From: <aa...@sv...> - 2008-02-29 09:27:53
|
Author: aaime Date: 2008-02-29 01:27:36 -0800 (Fri, 29 Feb 2008) New Revision: 29506 Modified: geotools/branches/2.4.x/modules/plugin/postgis/src/main/java/org/geotools/data/postgis/PostgisDataStore.java Log: Prevent NPE when no geometry type is provided, prevent NPE when the data is not 3D and WKB is used Modified: geotools/branches/2.4.x/modules/plugin/postgis/src/main/java/org/geotools/data/postgis/PostgisDataStore.java =================================================================== --- geotools/branches/2.4.x/modules/plugin/postgis/src/main/java/org/geotools/data/postgis/PostgisDataStore.java 2008-02-28 10:01:39 UTC (rev 29505) +++ geotools/branches/2.4.x/modules/plugin/postgis/src/main/java/org/geotools/data/postgis/PostgisDataStore.java 2008-02-29 09:27:36 UTC (rev 29506) @@ -1823,19 +1823,17 @@ */ protected AttributeIO getGeometryAttributeIO(AttributeType type, QueryData queryData) { + // grab the crs if available GeometryAttributeType geometryType = (GeometryAttributeType) type; - CoordinateReferenceSystem crs = geometryType.getCoordinateSystem(); + CoordinateReferenceSystem crs = null; + if(geometryType != null) + crs = geometryType.getCoordinateSystem(); + Hints hints = queryData != null ? queryData.getHints() : GeoTools.getDefaultHints(); - int D = (crs == null || Boolean.TRUE.equals( queryData.getHints().get( Hints.FEATURE_2D ))) ? 2 : crs.getCoordinateSystem().getDimension(); if (WKBEnabled) { - if( D == 3 ){ return new PgWKBAttributeIO(isByteaEnabled(), hints); - } - else { - return null; - } } else { if( D == 3 ){ return new EWKTAttributeIO(); |