[Gdal-dev] Evolution of OGRLayer ?

Frank Warmerdam warmerdam at pobox.com
Mon Sep 22 08:58:50 EDT 2003


Jean wrote:
> Here is a proposition for OGRLayer
> 
> There is two way to access a Feature with an OGRLayer
> 1 - A sequential access via GetNextFeature.
> 2 - A direct access via its FeatureID : GetFeature(long aFeatureID).
> 
> Some records provider (like ADO for example) bring another type of acess
> : GetFeature(long aRecordPositionInCurrentQuery)
...
> So would you be interrested in a public method on OGRLayer to get
> aFeature via its Query's position ?
> 
> if (OLCRandomRead) is available
> OGRFeature* GetFeatureFromPosition(long aRecordPosition); 

Jean,

I can see your point about why this would be desirable in some
circumstances.  However, it isn't so obvious to me that I could correctly
and efficiently implement such an operation on many of the existing formats
with a reasonable amount of effort.   I would add that it would be even
harder to implement this efficiently if the query is anything other than
"get the whole layer".

I would encourage you to file this as a feature request in bugzilla, but
for the time being I won't be acting on it.

I assume you are interested in implementing such a grid display/editing mode
for large layers where it would be impractical to hold them all in memory?
If the layers to be operated on are not too huge, my first suggestion would
be to load all features into a memory layer and then have the grid display
operate against that.  A "Memory" OGR driver was implemented a few months
ago specifically for high speed access for editing in interactive
applications.

If the layers are likely to be too large to load into RAM, some other
approach would be necessary.   Depending on the format, my suggestion
would be to either make one pass recording the feature id's for subsequent
direct feature requests (cost 4 bytes per feature of RAM, and one pass)
or to basically sequentually read through to the desired area for each
display update, likely keeping a substantial "window" of features in
RAM in the application to avoid having to re-read for refreshes, or small
moves through the result.

> Hoping my english is not that bad, 

Very understandable.

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 Gdal-dev mailing list