Search in sources :

Example 61 with Polygon

use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.

the class PolygonEditorTest method testNotModified.

@Test
public void testNotModified() {
    final Polygon polygon = POLYGON;
    final PolygonEditor polygonEditor = polygon.newGeometryEditor();
    try {
        polygonEditor.setZ(new int[0], 13);
        Assert.fail("Invalid index should cause exception");
    } catch (final Exception e) {
    }
}
Also used : PolygonEditor(com.revolsys.geometry.model.editor.PolygonEditor) Polygon(com.revolsys.geometry.model.Polygon) Test(org.junit.Test)

Example 62 with Polygon

use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.

the class MiscellaneousTest method testPolygonGetCoordinates.

// public void testGeometryCollectionIsSimple1() throws Exception {
// Geometry g = reader.read("GEOMETRYCOLLECTION("
// + "LINESTRING(0 0, 100 0),"
// + "LINESTRING(0 10, 100 10))");
// assertTrue(g.isSimple());
// }
// public void testGeometryCollectionIsSimple2() throws Exception {
// Geometry g = reader.read("GEOMETRYCOLLECTION("
// + "LINESTRING(0 0, 100 0),"
// + "LINESTRING(50 0, 100 10))");
// assertTrue(! g.isSimple());
// }
/**
 * @todo Enable when #isSimple implemented
 */
// public void testMultiLineStringIsSimple1() throws Exception {
// Geometry g = reader.read("MULTILINESTRING("
// + "(0 0, 100 0),"
// + "(0 10, 100 10))");
// assertTrue(g.isSimple());
// }
public void testPolygonGetCoordinates() throws Exception {
    final Polygon p = (Polygon) this.geometryFactory.geometry("POLYGON ( (0 0, 100 0, 100 100, 0 100, 0 0), " + "          (20 20, 20 80, 80 80, 80 20, 20 20)) ");
    assertEquals(10, p.getVertexCount());
}
Also used : Polygon(com.revolsys.geometry.model.Polygon)

Example 63 with Polygon

use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.

the class MiscellaneousTest method testEmptyPolygon.

public void testEmptyPolygon() throws Exception {
    final Polygon p = this.geometryFactory.polygon();
    assertEquals(2, p.getDimension());
    assertEquals(BoundingBox.empty(), p.getBoundingBox());
    assertTrue(p.isSimple());
}
Also used : Polygon(com.revolsys.geometry.model.Polygon)

Example 64 with Polygon

use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.

the class ValidClosedRingTest method testGoodPolygon.

public void testGoodPolygon() {
    final Polygon poly = (Polygon) fromWKT("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))");
    checkIsValid(poly, true);
}
Also used : Polygon(com.revolsys.geometry.model.Polygon)

Example 65 with Polygon

use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.

the class GeometryFactoryTest method testCreateGeometry.

private static void testCreateGeometry() {
    final LineString pointPoints = new LineStringDouble(2, 0.0, 0);
    final LineString point2Points = new LineStringDouble(2, 20.0, 20);
    final LineString ringPoints = new LineStringDouble(2, 0.0, 0, 0, 100, 100, 100, 100, 0, 0, 0);
    final LineString ring2Points = new LineStringDouble(2, 20.0, 20, 20, 80, 80, 80, 80, 20, 20, 20);
    final LineString ring3Points = new LineStringDouble(2, 120.0, 120, 120, 180, 180, 180, 180, 120, 120, 120);
    final Point point = GEOMETRY_FACTORY.point(2, 0.0, 0);
    assertCopyGeometry(point, pointPoints);
    final LineString line = GEOMETRY_FACTORY.lineString(ringPoints);
    assertCopyGeometry(line, ringPoints);
    final LinearRing linearRing = GEOMETRY_FACTORY.linearRing(ringPoints);
    assertCopyGeometry(linearRing, ringPoints);
    final Polygon polygon = GEOMETRY_FACTORY.polygon(ringPoints);
    assertCopyGeometry(polygon, ringPoints);
    final Polygon polygon2 = GEOMETRY_FACTORY.polygon(ringPoints, ring2Points);
    assertCopyGeometry(polygon2, ringPoints, ring2Points);
    final Punctual multiPoint = GEOMETRY_FACTORY.punctual(pointPoints);
    assertCopyGeometry(multiPoint, pointPoints);
    final Punctual multiPoint2 = GEOMETRY_FACTORY.punctual(pointPoints, point2Points);
    assertCopyGeometry(multiPoint2, pointPoints, point2Points);
    final Lineal multiLineString = GEOMETRY_FACTORY.lineal(ringPoints);
    assertCopyGeometry(multiLineString, ringPoints);
    final Lineal multiLineString2 = GEOMETRY_FACTORY.lineal(ringPoints, ring2Points);
    assertCopyGeometry(multiLineString2, ringPoints, ring2Points);
    final Polygonal multiPolygon = GEOMETRY_FACTORY.polygonal(ringPoints);
    assertCopyGeometry(multiPolygon, ringPoints);
    final Polygonal multiPolygon2 = GEOMETRY_FACTORY.polygonal(ringPoints, ring3Points);
    assertCopyGeometry(multiPolygon2, ringPoints, ring3Points);
}
Also used : Punctual(com.revolsys.geometry.model.Punctual) Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString) Polygonal(com.revolsys.geometry.model.Polygonal) Point(com.revolsys.geometry.model.Point) LinearRing(com.revolsys.geometry.model.LinearRing) Polygon(com.revolsys.geometry.model.Polygon) LineStringDouble(com.revolsys.geometry.model.impl.LineStringDouble)

Aggregations

Polygon (com.revolsys.geometry.model.Polygon)147 Point (com.revolsys.geometry.model.Point)66 LinearRing (com.revolsys.geometry.model.LinearRing)54 LineString (com.revolsys.geometry.model.LineString)39 Geometry (com.revolsys.geometry.model.Geometry)34 ArrayList (java.util.ArrayList)30 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)22 Polygonal (com.revolsys.geometry.model.Polygonal)17 BoundingBox (com.revolsys.geometry.model.BoundingBox)14 Punctual (com.revolsys.geometry.model.Punctual)12 Test (org.junit.Test)12 Lineal (com.revolsys.geometry.model.Lineal)11 BaseCloseable (com.revolsys.io.BaseCloseable)7 List (java.util.List)7 PolygonEditor (com.revolsys.geometry.model.editor.PolygonEditor)6 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)6 Vertex (com.revolsys.geometry.model.vertex.Vertex)6 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)3 ProjectedCoordinateSystem (com.revolsys.geometry.cs.ProjectedCoordinateSystem)3 Graphics2D (java.awt.Graphics2D)3