[mapserver-users] MapScript ShapFileObj
Josh Hevenor
jhevenor at rogers.com
Thu Jul 16 13:35:58 PDT 2009
I have a quick question about the ShapeFileObj class in PHP mapscript
then I'd like to throw out an offer and see who wants to take me up on it.
First my question. I'm trying to write a quick data exporter. The
general process is, query a spatial database, loop through the results
and build a shapefile, export the shapefile. I'm not having any run-time
failures but my result has only .SHP, .SHX files. When I look at the
shapefile in ogrinfo I see my points but no projection, and when I use
ogr2ogr to add a projection I see that there's no attribute
information...only the points.
My code looks similar to this:
// Open map object
$map = ms_newmapobj($mapPath);
$layer = $map->getLayerByName($layerName);
// Create shapefileobj with random name
$rnd = time();
$filePath = "C:\\Inetpub\\wwwroot\\tmp\\Extract\\$rnd";
$fileName = $filePath . "somename"; // no extension
$oShapeFile = ms_newShapefileObj($fileName, $layerType); // assume
MS_SHP_POINT for this example
$status = $layer->open();
$status = $layer->whichShapes($map->extent);
while ($shape = $layer->nextShape())
{
$id = $shape->values[$idField];
echo "Adding shape with ID = $id\n";
$oShapeFile->addShape($shape);
$shape->free();
}
$layer->close();
$oShapeFile->free();
// zip up and return to browser
Any suggestions would be appreciated.
Now my offer. I usually get by with the available documentation and a
decent archive of old projects to compare from. The documentation for
this object is pretty sparse:
http://mapserver.org/mapscript/php/index.html#shapefileobj-class The
SWIG api doc looks about the same. I'd like to put together an example
for each class function to flesh out the doc. If there are a lot of
interested participants we could do all the classes, but for now I'll
start with ShapeFileObj. If there's something like this on the go
already, let me know how I can help.
Thanks,
Josh Hevenor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20090716/537c6b67/attachment.htm>
More information about the MapServer-users
mailing list