Adding Layer with 2.5D geometry trips up over number of ordinates when generating initial bounds

Description

When adding a layer:

  • Native Bounding Box link for <b>Compute from data</b>
    * Lat/Lon Bounding Box link for <b>Compute from native bounds</b>

Both fail to calculate an appropriate bounds for the dataset.

java.lang.RuntimeException: org.opengis.geometry.MismatchedDimensionException: Argument "GDA94" has 3 dimensions, while 2 was expected.
at org.geotools.jdbc.JDBCFeatureSource.getBoundsInternal(JDBCFeatureSource.java:508)
at org.geotools.data.store.ContentFeatureSource.getBounds(ContentFeatureSource.java:426)
at org.geotools.data.store.ContentFeatureSource.getBounds(ContentFeatureSource.java:363)
at org.vfny.geoserver.global.GeoServerFeatureSource.getBounds(GeoServerFeatureSource.java:591)
at org.geoserver.catalog.CatalogBuilder.getNativeBounds(CatalogBuilder.java:555)
at org.geoserver.catalog.CatalogBuilder.getNativeBounds(CatalogBuilder.java:537)

Okay running from eclipse shows the root cause:

Caused by: org.opengis.geometry.MismatchedDimensionException: Argument 2 was expected.
at org.geotools.geometry.jts.ReferencedEnvelope.checkCoordinateReferenceSystemDimension(ReferencedEnvelope.java:287)
at org.geotools.geometry.jts.ReferencedEnvelope.&lt;init&gt;(ReferencedEnvelope.java:160)
at org.geotools.jdbc.JDBCDataStore.getBounds(JDBCDataStore.java:1123)
at org.geotools.jdbc.JDBCFeatureSource.getBoundsInternal(JDBCFeatureSource.java:501)

The code in ReferencedEnvelope is here:

ReferencedEnvelope(CoordinateReferenceSystem crs)
MismatchedDimensionException {
.crs = crs;
checkCoordinateReferenceSystemDimension();
}
void checkCoordinateReferenceSystemDimension()
MismatchedDimensionException {
) {
expected = getDimension();
dimension = crs.getCoordinateSystem().getDimension();
(dimension &gt; expected) {
MismatchedDimensionException(Errors.format(
ErrorKeys.MISMATCHED_DIMENSION_$3, crs.getName().getCode(),
(expected)));
}
}
}

So basically the data stores are supposed to look at the CRS and choose if they want to construct an ReferencedEnvelope or a ReferencedEnvelope3D.

Well nobody has updated the base classes, such as ContentDataStore yet. Indeed this is a bit of a pain, there should be a factory method to sort it out:

// casting
ReferencedEnvelope.reference( BoundingBox )
ReferencedEnvelope.reference( Envelope )
ReferencedEnvelope.reference( Envelope )

// factory
ReferencedEnvelope.create( Envelope, CoordinateReferenceSystem )
ReferencedEnvelope.create( CoordinateReferenceSystem )

So I am going to have to go create a GeoTools bug for this one.

Environment

None

Status

Assignee

Unassigned

Reporter

codehaus

Triage

None

Fix versions

Affects versions

2.2.1

Components

Priority

Low
Configure