[Gdal-dev] How to Create a Geometry Filter

Kent Eschenberg eschenbe at psc.edu
Wed Oct 10 17:03:12 EDT 2007


Greetings,

This is a combination complaint/question. I'm trying to use the layer classes' 
  geometry filter to select only features in an area bounded by 4 points.

I can't do that directly but must use SetSpatialFilter and first create an 
instance of OGRPolygon. I do so and look for a way to set the polygon's points.

I can't do that directly but must use addRing and first create an instance of 
OGRLinearRing. I do that and look for a way to set the ring's points.

I can't do that directly but must use importFromWkb and first create a buffer 
of "the well known binary data".

Perhaps it is well known in an alternate universe but I can't find it anywhere 
in the documentation that came with the GDAL library.

Being a good programmer I looked at ogrlinearring.cpp for the routine 
"importFromWkb". All it does is return

    OGRERR_UNSUPPORTED_OPERATION

That doesn't look promising but I also found an undocumented routine hiding in 
that file, _importFromWkb, which doesn't even bother to claim that its "stream 
buffer" input is well known.

Is this the best thing to do? To create a "stream buffer" to create a "ring" to 
create a polygon to create a filter for a layer?

I should document this adventure in a file named "wild_goose_chase.shp".

Kent
Pittsburgh Supercomputing Center



More information about the Gdal-dev mailing list