Search in sources :

Example 71 with Geometry

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

the class AreaLengthTest method checkArea.

public void checkArea(final String wkt, final double expectedValue) throws Exception {
    final Geometry g = this.geometryFactory.geometry(wkt);
    assertEquals(expectedValue, g.getArea(), TOLERANCE);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry)

Example 72 with Geometry

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

the class GeometryCollectionImplTest method testGetDimension.

public void testGetDimension() throws Exception {
    final Geometry g = this.geometryFactory.geometry("GEOMETRYCOLLECTION (POINT (10 10), POINT (30 30), LINESTRING (15 15, 20 20))");
    assertEquals(1, g.getDimension());
}
Also used : Geometry(com.revolsys.geometry.model.Geometry)

Example 73 with Geometry

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

the class GeometryImplTest method doTestEqualsExact.

private void doTestEqualsExact(final Geometry x, final Geometry somethingExactlyEqual, final Geometry somethingEqualButNotExactly, final Geometry somethingNotEqualButSameClass) throws Exception {
    Geometry differentClass;
    if (x instanceof Point) {
        differentClass = this.geometryFactory.geometry("POLYGON((0 0,0 50,50 43949,50 0,0 0))");
    } else {
        differentClass = this.geometryFactory.geometry("POINT(2351 1563)");
    }
    assertTrue(x.equals(2, x));
    assertTrue(x.equals(2, somethingExactlyEqual));
    assertTrue(somethingExactlyEqual.equals(2, x));
    // assertTrue(!x.equalsExact(somethingEqualButNotExactly));
    // assertTrue(!somethingEqualButNotExactly.equalsExact(x));
    // assertTrue(!x.equalsExact(somethingEqualButNotExactly));
    // assertTrue(!somethingEqualButNotExactly.equalsExact(x));
    assertTrue(!x.equals(2, differentClass));
    assertTrue(!differentClass.equals(2, x));
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Point(com.revolsys.geometry.model.Point)

Example 74 with Geometry

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

the class GeometryImplTest method testEqualsExactForGeometryCollections.

public void testEqualsExactForGeometryCollections() throws Exception {
    final Geometry polygon1 = this.geometryFactory.geometry("POLYGON ((0 0, 0 50, 50 50, 50 0, 0 0))");
    final Geometry polygon2 = this.geometryFactory.geometry("POLYGON ((50 50, 50 0, 0 0, 0 50, 50 50))");
    final Geometry x = this.geometryFactory.geometry(polygon1, polygon2);
    final Geometry somethingExactlyEqual = this.geometryFactory.geometry(polygon1, polygon2);
    final Geometry somethingNotEqualButSameClass = this.geometryFactory.geometry(polygon2);
    final Geometry sameClassButEmpty = this.geometryFactory.geometryCollection();
    final Geometry anotherSameClassButEmpty = this.geometryFactory.geometryCollection();
    final CollectionFactory collectionFactory = new CollectionFactory() {

        @Override
        public Geometry newCollection(final Geometry... geometries) {
            return GeometryImplTest.this.geometryFactory.geometry(geometries);
        }
    };
    doTestEqualsExact(x, somethingExactlyEqual, somethingNotEqualButSameClass, sameClassButEmpty, anotherSameClassButEmpty, collectionFactory);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry)

Example 75 with Geometry

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

the class GeometryImplTest method testEquals.

public void testEquals() throws Exception {
    final Geometry g = this.geometryFactory.geometry("POLYGON ((0 0, 0 50, 50 50, 50 0, 0 0))");
    final Geometry same = this.geometryFactory.geometry("POLYGON ((0 0, 0 50, 50 50, 50 0, 0 0))");
    final Geometry differentStart = this.geometryFactory.geometry("POLYGON ((0 50, 50 50, 50 0, 0 0, 0 50))");
    final Geometry differentFourth = this.geometryFactory.geometry("POLYGON ((0 0, 0 50, 50 50, 50 -99, 0 0))");
    final Geometry differentSecond = this.geometryFactory.geometry("POLYGON ((0 0, 0 99, 50 50, 50 0, 0 0))");
    doTestEquals(g, same, true, true, true, true);
    doTestEquals(g, differentStart, true, false, false, true);
    doTestEquals(g, differentFourth, false, false, false, false);
    doTestEquals(g, differentSecond, false, false, false, false);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry)

Aggregations

Geometry (com.revolsys.geometry.model.Geometry)488 Point (com.revolsys.geometry.model.Point)140 LineString (com.revolsys.geometry.model.LineString)87 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)75 ArrayList (java.util.ArrayList)70 BoundingBox (com.revolsys.geometry.model.BoundingBox)39 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)39 Polygon (com.revolsys.geometry.model.Polygon)34 List (java.util.List)33 Record (com.revolsys.record.Record)32 Iterator (java.util.Iterator)20 RecordDefinition (com.revolsys.record.schema.RecordDefinition)18 LinearRing (com.revolsys.geometry.model.LinearRing)16 Vertex (com.revolsys.geometry.model.vertex.Vertex)16 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)14 LineSegment (com.revolsys.geometry.model.segment.LineSegment)13 GeometricShapeFactory (com.revolsys.geometry.util.GeometricShapeFactory)13 FieldDefinition (com.revolsys.record.schema.FieldDefinition)12 DataType (com.revolsys.datatype.DataType)10 IOException (java.io.IOException)10