Hi Ian

My points have a dimension of 3, see below, or let me repeat here:

gf.createPoint(new Coordinate(enh.getX(), enh.getY(), enh.getZ()

My points have X,Y,Z. The problem is that the CRS returns 2 as dimension, which is correct, but  in PackedCoordinateSequence it does this check (dimension - measures < 2) and this measures is 1. measures comes from my Point which contains XYZ (I checked in the debugger) when it gets converted to CoordinateSequence and this CoordinateSequence returns the 1 for the measures (cs.getMeasures()).

I have no clue what that measures meansand why it is 1. I also do not understand why it is necessary to involve a CRS to get a dimension if a Point gets (just) cloned.

Yes, it is a show stopper. What I want to try is, use jts-1.11 instead of jts-1.18. Not sure if that is compatible with Geotools 25.2. It is also not clear to me, who is responsible for jts. Is it the Geotools team, or some other team.

Regards,

Peter


Am 06.10.2021 um 17:19 schrieb Ian Turton:
This sounds like https://osgeo-org.atlassian.net/browse/GEOT-6599 <https://osgeo-org.atlassian.net/browse/GEOT-6599> which is marked as fixed, but your points should have a dimension of 3 (X,Y,Z) not 2 so I guess that is probably what causes the problem - if you can provide a test case I can look at more fixing when I get some free time. If it's a show stopper for you then there are commercial support options available.

Ian


On Wed, 6 Oct 2021 at 14:05, Peter Friess <pk.fri...@t-online.de <mailto: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 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
    <mailto:GeoTools-GT2-Users@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
    <https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users>



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

Reply via email to