Search in sources :

Example 31 with Geometry

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

the class PreparedGeometryTeeOperation method checkAllPrepOps.

private void checkAllPrepOps(final Geometry g1, final Geometry g2) {
    final Geometry prepGeom = g1.prepare();
    checkIntersects(g1, prepGeom, g2);
    checkContains(g1, prepGeom, g2);
    checkContainsProperly(g1, prepGeom, g2);
    checkCovers(g1, prepGeom, g2);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry)

Example 32 with Geometry

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

the class GeometryTestUtil method multiLineString.

public static Lineal multiLineString(final GeometryFactory geometryFactory, final int geometryCount, final int vertexCount, final double delta) {
    final List<Geometry> geometries = new ArrayList<>();
    for (int i = 0; i < geometryCount; i++) {
        final Geometry geometry = lineString(geometryFactory, vertexCount + i, delta * (vertexCount + i * 3));
        geometries.add(geometry);
    }
    return geometryFactory.lineal(geometries);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point)

Example 33 with Geometry

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

the class GeometryTestUtil method multiPoint.

public static Punctual multiPoint(final GeometryFactory geometryFactory, final int geometryCount, final double delta) {
    final List<Geometry> geometries = new ArrayList<>();
    for (int i = 0; i < geometryCount; i++) {
        final Geometry geometry = point(geometryFactory, delta * i);
        geometries.add(geometry);
    }
    final Punctual multiPoint = geometryFactory.punctual(geometries);
    return multiPoint;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Punctual(com.revolsys.geometry.model.Punctual) ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point)

Example 34 with Geometry

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

the class BufferTest method performanceTest.

public static void performanceTest() throws Throwable {
    // JTS takes 3.4 seconds
    final PathResource resource = new PathResource("/Users/paustin/Development/ALL/com.revolsys.open/com.revolsys.open.core/src/test/resources/com/revolsys/jts/test/data/world.wkt");
    List<Geometry> geometries = new ArrayList<>();
    try (Reader<Geometry> reader = GeometryReader.newGeometryReader(resource)) {
        geometries = reader.toList();
    }
    for (final Geometry geometry : geometries) {
        geometry.buffer(5);
    }
    final long time = System.currentTimeMillis();
    for (final Geometry geometry : geometries) {
        geometry.buffer(5);
    }
    System.out.println(System.currentTimeMillis() - time);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) ClassPathResource(com.revolsys.spring.resource.ClassPathResource) PathResource(com.revolsys.spring.resource.PathResource) ArrayList(java.util.ArrayList)

Example 35 with Geometry

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

the class AffineTransformationTest method checkTransformation.

void checkTransformation(final String geomStr) throws IOException, ParseException, NoninvertibleTransformationException {
    final Geometry geom = geometryFactory.geometry(geomStr);
    final AffineTransformation trans = AffineTransformation.rotationInstance(Math.PI / 2);
    final AffineTransformation inv = trans.getInverse();
    final Geometry transGeom = trans.transform(geom);
    final Geometry invGeom = inv.transform(transGeom);
    // check if transformed geometry is equal to original
    final boolean isEqual = geom.equalsExact(invGeom, 0.0005);
    assertTrue(isEqual);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) AffineTransformation(com.revolsys.geometry.model.util.AffineTransformation)

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