Global Mapper Pro

Pass 2 file pat as variables on a command line

_XD_
_XD_ Global Mapper User
edited March 2014 in GM Script Language
Hello,

I'm using GMV15.1.

I've written a "little" script to convert a .jp2 file to a GeoTiff file. Il looks like :
GLOBAL_MAPPER_SCRIPT VERSION=1.00
SET_LOG_FILE FILENAME="C:\Program Files\GlobalMapper15\Script\log_jp2ToGeoTiff.txt"


IMPORT FILENAME="%SOURCE%"
EXPORT_RASTER FILENAME="%TARGET%" TYPE="GEOTIFF"
And I want to call it from a script .bat that way :
"c:\Program Files\GlobalMapper15\global_mapper.exe" "c:\Program Files\GlobalMapper15\Script\Utilities\jp2_to_GeoTiff.gms" -SOURCE "d:\imageJP2\myImage.JP2" -TARGET "d:\imageGeoTiff\myImage.TIFF"

Unfortunately it does not work :-(. In logs I have:
Command line parameter string: '-SOURCE "d:\imageJP2\myImage.JP2" -TARGET "d:\imageGeoTiff\myImage.TIFF"'
Defined variable '%SOURCE%' to value '"d:\imageJP2\myImage.JP2" from command line parameter
Defined variable '%TARGET%' to value 'd:\imageGeoTiff\myImage.TIFF from command line parameter
WARNING: Empty FILENAME parameter for IMPORT command.
Exporting raster data to file d:\imageGeoTiff\myImage.TIFF...
ERROR: Data must be loaded for EXPORT_RASTER command.
Script processing COMPLETED [End Time: 03/12/14 12:30:50, Elapsed Time: 0.000 seconds]

If I switch variables
"c:\Program Files\GlobalMapper15\global_mapper.exe" "c:\Program Files\GlobalMapper15\Script\Utilities\jp2_to_GeoTiff.gms" -TARGET "d:\imageGeoTiff\myImage.TIFF" -SOURCE "d:\imageJP2\myImage.JP2"
I have:
Command line parameter string: '-TARGET "d:\imageGeoTiff\myImage.TIFF" -SOURCE "d:\imageJP2\myImage.JP2"'
Defined variable '%TARGET%' to value '"d:\imageGeoTiff\myImage.TIFF" from command line parameter
Defined variable '%SOURCE%' to value 'd:\imageJP2\myImage.JP2 from command line parameter
Importing file d:\imageJP2\myImage.JP2...
WARNING: Unknown parameter <d:\imageGeoTiff\myImage.TIFF""> ignored.
WARNING: Empty FILENAME parameter for EXPORT_RASTER command.
ERROR: Missing FILENAME parameter for EXPORT_RASTER command.
Script processing COMPLETED [End Time: 03/12/14 12:31:59, Elapsed Time: 0.000 seconds]
Different... but not better...

Apparently there is a problem with variables parsing. How can I make it works ?

Thanks !

Xavier.

Comments

  • bmg_bob
    bmg_bob Global Mapper Programmer
    edited March 2014
    Hello Xavier,

    Thank you for using Global Mapper.

    I have been able to reproduce your problem. It looks like a bug in Global Mapper. I will investigate and see if I can put together a fix.

    Cheers,

    Bob
  • global_mapper
    global_mapper Administrator
    edited March 2014
    Bob was able to fix the issue. I have placed a new build at http://www.bluemarblegeo.com/downloads/global-mapper/global_mapper15.zip with the latest changes for you to try. Simply download that file and extract the contents into your existing v15.xx installation folder to give it a try. If you are using the 64-bit v15 version there is a new build at http://www.bluemarblegeo.com/downloads/global-mapper/global_mapper15_64bit.zip .

    Thanks,

    Mike
    Global Mapper Guru
    geohelp@bluemarblegeo.com
    Global Mapper
  • _XD_
    _XD_ Global Mapper User
    edited March 2014
    Hello Mike, hello Bob,

    Thank you for your answer that indeed correct my problem.

    Nevertheless I still have a strange behaviour when there are some spaces in file path. For instance if launch the same command but with a space between "image" and "JP2" in source path, and with a space between "image" and "GeoTiff" in target path :
    "c:\Program Files\GlobalMapper15\global_mapper.exe" "c:\Program Files\GlobalMapper15\Script\Utilities\jp2_to_GeoTiff.gms" -SOURCE "d:\[B]image JP2[/B]\myImage.JP2" -TARGET "d:\[B]image GeoTiff[/B]\myImage.tiff"
    
    I have this log :
    Command line parameter string: '-SOURCE "d:\image JP2\myImage.JP2" -TARGET "d:\image GeoTiff\myImage.tiff"'
    Defined variable '%SOURCE%' to value 'd:\image JP2\myImage.JP2" -TARGE' from command line parameter
    Defined variable '%TARGET%' to value 'd:\image GeoTiff\myImage.tiff"' from command line parameter
    Importing file d:\image JP2\myImage.JP2...
    WARNING: Unknown parameter <"> ignored.
    Exporting raster data to file d:\image GeoTiff\myImage.tiff...

    Well... it works ! I obtain a GeoTiff image in "image GeoTiff" directory so I can use my script like this. But it seems a little weird...

    Thanks,

    Xavier.
  • bmg_bob
    bmg_bob Global Mapper Programmer
    edited March 2014
    Hi Xavier,

    It appears that there is still a bug in the parameter parsing logic. I will take a look.

    Cheers,

    Bob
  • bmg_bob
    bmg_bob Global Mapper Programmer
    edited March 2014
    Hi Xavier,

    I fixed the parameter parsing problem. There is a new build at http://www.bluemarblegeo.com/downloads/global-mapper/global_mapper15.zip with the latest changes for you to try. Simply download that file and extract the contents into your existing v15.xx installation folder to give it a try. If you are using the 64-bit v15 version there is a new build at http://www.bluemarblegeo.com/downloads/global-mapper/global_mapper15_64bit.zip .
    Cheers,

    Bob
Sign In or Register to comment.