Hi All,

Yesterday, I replaced in our application Geotools 21.2 with 25.2. After the replacement certain features I implemented, unfortunately,  do not work any longer. When displaying a shapefile, I get the following exception:

/"Must have at least 2 spatial dimensions" / which is throws by PackedCoordinateSequence.I therefore started debugging to figure out what happens.

The shapefile's geometry is a point given in east, north, height: builder.add(gf.createPoint(new Coordinate(enh.getX(), enh.getY(), enh.getZ())));

I need a 3D point as we have implemented a viewer (independent from GeoTools) which can display our shapefiles in 3D (actually perspective view). When I create the shapefile with easting and northing only, the above exception is not thrown, But, this is not a solution as I need a 3D point. The coordinate reference  system is EPSG:32617, i.e. WGS84 UTM zone 17 .

We have pure shapefile viewers and we have shapefile editors. When allowing for editing, I keep the features in memory, i.e.  I create a SimpleFeatureSource as:

SimpleFeatureCollection collection = DataUtilities.collection(source.getFeatures());
 return DataUtilities.source(collection);

Now, for the SimpleFeatureSource created by DataUtilities the hints are null. Thus, when rendering the features StreamingRenderer calls getTransformedShape which than clones the geometry by calling LiteCoordinateSequence.cloneGeometry(geom, dim). The dimension dim is 2, received from CRS (UTM 17).

cloneGeometry checks the type which is in my case a Point and calls cloneGeometry(Point geom, int dimension) which calls

geomFac.createPoint(new LiteCoordinateSequence(geom.getCoordinateSequence(), dimension));

new LiteCoordinateSequence calls super(dimension, cs.getMeasures()), because it is of type PackedCoordinateSequence. The code looks as:

protected PackedCoordinateSequence(int dimension, int measures ) {
      if (dimension - measures < 2) {
         throw new IllegalArgumentException("Must have at least 2 spatial dimensions");
      }
      this.dimension = dimension;
      this.measures = measures;
  }

And here is the problem: dimension is 2 as provided by the CRS, and the measures (whatever this is) is 1. This measures is derived from Point somehow. The Point is turned into a CoordinateSequence and this has for whatever reason a mesasures of 1. And the cloning fails.

As said before: with GeoTools 21.2 it all worked fine. Now I am screwed. Is there any solution to this? A different version of the jts-core-xx.jar. I am usingjts-core-1.18.1.  Well, I did not choose it myself, Maven downloaded it.

Going back to Geotools 21.2, is in my opinion also not a solution. We would like to stay as close as possible to the most recent version of Geotools.

Any help is very much appreciated is this issue blocks our development.

Regards,

Peter




_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to