[mapserver-users] MapScript ShapFileObj
jhevenor at rogers.com
Thu Jul 16 16:35:58 EDT 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";
// 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:
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the mapserver-users