[mapserver-users] PHP Mapscript: getFeature / addFeature

Chris Green chris.green at ibstv.co.uk
Thu Oct 20 10:08:56 PDT 2011


Dear List

 

I'm struggling with what should be (I think) quite simple. I want to get a
feature from one layer of a map then add it to another layer. I am using
Mapserver 6.0 and PHP mapscript like so:

 

 

$map = ms_newMapobj("path/to/.map");

$layer1=$map->getLayerByName("countries");

 

$layer2=$map->getLayerByName("highlightCountry");

 

$country='France';

 

$layer1->queryByAttributes('NAME', $country , MS_SINGLE );

  

$shape = $layer1->getShape($layer1->getResult(0));

 

$layer2->open();

 

$layer2->addFeature($shape); ##  I get a Mapserver 'internal error' at this
point ##

 

$layer2->close();

 

$image=$map->draw();

 

 

Extract from my mapfile:

 

LAYER

       NAME "countries" 

       DATA "world"

       STATUS default

       TYPE   line  

 

       CLASS

              STYLE        

                     COLOR  255 255 255

                    WIDTH   1

              END # style

       END # class

 

END #layer

 

LAYER

       NAME "highlightCountry" 

       STATUS  default

       TYPE   line  

 

       CLASS

             STYLE        

                     COLOR  255 255 0

                     WIDTH  4      

             END # style

       END # class

 

 

END # layer

 

 

Can anyone help?

 

 

 

Chris

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20111020/6ca07c04/attachment.htm>


More information about the MapServer-users mailing list