[Mapserver-users] Does anyone success add point persistent to shape?
Eric Bridger
eric at gomoos.org
Mon Jun 7 12:19:35 PDT 2004
There is a difference between a LAYER and a shapefile. Typically the
DATA member of a LAYER is a shapefile name. This is probably the default
case. But a new layer "$newLyr = new_msLayerObj(" has no DATA member
set yet, so the $newLyr->open() will fail.
What you want is a shape file object. See
http://mapserver.gis.umn.edu/doc/phpmapscript-class-guide.html#shapefileObj
and use the $shapefile->add() method. Call $shapefile->free() to save
the file and then you can draw the layer if it's DATA member points to
the shapefile you just saved. So I guess you want:
LAYER
NAME "test_point"
DATA "myshapefile"
$layer = $mapObj->getLayerByName("test_point");
$shapefile = ms_newShapefileObj($layer->{data}, $MS_SHAPE_POINT);
... add your point or shape.
$shapefile->free();
$layer->draw($imgObj);
(you might have to do another getLayerByName() to reload the layer, but
probalby not.)
On Mon, 2004-06-07 at 14:46, Dave McCann wrote:
> We are looking for a similar function to write point/polygon data that a
> user plots on a map. Have you been successful in finding the answer?
>
> Anyone else out there know of an answer?
>
> Thanks,
>
> Dave
>
> -----Original Message-----
> From: mapserver-users-admin at lists.gis.umn.edu
> [mailto:mapserver-users-admin at lists.gis.umn.edu] On Behalf Of No dream more
> Sent: Friday, June 04, 2004 12:05 AM
> To: Mapserver-users at lists.gis.umn.edu
> Subject: [Mapserver-users] Does anyone success add point persistent to
> shape?
>
>
> Dear list,
>
> I am customizing the interface from mapserver workshop to implementing a
> function to add point to map. But I got some problem:
> - If I create a new layer then I open layer for adding a point. The error
> always is "msSHPOpenFile(): No (NULL) filename provided".
> $newLyr = new_msLayerObj($mapObj);
> if($newLyr->open()==MS_SUCCESS){ ////// -> msSHPOpenFile(): No (NULL)
> filename provided
> }
>
> - I can add a point to existing layer but I can add only one point. This
> point cannot be save to shape file.
>
> //$newLyr = new_msLayerObj($mapObj);
> $newLyr = $mapObj->getLayerByName("test_point");
>
> $newPoint = ms_newPointObj();
> $newPoint->setXY($x, $y);
>
> $newLine = ms_newLineObj();
> $newLine.add($newPoint);
>
> $newShp = ms_newShapeObj(MS_SHAPE_POINT);
> $newShp->add($newLine);
>
> $imgObj = $mapObj->draw(); (If this call, the point
> can draw)
> //$imgObj = $mapObj->prepareImage(); (If this call, I got only a
> blank screen)
>
> $newLyr->draw($imgObj);
> $imgObj->saveImage("");
>
> Does anyone success add point persistent to shape?
>
> Thank.
>
> Le Ngoc Lam
>
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>
>
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>
More information about the MapServer-users
mailing list