Python mapscript & OGR.py

Sean Gillies sgillies at FRII.COM
Wed Feb 9 10:30:05 PST 2005


On Feb 9, 2005, at 11:01 AM, Ryan, Adam wrote:

> Two great tastes that taste great together.  But how to mix them in
> the same
> bowl of scripts eludes me.
>
> To utilize OGRGeometry methods on a mapscript.layerObj I need to
> instantiate
> an OGRLayer using layerObj.data?  OK, so I have dual classes; it's not
> that
> big a deal.  But eventually I want to use the results of my OGR spatial
> querying (within, crosses, etc.).  What I need is a way to replace my
> layerObj's resultCacheObj() with my list of OGRFeatures WITHOUT doing a
> (very slow) queryByIndex for each feature.
>
> Any thoughts?  Scrap that idea and use postGIS?
>
> Cheers,
>
> Adam
>

Adam,

Iterate over your list of OGR features, build up a shapeObj from each
Geometry, and then use layerObj::addFeature() to pop these shapes into
the inline features of a layer.  They will draw just like a normal
layer's features -- except that you will have to classify them yourself
by assigning values to each shape's classindex attribute.
Unfortunately, building up shapeObjs using the mapscript API is
sloooooooowwwwwwwwwww.  The fastest possible builder for shapeObjs
using only Python is shown around line 108 of the attached file, but is
still very slow.

I think you should collaborate with me on my Python Cartographic
Library.  It has a framework for feature querying and classification
that uses ogr.py and uses mapscript.py for the actual map rendering.
Email me offline and I'll tell you all about it.

cheers,
Sean

--
Sean Gillies
sgillies at frii dot com
http://users.frii.com/sgillies
-------------- next part --------------
A non-text attachment was scrubbed...
Name: timeshapes.py
Type: application/octet-stream
Size: 6442 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20050209/854bc868/attachment.obj>


More information about the MapServer-users mailing list