[Geoserver-devel] Discrepancy in GeoServerFeatureSource getSchema() and getBounds()

Hi,
looking into the build failures caused by Jody's MapContext
refactor I found that there is a discrepancy in how we handle
the reprojeciton policy in GeoServerFeatureSource.

Basically, getSchema() and getFeatures() do apply the reprojection
policies, but getBounds() returns the native bounds always,
forgetting about crs forcing and reprojecting.

Unfortunately the fix is not easy as there is code using the
getBounds() method to compute a layer _native_ bounds, for
example, see CatalogBuilder().getNativeBounds().

I would like to fix the above, but how?
Ideas:
- have the CatalogBuilder() dodge the FeatureTypeInfo().getFeatureSource() method and
   call onto the data store directly to get the feature
   source (uses internal knowledge that the store is
   not being wrapped)
- expose in GeoServerFeatureSource() getNativeBounds()/
   getNativeBounds(query) methods and have the builder
   perform a cast? However that will break when using
   read only security wrappers

Bummer... I guess option a) is the only feasible one?

And once we have that fixed, the current GeoServerFeatureSource().getBounds()
can simply be made to call getFeatures(q).getBounds(),
since we do handle the reprojection properly in getFeatures()

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

On 15/06/2010, at 11:39 PM, Andrea Aime wrote:

Hi,
looking into the build failures caused by Jody's MapContext
refactor I found that there is a discrepancy in how we handle
the reprojeciton policy in GeoServerFeatureSource.

Basically, getSchema() and getFeatures() do apply the reprojection
policies, but getBounds() returns the native bounds always,
forgetting about crs forcing and reprojecting.

Unfortunately the fix is not easy as there is code using the
getBounds() method to compute a layer _native_ bounds, for
example, see CatalogBuilder().getNativeBounds().

I would like to fix the above, but how?
Ideas:
- have the CatalogBuilder() dodge the
FeatureTypeInfo().getFeatureSource() method and
  call onto the data store directly to get the feature
  source (uses internal knowledge that the store is
  not being wrapped)
- expose in GeoServerFeatureSource() getNativeBounds()/
  getNativeBounds(query) methods and have the builder
  perform a cast? However that will break when using
  read only security wrappers

Bummer... I guess option a) is the only feasible one?

c) Can you somehow mark your with an interface; and have a method to return the "native" FeatureSource? Less api if nothing else.

if( featureSource instanceof WrappedFeatureSource){
   WrappedFeatureSource wrapped = (WrappedFeatureSource) featureSource;
   return wrapped.getBounds(); // returns the native bounds
}

Jody