Search in sources :

Example 86 with Geometry

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

the class LineSequencerTest method runLineSequencer.

private void runLineSequencer(final String[] inputWKT, final String expectedWKT) throws ParseException {
    final List inputGeoms = fromWKT(inputWKT);
    final LineSequencer sequencer = new LineSequencer();
    sequencer.add(inputGeoms);
    final boolean isCorrect = false;
    if (!sequencer.isSequenceable()) {
        assertTrue(expectedWKT == null);
    } else {
        final Geometry expected = geometryFactory.geometry(expectedWKT);
        final Geometry result = sequencer.getSequencedLineStrings();
        final boolean isOK = expected.equalsNorm(result);
        if (!isOK) {
        // System.out.println("ERROR - Expected: " + expected);
        // System.out.println(" Actual: " + result);
        }
        assertTrue(isOK);
        final boolean isSequenced = LineSequencer.isSequenced(result);
        assertTrue(isSequenced);
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) List(java.util.List) ArrayList(java.util.ArrayList) LineSequencer(com.revolsys.geometry.operation.linemerge.LineSequencer)

Example 87 with Geometry

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

the class LineSequencerTest method runIsSequenced.

private void runIsSequenced(final String inputWKT, final boolean expected) throws ParseException {
    final Geometry g = geometryFactory.geometry(inputWKT);
    final boolean isSequenced = LineSequencer.isSequenced(g);
    assertTrue(isSequenced == expected);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry)

Example 88 with Geometry

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

the class RelateBoundaryNodeRuleTest method runRelateTest.

void runRelateTest(final String wkt1, final String wkt2, final BoundaryNodeRule bnRule, final String expectedIM) throws ParseException {
    final Geometry g1 = this.geometryFactory.geometry(wkt1);
    final Geometry g2 = this.geometryFactory.geometry(wkt2);
    final IntersectionMatrix im = RelateOp.relate(g1, g2, bnRule);
    final String imStr = im.toString();
    // System.out.println(imStr);
    assertTrue(im.matches(expectedIM));
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) IntersectionMatrix(com.revolsys.geometry.model.IntersectionMatrix)

Example 89 with Geometry

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

the class UnaryUnionTest method doTest.

private void doTest(final String expectedWKT, final String... inputWKT) throws ParseException {
    Geometry result;
    final Collection<Geometry> geoms = GeometryUtils.readWKT(inputWKT);
    if (geoms.size() == 0) {
        final GeometryFactory geometryFactory = GeometryFactory.DEFAULT_3D;
        result = UnaryUnionOp.union(geoms, geometryFactory);
    } else {
        result = UnaryUnionOp.union(geoms);
    }
    Assert.assertEquals(GeometryUtils.readWKT(expectedWKT), result);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory)

Example 90 with Geometry

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

the class ValidSelfTouchingRingFormingHoleTest method checkIsValidSTR.

private void checkIsValidSTR(final String wkt, final boolean expected) {
    final Geometry geom = fromWKT(wkt);
    final IsValidOp validator = new IsValidOp(geom);
    validator.setSelfTouchingRingFormingHoleValid(true);
    final boolean isValid = validator.isValid();
    assertTrue(isValid == expected);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) IsValidOp(com.revolsys.geometry.operation.valid.IsValidOp)

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