Skip to content

Commit

Permalink
Support of dimension in PackedPoints (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoltz committed Feb 1, 2021
1 parent 8117e02 commit 2ca4167
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,11 @@ public Point getStartPoint() {

@Override
public Envelope expandEnvelope( Envelope env ) {
for ( int i = 0; i < coordinates.length; i += 2 ) {
env.expandToInclude( coordinates[i], coordinates[i + 1] );
for ( int i = 0; i < coordinates.length; i += dimension ) {
if ( dimension == 3 )
env.expandToInclude( new Coordinate( coordinates[i], coordinates[i + 1], coordinates[i + 2] ) );
else
env.expandToInclude( coordinates[i], coordinates[i + 1] );
}
return env;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.deegree.geometry.standard.points;

import static org.junit.Assert.assertThat;

import org.deegree.cs.coordinatesystems.ICRS;
import org.deegree.cs.persistence.CRSManager;
import org.hamcrest.CoreMatchers;
import org.junit.Test;

import com.vividsolutions.jts.geom.Envelope;

/**
* @author <a href="mailto:[email protected]">Lyn Goltz </a>
*/
public class PackedPointsTest {

@Test
public void testExpandEnvelope_Dimension2() {
ICRS crs = CRSManager.getCRSRef( "EPSG:4326" );
double[] coordinates = new double[] { 3, 3, 4, 4, 5, 5 };

PackedPoints points = new PackedPoints( crs, coordinates, 2 );
Envelope envelope = new Envelope( 0, 10, 0, 10 );
Envelope expandedEnvelope = points.expandEnvelope( envelope );

assertThat( expandedEnvelope, CoreMatchers.<Envelope> is( envelope ) );
}

@Test
public void testExpandEnvelope_Dimension3() {
ICRS crs = CRSManager.getCRSRef( "EPSG:4326" );
double[] coordinates = new double[] { 3, 3, 0, 4, 4, 0, 5, 5, 0 };

PackedPoints points = new PackedPoints( crs, coordinates, 3 );
Envelope envelope = new Envelope( 0, 10, 0, 10 );
Envelope expandedEnvelope = points.expandEnvelope( envelope );

assertThat( expandedEnvelope, CoreMatchers.<Envelope> is( envelope ) );
}

}

0 comments on commit 2ca4167

Please sign in to comment.