Python mapscript & OGR.py
Frank Warmerdam
fwarmerdam at GMAIL.COM
Wed Feb 9 11:59:01 PST 2005
On Wed, 9 Feb 2005 10:01:33 -0800, Ryan, Adam <ARyan at co.linn.or.us> wrote:
> 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?
Adam,
Eventually I would like to have methods for quickly turning OGR Features
(or at least OGR Geometries) into ShapeObjs and the opposite. In the
meantime this is messy. One option (in addition to the method that Sean
discusses) is to setup an OGR "memory layer". It is a lightweight OGR
datasource that is stored completely in memory. You could have your
python fetch the features you want from the disk file via whatever
mechanism, and with whatever post processing (ie OGR GEOS funcs)
you want. Then copy the features to a memory layer and setup the layer
CONNECTION definition to refer to that memory layer.
The tricky parts are likely to be creating the memory datasource in
"shared" mode so that MapServer can re-open it without knowing it
is already open. Also, it may be tricky to get the proper datasource name
for the memory datasource/layer. If you are really keen to pursue this
approach let me know, and I could try and work through a working
example for you to work from.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
More information about the MapServer-users
mailing list