PHP mapscript 7.0.0 ms_newGridObj appears non-functional #5159

Closed
dshorthouse opened this Issue Sep 6, 2015 · 16 comments

Comments

Projects
None yet
4 participants
@dshorthouse
Contributor

dshorthouse commented Sep 6, 2015

I upgraded to 7.0.0 from 6.4.2 and I cannot get ms_newGridObj to work in PHP mapscript, which was working just fine. No errors are thrown with the same code - just no GRID no matter what I attempt. When I use shp2img using a barebones map file however, GRID does work.

@dshorthouse

This comment has been minimized.

Show comment
Hide comment
@dshorthouse

dshorthouse Sep 21, 2015

Contributor

Can anyone verify this?

Contributor

dshorthouse commented Sep 21, 2015

Can anyone verify this?

@dshorthouse

This comment has been minimized.

Show comment
Hide comment
@dshorthouse

dshorthouse Sep 22, 2015

Contributor

I had a suspicion that the GRID block was not being created with ms_newGridObj. If it's any indication, saving out the map object to a mapfile sure enough shows the complete absence of the GRID block. As a workaround, I'm temporarily using updateFromString to programmatically inject the GRID block.

Contributor

dshorthouse commented Sep 22, 2015

I had a suspicion that the GRID block was not being created with ms_newGridObj. If it's any indication, saving out the map object to a mapfile sure enough shows the complete absence of the GRID block. As a workaround, I'm temporarily using updateFromString to programmatically inject the GRID block.

@tbonfort

This comment has been minimized.

Show comment
Hide comment
@tbonfort

tbonfort Sep 23, 2015

Member

please provide a minimal php script that exhibits the behavior

Member

tbonfort commented Sep 23, 2015

please provide a minimal php script that exhibits the behavior

@dshorthouse

This comment has been minimized.

Show comment
Hide comment
@dshorthouse

dshorthouse Sep 23, 2015

Contributor
<?php

$mapfile_string = "
    MAP
        OUTPUTFORMAT
            NAME png
            DRIVER AGG/PNG
            IMAGEMODE RGB
            MIMETYPE 'image/png'
            EXTENSION 'png'
        END
    END";

$projection = 'proj=longlat,ellps=WGS84,datum=WGS84,no_defs';

# MAP Object
$map_obj = ms_newMapObjFromString($mapfile_string);
$map_obj->setProjection($projection);
$map_obj->set("name", "grid_test");
$map_obj->web->set("template", "template.html");
$map_obj->set("units", MS_DD);
$map_obj->selectOutputFormat("png");
$map_obj->setExtent(-180, -90, 180, 90);
$map_obj->setSize(600,200);

# GRID Layer
$layer = ms_newLayerObj($map_obj);
$layer->set("name", "grid");
$layer->set("type", MS_LAYER_LINE);
$layer->set("status", MS_ON);
$layer->setProjection($projection);

$class = ms_newClassObj($layer);
$style = ms_newStyleObj($class);
$style->color->setRGB(200, 200, 200);

/* GRID ... END IS NOT CREATED in 7.0.0 */
ms_newGridObj($layer);
$layer->grid->set("labelformat", "DDMMSS");

/* ALTERNATE GRID CREATION FROM STRING
$grid_string  = 'LAYER name "grid"' . "\n";
$grid_string .= 'GRID' . "\n";
$grid_string .= 'labelformat "DDMMSS"' . "\n";
$grid_string .= 'END' . "\n";
$grid_string .= 'END' . "\n";
$layer->updateFromString($grid_string);
*/

# OUTPUT
header("Content-Type: image/png");
$image = $map_obj->drawQuery();
$image->saveImage("");

/* ALTERNATE OUTPUT TO MAPFILE
$map_obj->save("/tmp/mapfile.map");
*/
Contributor

dshorthouse commented Sep 23, 2015

<?php

$mapfile_string = "
    MAP
        OUTPUTFORMAT
            NAME png
            DRIVER AGG/PNG
            IMAGEMODE RGB
            MIMETYPE 'image/png'
            EXTENSION 'png'
        END
    END";

$projection = 'proj=longlat,ellps=WGS84,datum=WGS84,no_defs';

# MAP Object
$map_obj = ms_newMapObjFromString($mapfile_string);
$map_obj->setProjection($projection);
$map_obj->set("name", "grid_test");
$map_obj->web->set("template", "template.html");
$map_obj->set("units", MS_DD);
$map_obj->selectOutputFormat("png");
$map_obj->setExtent(-180, -90, 180, 90);
$map_obj->setSize(600,200);

# GRID Layer
$layer = ms_newLayerObj($map_obj);
$layer->set("name", "grid");
$layer->set("type", MS_LAYER_LINE);
$layer->set("status", MS_ON);
$layer->setProjection($projection);

$class = ms_newClassObj($layer);
$style = ms_newStyleObj($class);
$style->color->setRGB(200, 200, 200);

/* GRID ... END IS NOT CREATED in 7.0.0 */
ms_newGridObj($layer);
$layer->grid->set("labelformat", "DDMMSS");

/* ALTERNATE GRID CREATION FROM STRING
$grid_string  = 'LAYER name "grid"' . "\n";
$grid_string .= 'GRID' . "\n";
$grid_string .= 'labelformat "DDMMSS"' . "\n";
$grid_string .= 'END' . "\n";
$grid_string .= 'END' . "\n";
$layer->updateFromString($grid_string);
*/

# OUTPUT
header("Content-Type: image/png");
$image = $map_obj->drawQuery();
$image->saveImage("");

/* ALTERNATE OUTPUT TO MAPFILE
$map_obj->save("/tmp/mapfile.map");
*/
@tbonfort

This comment has been minimized.

Show comment
Hide comment
@tbonfort

tbonfort Sep 29, 2015

Member

Caused by the changes in #4913 . Assigning to @szekerest

Member

tbonfort commented Sep 29, 2015

Caused by the changes in #4913 . Assigning to @szekerest

@tbonfort tbonfort assigned tbonfort and szekerest and unassigned tbonfort Sep 29, 2015

szekerest added a commit to szekerest/mapserver that referenced this issue Oct 2, 2015

@szekerest

This comment has been minimized.

Show comment
Hide comment
@szekerest

szekerest Oct 2, 2015

Member

Could someone check if the commit above is working?
I have no chance to test php at the moment.

Member

szekerest commented Oct 2, 2015

Could someone check if the commit above is working?
I have no chance to test php at the moment.

@jmckenna

This comment has been minimized.

Show comment
Hide comment
@jmckenna

jmckenna Oct 29, 2015

Member

Checking....

Member

jmckenna commented Oct 29, 2015

Checking....

@jmckenna

This comment has been minimized.

Show comment
Hide comment
@jmckenna

jmckenna Oct 29, 2015

Member

i get the same issue with master, on windows, with that test script (GRID object is not written to the mapfile).

Member

jmckenna commented Oct 29, 2015

i get the same issue with master, on windows, with that test script (GRID object is not written to the mapfile).

@tbonfort

This comment has been minimized.

Show comment
Hide comment
@tbonfort

tbonfort Oct 29, 2015

Member

@szekerest posted a proposed fix in his clone in 57f9ecb but nobody tried it out. it has not been merged into master or branch-7-0 as it hasn't been tested.

Member

tbonfort commented Oct 29, 2015

@szekerest posted a proposed fix in his clone in 57f9ecb but nobody tried it out. it has not been merged into master or branch-7-0 as it hasn't been tested.

@jmckenna

This comment has been minimized.

Show comment
Hide comment
@jmckenna

jmckenna Oct 29, 2015

Member

good lord i just spent 2 hours getting master to work here. umm....can you apply this to master so it is easier to test?

Member

jmckenna commented Oct 29, 2015

good lord i just spent 2 hours getting master to work here. umm....can you apply this to master so it is easier to test?

@tbonfort

This comment has been minimized.

Show comment
Hide comment
@tbonfort

tbonfort Oct 29, 2015

Member

not applying to master before someone actually confirms it fixes the issue given tamas couldn't test.

git remote add szekerest https://github.com/szekerest/mapserver.git
git fetch szekerest
git checkout 57f9ecb
=>build and test!
Member

tbonfort commented Oct 29, 2015

not applying to master before someone actually confirms it fixes the issue given tamas couldn't test.

git remote add szekerest https://github.com/szekerest/mapserver.git
git fetch szekerest
git checkout 57f9ecb
=>build and test!
@jmckenna

This comment has been minimized.

Show comment
Hide comment
@jmckenna

jmckenna Oct 29, 2015

Member

for windows i have to make many custom changes, for my builds to work (especially for the mapscripts). It is hard to explain.

Member

jmckenna commented Oct 29, 2015

for windows i have to make many custom changes, for my builds to work (especially for the mapscripts). It is hard to explain.

@tbonfort

This comment has been minimized.

Show comment
Hide comment
@tbonfort

tbonfort Oct 29, 2015

Member

then let @dshorthouse test the fix. this isn't windows specific.

Member

tbonfort commented Oct 29, 2015

then let @dshorthouse test the fix. this isn't windows specific.

@jmckenna

This comment has been minimized.

Show comment
Hide comment
@jmckenna

jmckenna Oct 29, 2015

Member

I confirm this fix (manually, with files from @szekerest 's clone). The resulting map image contains grid lines. The resulting map layer does contain a GRID object:

  LAYER
    NAME "grid"
    PROJECTION
      "proj=longlat"
      "ellps=WGS84"
      "datum=WGS84"
      "no_defs"
    END # PROJECTION
    STATUS ON
    TILEITEM "location"
    TYPE LINE
    UNITS METERS
    CLASS
      STYLE
        COLOR 200 200 200
      END # STYLE
    END # CLASS
    GRID
      LABELFORMAT "%3d %02d %02d"
      MAXSUBDIVIDE 256
      MINSUBDIVIDE 256
    END # GRID
  END # LAYER
Member

jmckenna commented Oct 29, 2015

I confirm this fix (manually, with files from @szekerest 's clone). The resulting map image contains grid lines. The resulting map layer does contain a GRID object:

  LAYER
    NAME "grid"
    PROJECTION
      "proj=longlat"
      "ellps=WGS84"
      "datum=WGS84"
      "no_defs"
    END # PROJECTION
    STATUS ON
    TILEITEM "location"
    TYPE LINE
    UNITS METERS
    CLASS
      STYLE
        COLOR 200 200 200
      END # STYLE
    END # CLASS
    GRID
      LABELFORMAT "%3d %02d %02d"
      MAXSUBDIVIDE 256
      MINSUBDIVIDE 256
    END # GRID
  END # LAYER
@dshorthouse

This comment has been minimized.

Show comment
Hide comment
@dshorthouse

dshorthouse Oct 30, 2015

Contributor

Thanks @jmckenna for confirming the fix. Apologies for not being able to do it myself. I'll let others close the fix once it's pulled into master.

Contributor

dshorthouse commented Oct 30, 2015

Thanks @jmckenna for confirming the fix. Apologies for not being able to do it myself. I'll let others close the fix once it's pulled into master.

szekerest added a commit that referenced this issue Oct 30, 2015

@tbonfort

This comment has been minimized.

Show comment
Hide comment
@tbonfort

tbonfort Oct 30, 2015

Member

applied to branch-7-0 in 4dacec0

Member

tbonfort commented Oct 30, 2015

applied to branch-7-0 in 4dacec0

@tbonfort tbonfort closed this Jan 4, 2016

@tbonfort tbonfort added this to the 7.0.1 milestone Feb 23, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment