DEFINE_VAR in a projection

Ice Age MarkIce Age Mark Global Mapper UserPosts: 324Trusted User
edited July 2015 in GM Script Language
Howdy,


Here's a scripting challenge for someone more adept than myself. I have a global basemap (GEBCO14) that I use frequently and view it in Orthographic projection zoomed out the the full data extent - so that it looks like viewing a globe from space. I want to quickly and conveniently view the datasets I load over this basemap from different perspectives (center Lat/Longs). So I tried to make a simple script that would use the "DEFINE_VAR" command to "substitute" whatever Lat/Longs I entered into a "DEFINE_PROJ" command.




GLOBAL_MAPPER_SCRIPT VERSION="1.00" FILENAME="ORTHO PROJECTIONS.gmw"


DEFINE_VAR NAME="LAT" VALUE="" \
PROMPT="YES" PROMPT_TEXT="ENTER VIEW LATITUDE"


DEFINE_VAR NAME="LONG" VALUE="" \
PROMPT="YES" PROMPT_TEXT="ENTER VIEW LONGITUDE"


DEFINE_PROJ PROJ_NAME="MYORTHO"
Projection ORTHOGRAPHIC
Datum WGS84
Zunits NO
Units METERS
Xshift 0.000000
Yshift 0.000000
Parameters
%LONG% /* longitude of center of projection


%LAT% /* latitude of center of projection


0.000 /* false easting (meters)


0.000 /* false northing (meters)


0 0 0.000 /* xy_plane_rotation


END_DEFINE_PROJ


LOAD_PROJECTION PROJ="MYORTHO"
SET_VIEW GLOBAL_BOUNDS="-14474578.525,-6685800.595,14474572.327,6685806.140"




This doesn't work. It seems that the define projection command won't recognize the defined variables, and always uses 0N,0E (the default for Orthographic?) instead. Is it possible to do this somehow?


Right now, I keep a small file of pre-defined "view" projections set up (Noth Pole, South Pole, my location, IDL-EQ, etc.), name them with numbers, and use IF_ELSE's to pick from them. Kind of hokey, but it works. I know I can use the reprojection tab, but it's several steps, not convenient or quick, and doesn't re-zoom to the full data extent after the change like my script does.


Thanks for any ideas,


Mark

Comments

  • Ice Age MarkIce Age Mark Global Mapper User Posts: 324Trusted User
    edited June 2015
    Nobody knows if this can be made to work somehow? Or of a different way to script it?
  • JeffH@BMGJeffH@BMG Global Mapper Developer Posts: 337Trusted User
    edited July 2015
    Hi Mark,

    Sorry for the delay, I just got a chance to look into this, and discovered that the DEFINE_PROJ sections didn't honor variable replacement. I fixed that, and tested against your proposed script. A new version of Global Mapper containing the change is now available: Global Mapper Downloads. Simply download the appropriate installer and run it to install the latest build. Please let us know if you run into any problems.

    Thanks for the the heads-up!

    ~Jeff
  • Ice Age MarkIce Age Mark Global Mapper User Posts: 324Trusted User
    edited July 2015
    Jeff,

    Perfect! Thank you very, very much. It works exactly as I had imagined now. The other slick thing is that the script stays at or near the top of the dropdown list of recent files, so it's right there to use over and over.

    Thanks again,

    Mark
  • JeffH@BMGJeffH@BMG Global Mapper Developer Posts: 337Trusted User
    edited July 2015
    Hi Mark,

    Glad to hear it. DEFINE_PROJ sections are handled a little differently than other script commands; I think the fact that variable replacement wasn't there in the first place was just an oversight. It looks pretty useful, actually, so good catch.

    Best,

    ~Jeff
Sign In or Register to comment.