Search in sources :

Example 76 with Geometry

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

the class GeometryImplTest method testEqualsExactForPolygons.

public void testEqualsExactForPolygons() throws Exception {
    final Polygon x = (Polygon) this.geometryFactory.geometry("POLYGON ((0 0, 0 50, 50 50, 50 0, 0 0))");
    final Polygon somethingExactlyEqual = (Polygon) this.geometryFactory.geometry("POLYGON ((0 0, 0 50, 50 50, 50 0, 0 0))");
    final Polygon somethingNotEqualButSameClass = (Polygon) this.geometryFactory.geometry("POLYGON ((50 50, 50 0, 0 0, 0 50, 50 50))");
    final Polygon sameClassButEmpty = (Polygon) this.geometryFactory.geometry("POLYGON EMPTY");
    final Polygon anotherSameClassButEmpty = (Polygon) this.geometryFactory.geometry("POLYGON EMPTY");
    final CollectionFactory collectionFactory = new CollectionFactory() {

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

Example 77 with Geometry

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

the class GeometryImplTest method testEqualsExactForLineStrings.

public void testEqualsExactForLineStrings() throws Exception {
    final LineString x = this.geometryFactory.lineString(2, 0.0, 0, 100.0, 0, 100.0, 100);
    final LineString somethingExactlyEqual = this.geometryFactory.lineString(2, 0.0, 0, 100.0, 0, 100.0, 100);
    final LineString somethingNotEqualButSameClass = this.geometryFactory.lineString(2, 0.0, 0, 100.0, 0, 100.0, 555);
    final LineString sameClassButEmpty = this.geometryFactory.lineString();
    final LineString anotherSameClassButEmpty = this.geometryFactory.lineString();
    final CollectionFactory collectionFactory = new CollectionFactory() {

        @Override
        public Geometry newCollection(final Geometry... geometries) {
            return GeometryImplTest.this.geometryFactory.lineal(geometries);
        }
    };
    doTestEqualsExact(x, somethingExactlyEqual, somethingNotEqualButSameClass, sameClassButEmpty, anotherSameClassButEmpty, collectionFactory);
    final CollectionFactory collectionFactory2 = new CollectionFactory() {

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

Example 78 with Geometry

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

the class RectanglePredicateSyntheticTest method newTestGeometries.

public List<Geometry> newTestGeometries(final BoundingBox env, final double inc, final double size) {
    final List<Geometry> testGeoms = new ArrayList<>();
    for (double y = env.getMinY(); y <= env.getMaxY(); y += inc) {
        for (double x = env.getMinX(); x <= env.getMaxX(); x += inc) {
            final Point base = new PointDoubleXY(x, y);
            testGeoms.add(newAngle(base, size, 0));
            testGeoms.add(newAngle(base, size, 1));
            testGeoms.add(newAngle(base, size, 2));
            testGeoms.add(newAngle(base, size, 3));
        }
    }
    return testGeoms;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 79 with Geometry

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

the class TriangleTest method checkLongestSideLength.

public void checkLongestSideLength(final String wkt, final double expectedValue) throws Exception {
    final Geometry g = this.geometryFactory.geometry(wkt);
    final TriangleImpl t = newTriangle(g);
    double length = Triangles.longestSideLength(t.p0, t.p1, t.p2);
    // System.out.println("(Static) longestSideLength = " + length);
    assertEquals(expectedValue, length, 0.00000001);
    // Test Instance version
    // 
    length = t.longestSideLength();
    // System.out.println("(Instance) longestSideLength = " + length);
    assertEquals(expectedValue, length, 0.00000001);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) TriangleImpl(com.revolsys.geometry.model.util.TriangleImpl)

Example 80 with Geometry

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

the class TriangleTest method checkCircumCentre.

public void checkCircumCentre(final String wkt, final Point expectedValue) throws Exception {
    final Geometry g = this.geometryFactory.geometry(wkt);
    final TriangleImpl t = newTriangle(g);
    Point circumcentre = Triangles.circumcentre(t.p0, t.p1, t.p2);
    // System.out.println("(Static) circumcentre = " + circumcentre);
    assertEquals(expectedValue.toString(), circumcentre.toString());
    // Test Instance version
    // 
    circumcentre = t.circumcentre();
    // System.out.println("(Instance) circumcentre = " +
    // circumcentre.toString());
    assertEquals(expectedValue.toString(), circumcentre.toString());
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) TriangleImpl(com.revolsys.geometry.model.util.TriangleImpl) Point(com.revolsys.geometry.model.Point)

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