/** * Creates a LineString using a LiteCoordinateSequence with 2 3D coordinates. * * @return a 3D LineString */ public static LineString lineStringLite3D() { return liteGF.createLineString(liteCSF.create(new double[] {1, 2, 100, 3, 4, 200}, 3)); }
/** * Creates a Polygon using a LiteCoordinateSequence with 2D coordinates. * * @return a 2D Polygon */ public static Polygon polygonLite2D() { return liteGF.createPolygon( liteGF.createLinearRing( liteCSF.create(new double[] {1, 1, 2, 1, 2, 2, 1, 2, 1, 1}, 2)), null); }
/** * Creates a Polygon using a LiteCoordinateSequence with 3D coordinates. * * @return a 3D Polygon */ public static Polygon polygonLite3D() { return liteGF.createPolygon( liteGF.createLinearRing( liteCSF.create( new double[] {1, 1, 100, 2, 1, 99, 2, 2, 98, 1, 2, 97, 1, 1, 100}, 3)), null); }
public void testCreateSchemaAndInsertPolyRectangleWithHole() throws Exception { LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); GeometryFactory gf = new GeometryFactory(csf); LinearRing shell = gf.createLinearRing( csf.create( new double[] {0, 0, 99, 10, 0, 33, 10, 10, 66, 0, 10, 66, 0, 0, 99}, 3)); LinearRing hole = gf.createLinearRing( csf.create( new double[] {2, 2, 99, 3, 2, 44, 3, 3, 99, 2, 3, 99, 2, 2, 99}, 3)); Polygon poly = gf.createPolygon(shell, new LinearRing[] {hole}); checkCreateSchemaAndInsert(poly); }
public void testCreateSchemaAndInsertPolyWithHoleCW() throws Exception { LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); GeometryFactory gf = new GeometryFactory(csf); LinearRing shell = gf.createLinearRing( csf.create( new double[] {1, 1, 99, 10, 1, 33, 10, 10, 66, 1, 10, 66, 1, 1, 99}, 3)); LinearRing hole = gf.createLinearRing( csf.create( new double[] {2, 2, 99, 8, 2, 44, 8, 8, 99, 2, 8, 99, 2, 2, 99}, 3)); Polygon poly = gf.createPolygon(shell, new LinearRing[] {hole}); checkCreateSchemaAndInsert(poly); }
@Test public void testCoordinateDimensionLineStringLite3D() { Geometry geom = liteGF.createLineString(liteCSF.create(new double[] {1, 2, 100, 3, 4, 200}, 3)); assertEquals(3, CoordinateSequences.coordinateDimension(geom)); }
public void testCreateSchemaAndInsertPolyTriangle() throws Exception { LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); GeometryFactory gf = new GeometryFactory(csf); LinearRing shell = gf.createLinearRing( csf.create(new double[] {0, 0, 99, 1, 0, 33, 1, 1, 66, 0, 0, 99}, 3)); Polygon poly = gf.createPolygon(shell, null); checkCreateSchemaAndInsert(poly); }
@Test public void testCoordinateDimensionPolygonEmptyLite3D() { Geometry geom = liteGF.createPolygon( liteGF.createLinearRing(liteCSF.create(new double[0], 3)), null); assertEquals(3, CoordinateSequences.coordinateDimension(geom)); }
public void testCreateSchemaAndInsertPolyRectangle() throws Exception { LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); GeometryFactory gf = new GeometryFactory(csf); LinearRing shell = gf.createLinearRing( csf.create( new double[] {0, 0, 99, 1, 0, 33, 1, 1, 66, 0, 1, 33, 0, 0, 99}, 3)); Polygon poly = gf.createPolygon(shell, null); checkCreateSchemaAndInsert(poly); }
@Test public void testDistance() throws Exception { LineString ls = gf.createLineString(csf.create(new double[] {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5})); Decimator d = new Decimator(identity, new Rectangle(0, 0, 5, 5), 0.8); d.decimateTransformGeneralize((Geometry) ls.copy(), identity); assertEquals(6, ls.getNumPoints()); d = new Decimator(identity, new Rectangle(0, 0, 5, 5), 1); d.decimateTransformGeneralize(ls, identity); assertEquals(4, ls.getNumPoints()); d = new Decimator(identity, new Rectangle(0, 0, 5, 5), 6); d.decimateTransformGeneralize(ls, identity); assertEquals(2, ls.getNumPoints()); }
@Test public void testDecimate3DPoint() throws Exception { Point p = gf.createPoint(csf.create(new double[] {0, 1, 2}, 3)); Decimator d = new Decimator(identity, new Rectangle(0, 0, 5, 5), 0.8); d.decimateTransformGeneralize(p, identity); assertEquals(1, p.getNumPoints()); assertEquals(2, p.getCoordinateSequence().getDimension()); }
@Test public void testCoordinateDimensionPolygonLite2D() { Geometry geom = liteGF.createPolygon( liteGF.createLinearRing( liteCSF.create(new double[] {1, 1, 2, 1, 2, 2, 1, 2, 1, 1}, 2)), null); assertEquals(2, CoordinateSequences.coordinateDimension(geom)); }
@Test public void testCoordinateDimensionPolygonEmptyLite2D() { Geometry geom = liteGF.createPolygon( liteGF.createLinearRing(liteCSF.create(new double[0], 2)), null); assertEquals(2, CoordinateSequences.coordinateDimension(geom)); }
@Test public void testCoordinateDimensionPolygonLite3D() { Geometry geom = liteGF.createPolygon( liteGF.createLinearRing( liteCSF.create( new double[] { 1, 1, 100, 2, 1, 99, 2, 2, 98, 1, 2, 97, 1, 1, 100 }, 3)), null); assertEquals(3, CoordinateSequences.coordinateDimension(geom)); }
@Test public void testDecimate3DLine() throws Exception { LineString ls = gf.createLineString( csf.create(new double[] {0, 0, 1, 1, 2, 1, 3, 3, 4, 4, 5, 5}, 3)); assertEquals(4, ls.getNumPoints()); Decimator d = new Decimator(identity, new Rectangle(0, 0, 5, 5), 0.8); d.decimateTransformGeneralize(ls, identity); assertEquals(4, ls.getNumPoints()); assertEquals(2, ls.getCoordinateSequence().getDimension()); }
@Test public void testDecimateOpenTriangle() throws Exception { LineString g = gf.createLineString(csf.create(new double[] {0, 0, 0, 2, 2, 2, 0, 0})); assertTrue(g.isValid()); Decimator d = new Decimator(3, 3); d.decimateTransformGeneralize(g, new AffineTransform2D(new AffineTransform())); g.geometryChanged(); assertTrue(g.isValid()); assertEquals(4, g.getCoordinateSequence().size()); }
/** http://jira.codehaus.org/browse/GEOT-2937 */ @Test public void testDecimatePseudoRing() { // a long rectangle made of 3 coordinates LineString g = gf.createLineString(csf.create(new double[] {0, 0, 0, 10, 0, 0})); assertTrue(g.isValid()); Decimator d = new Decimator(4, 4); d.decimate(g); g.geometryChanged(); assertTrue(g.isValid()); assertEquals(3, g.getCoordinateSequence().size()); }
/** http://jira.codehaus.org/browse/GEOT-1923 */ @Test public void testDecimateRing() { // a long rectangle made of 5 coordinates LinearRing g = gf.createLinearRing(csf.create(new double[] {0, 0, 0, 10, 2, 10, 2, 0, 0, 0})); assertTrue(g.isValid()); Decimator d = new Decimator(4, 4); d.decimate(g); g.geometryChanged(); assertTrue(g.isValid()); assertEquals(4, g.getCoordinateSequence().size()); }
@Test public void testNoDecimation() { // acute triangle LinearRing g = gf.createLinearRing(csf.create(new double[] {0, 0, 0, 10, 2, 10, 2, 0, 0, 0})); LinearRing original = (LinearRing) g.copy(); assertTrue(g.isValid()); Decimator d = new Decimator(-1, -1); d.decimate(g); g.geometryChanged(); assertTrue(g.isValid()); assertTrue(original.equalsExact(g)); }
/** http://jira.codehaus.org/browse/GEOT-1923 */ @Test public void testDecimateRingEnvelope() { // acute triangle LinearRing g = gf.createLinearRing(csf.create(new double[] {0, 0, 0, 10, 2, 10, 2, 0, 0, 0})); assertTrue(g.isValid()); Decimator d = new Decimator(20, 20); d.decimate(g); g.geometryChanged(); assertTrue(g.isValid()); assertEquals(4, g.getCoordinateSequence().size()); }