At some point recently JTS added better support for XY, XYZ, XYZM, XYM
coordinates out-of-the box; rather than as a code example of how it could
be done. GeoTools makes use of this functionality now as you have
determined.

The coordinate system you are using - what does it say? Checking
https://epsg.io/32617 shows two axis are defined; so geotools is providing
a dimension of 2.  The UTM coordinate systems do not allow for an
elevation...

If you are stepping outside of a standard projection and make up your own
with an elevation GeoTools should be able to continue to work if you add a
prj file to your shapefile that describes the addition of an elevation axis.
--
Jody Garnett


On Wed, 6 Oct 2021 at 06:05, Peter Friess <pk.fri...@t-online.de> wrote:

> 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 using jts-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
>
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to