Skip to content

Commit

Permalink
Merge pull request #1360 from lat-lon/fixJTSPointsIterator-XPLANBOX-1093
Browse files Browse the repository at this point in the history
Ensure creation of new default points to avoid unexpected JTS Geometries
  • Loading branch information
stephanr authored Jul 27, 2022
2 parents b0a9344 + f7ae729 commit 83f883b
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,10 @@ public Point get( int i ) {
@Override
public Iterator<Point> iterator() {

return new Iterator<Point>() {
return new Iterator<>() {

private int idx = 0;

private double[] pointCoordinates = new double[getDimension()];

@SuppressWarnings("synthetic-access")
private DefaultPoint point = new DefaultPoint( null, crs, null, pointCoordinates );

@Override
public boolean hasNext() {
Expand All @@ -124,11 +120,12 @@ public Point next() {
if ( !hasNext() ) {
throw new NoSuchElementException();
}
double[] pointCoordinates = new double[getDimension()];
for ( int i = 0; i < getDimension(); i++ ) {
pointCoordinates[i] = getOrdinate( idx, i );
}
idx++;
return point;
return new DefaultPoint( null, crs, null, pointCoordinates );
}

@Override
Expand Down

0 comments on commit 83f883b

Please sign in to comment.