Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP mapscript 7.0.0 ms_newGridObj appears non-functional #5159

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

PHP mapscript 7.0.0 ms_newGridObj appears non-functional #5159

dshorthouse opened this issue Sep 6, 2015 · 16 comments
Assignees
Milestone

Comments

@dshorthouse
Copy link
Contributor

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
Copy link
Contributor Author

Can anyone verify this?

@dshorthouse
Copy link
Contributor Author

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
Copy link
Member

please provide a minimal php script that exhibits the behavior

@dshorthouse
Copy link
Contributor Author

<?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
Copy link
Member

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
Copy link
Member

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

@jmckenna
Copy link
Member

Checking....

@jmckenna
Copy link
Member

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

@tbonfort
Copy link
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.

@jmckenna
Copy link
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?

@tbonfort
Copy link
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!

@jmckenna
Copy link
Member

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

@tbonfort
Copy link
Member

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

@jmckenna
Copy link
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

@dshorthouse
Copy link
Contributor Author

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
Copy link
Member

applied to branch-7-0 in 4dacec0

@tbonfort tbonfort closed this as completed 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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants