Re: [Geotools-gt2-users] Geotools version 25.2 LiteCoordinateSequence

2021-10-11 Thread Jody Garnett
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  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


Re: [Geotools-gt2-users] Geotools version 25.2 LiteCoordinateSequence

2021-10-07 Thread Ian Turton
if you had clicked the goto home link it would work -
https://osgeo-org.atlassian.net/jira/software/c/projects/GEOT/issues/

Ian

On Thu, 7 Oct 2021 at 08:56, Peter Friess  wrote:

> Well, ...
>
> I have created a test example. Very simple, just used your Quickstart and
> added two statements. I would have uploaded it and created an issue, but
> the link  (https://osgeo-org.atlassian.net/jira/software/c/projects/GEOT)
> you provided is broken.  As I can't upload the example I attached it here.
>
> Peter
> Am 07.10.2021 um 09:40 schrieb Ian Turton:
>
>
>
> On Wed, 6 Oct 2021 at 18:02, Peter Friess  wrote:
>
>> Our application is huge. It is not straightforward to create a test
>> example.  Let me respond to what you stated
>>
>> > This is the problem!!! You should be passing in *3* then the check
>> would pass!
>> How should I pass in 3?. All is done inside StreamingRenderer. It starts
>> with
>> StreamingRenderer.paint
>> StreamingRenderer.processStylers
>> StreamingRenderer.drawPlain
>> StreamingRenderer.processFeature
>> StreamingRenderer.processSymbolizers
>> StreamingRenderer$RenderableFeature.getShape
>> StreamingRenderer$RenderableFeature.getTransformedShape
>> and then it calls
>> LiteCoordinateSequence.cloneGeometry
>> which then does inside this check and throws an exception.
>>
>> Means, I do not pass anything. Inside this sequence it uses the
>> CoordinateReferenceSystem which it gets from SymbolizerAssociation. This
>> CoordinateReferenceSystem returns as dimension 2 which then is used in that
>> check. So, I do not pass a 2. It is all done inside StreamingRenderer. The
>> CoordinateReferenceSystemis is created by CRS.decode(code), again not my
>> code. As it is a UTM projection the dimension is 2.
>>
>> =>  when I create a 2-dimensional point -  new Coordinate(x,y) - all
>> works fine.
>>
>> =>  when I create a 3-dimensional point -  new Coordinate(x,y,z) - and
>> I  do *NOT *load the features into memory;all works fine.
>>
>> =>  when I create a 3-dimensional point -  new Coordinate(x,y,z) - and
>> I  do load the points into memory -  DataUtilities.source(
>> DataUtilities.collection(source.getFeatures())) - then the exception is
>> throw as StreaminReader clones the geometry inside  getTransformedShape.
>>
>> There is a problem when the geometry gets cloned and when the Point is 3D
>> but the CoordinateReferenceSystem is 2D. This did perfectly work in version
>> 21.2. And it does *not *work in 25.2
>>
>> Shouldn't that be enough information  to understand the problem.
>>
>
> It very well might be but certainly I (and I suspect the other developers)
> will not expend the effort in our limited spare time to look into this
> issue if there is no issue raised and if we have to try to figure out a
> test to demonstrate the issue. You might want to watch a couple of useful
> videos that explain how this works - The secret life of open source
> developers (
> https://media.ccc.de/v/bucharest-322-the-secret-life-of-open-source-developers)
> and Earning your support instead of buying it (https://vimeo.com/144089061)
>
>
> Ian
>
>

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


Re: [Geotools-gt2-users] Geotools version 25.2 LiteCoordinateSequence

2021-10-07 Thread Ian Turton
On Wed, 6 Oct 2021 at 18:02, Peter Friess  wrote:

> Our application is huge. It is not straightforward to create a test
> example.  Let me respond to what you stated
>
> > This is the problem!!! You should be passing in *3* then the check
> would pass!
> How should I pass in 3?. All is done inside StreamingRenderer. It starts
> with
> StreamingRenderer.paint
> StreamingRenderer.processStylers
> StreamingRenderer.drawPlain
> StreamingRenderer.processFeature
> StreamingRenderer.processSymbolizers
> StreamingRenderer$RenderableFeature.getShape
> StreamingRenderer$RenderableFeature.getTransformedShape
> and then it calls
> LiteCoordinateSequence.cloneGeometry
> which then does inside this check and throws an exception.
>
> Means, I do not pass anything. Inside this sequence it uses the
> CoordinateReferenceSystem which it gets from SymbolizerAssociation. This
> CoordinateReferenceSystem returns as dimension 2 which then is used in that
> check. So, I do not pass a 2. It is all done inside StreamingRenderer. The
> CoordinateReferenceSystemis is created by CRS.decode(code), again not my
> code. As it is a UTM projection the dimension is 2.
>
> =>  when I create a 2-dimensional point -  new Coordinate(x,y) - all works
> fine.
>
> =>  when I create a 3-dimensional point -  new Coordinate(x,y,z) - and I
> do *NOT *load the features into memory;all works fine.
>
> =>  when I create a 3-dimensional point -  new Coordinate(x,y,z) - and I
> do load the points into memory -  DataUtilities.source(
> DataUtilities.collection(source.getFeatures())) - then the exception is
> throw as StreaminReader clones the geometry inside  getTransformedShape.
>
> There is a problem when the geometry gets cloned and when the Point is 3D
> but the CoordinateReferenceSystem is 2D. This did perfectly work in version
> 21.2. And it does *not *work in 25.2
>
> Shouldn't that be enough information  to understand the problem.
>

It very well might be but certainly I (and I suspect the other developers)
will not expend the effort in our limited spare time to look into this
issue if there is no issue raised and if we have to try to figure out a
test to demonstrate the issue. You might want to watch a couple of useful
videos that explain how this works - The secret life of open source
developers (
https://media.ccc.de/v/bucharest-322-the-secret-life-of-open-source-developers)
and Earning your support instead of buying it (https://vimeo.com/144089061)

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


Re: [Geotools-gt2-users] Geotools version 25.2 LiteCoordinateSequence

2021-10-06 Thread Ian Turton
On Wed, 6 Oct 2021 at 17:03, Peter Friess  wrote:

> Sorry Ian,
>
> I don't get it. I create a Coordinate and pass 3 values: 
> enh.getX(),enh.getY(),
> enh.getZ(). Why are you telling me I pass 2? I also stated I check in the
> debugger the Coordinate has x, y, and z.
>

> The problem is that the CRS returns 2 as dimension, which is correct

This is the problem!!! You should be passing in *3* then the check would
pass! At no point did I suggest you passed in two.

Please produce a small test case so we can all see what is happening.

Ian

> Peter
>
>
> Am 06.10.2021 um 17:52 schrieb Ian Turton:
>
>
>
> On Wed, 6 Oct 2021 at 16:35, Peter Friess  wrote:
>
>> 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
>>
>
> No that is the problem - your points have a dimension of 3 so you should
> not pass in 2 here.  You could try calling
> `org.geotools.geometry.jts.LiteCoordinateSequence.guessDimension(Coordinate...)`
> which should return 3 for your data.
>
>> , 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 means and 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.
>>
>
> measures are the M of a POINTMZ or POINTM (so yet another dimension to the
> coordinate) - you should get 3-1 = 2 (x,y) and all should be well.
>
> 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.
>>
>
> It looks like it is a geotools problem, so as a first step raise an issue (
> https://osgeo-org.atlassian.net/jira/software/c/projects/GEOT) preferably
> with a test case. Then either wait for a fix to come, or implement a fix or
> incentivise someone to care about it for you.
>
> Ian
>
> --
> Ian Turton
>
>

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


Re: [Geotools-gt2-users] Geotools version 25.2 LiteCoordinateSequence

2021-10-06 Thread Peter Friess

Sorry Ian,

I don't get it. I create a Coordinate and pass 3 values: 
enh.getX(),enh.getY(), enh.getZ(). Why are you telling me I pass 2? I 
also stated I check in the debugger the Coordinate has x, y, and z.


Peter


Am 06.10.2021 um 17:52 schrieb Ian Turton:



On Wed, 6 Oct 2021 at 16:35, Peter Friess > wrote:


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


No that is the problem - your points have a dimension of 3 so you 
should not pass in 2 here.  You could try calling 
`org.geotools.geometry.jts.LiteCoordinateSequence.guessDimension(Coordinate...)` 
which should return 3 for your data.


, 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.


measures are the M of a POINTMZ or POINTM (so yet another dimension to 
the coordinate) - you should get 3-1 = 2 (x,y) and all should be well.


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.


It looks like it is a geotools problem, so as a first step raise an 
issue (https://osgeo-org.atlassian.net/jira/software/c/projects/GEOT 
) 
preferably with a test case. Then either wait for a fix to come, or 
implement a fix or incentivise someone to care about it for you.


Ian

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


Re: [Geotools-gt2-users] Geotools version 25.2 LiteCoordinateSequence

2021-10-06 Thread Peter Friess

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 
 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 > 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

https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users




--
Ian Turton

[Geotools-gt2-users] Geotools version 25.2 LiteCoordinateSequence

2021-10-06 Thread Peter Friess

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