Search in sources :

Example 61 with Geometry

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

the class MiscellaneousTest2 method testZeroAreaPolygon.

public void testZeroAreaPolygon() throws Exception {
    final Geometry g = this.geometryFactory.geometry("POLYGON((0 0, 0 0, 0 0, 0 0, 0 0))");
    g.isValid();
    // No exception thrown [Jon Aquino]
    assertTrue(true);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry)

Example 62 with Geometry

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

the class AbstractIndexedLineTest method runIndicesOfThenExtract.

protected void runIndicesOfThenExtract(final String inputStr, final String subLineStr) // throws Exception
{
    final Geometry input = read(inputStr);
    final Geometry subLine = read(subLineStr);
    final Geometry result = indicesOfThenExtract(input, subLine);
    checkExpected(result, subLineStr);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry)

Example 63 with Geometry

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

the class AbstractIndexedLineTest method checkExpected.

protected void checkExpected(final Geometry result, final String expected) {
    final Geometry subLine = read(expected);
    final boolean isEqual = result.equalsExact(subLine, 1.0e-5);
    if (!isEqual) {
    // System.out.println("Computed result is: " + result);
    }
    assertTrue(isEqual);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry)

Example 64 with Geometry

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

the class LinearLocationTest method testRepeatedCoordsLineString.

public void testRepeatedCoordsLineString() throws Exception {
    final Geometry line = this.geometryFactory.geometry("LINESTRING (10 0, 10 0, 20 0)");
    final LocationIndexedLine indexedLine = new LocationIndexedLine(line);
    final LinearLocation loc0 = indexedLine.indexOf(new PointDoubleXY(11, 0));
    assertTrue(loc0.compareTo(new LinearLocation(1, 0.1)) == 0);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LocationIndexedLine(com.revolsys.geometry.linearref.LocationIndexedLine) LinearLocation(com.revolsys.geometry.linearref.LinearLocation) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 65 with Geometry

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

the class LinearLocationTest method testSameSegmentLineString.

public void testSameSegmentLineString() throws Exception {
    final Geometry line = this.geometryFactory.geometry("LINESTRING (0 0, 10 0, 20 0, 30 0)");
    final LocationIndexedLine indexedLine = new LocationIndexedLine(line);
    final LinearLocation loc0 = indexedLine.indexOf(new PointDoubleXY(0, 0));
    final LinearLocation loc0_5 = indexedLine.indexOf(new PointDoubleXY(5, 0));
    final LinearLocation loc1 = indexedLine.indexOf(new PointDoubleXY(10, 0));
    final LinearLocation loc2 = indexedLine.indexOf(new PointDoubleXY(20, 0));
    final LinearLocation loc2_5 = indexedLine.indexOf(new PointDoubleXY(25, 0));
    final LinearLocation loc3 = indexedLine.indexOf(new PointDoubleXY(30, 0));
    assertTrue(loc0.isOnSameSegment(loc0));
    assertTrue(loc0.isOnSameSegment(loc0_5));
    assertTrue(loc0.isOnSameSegment(loc1));
    assertTrue(!loc0.isOnSameSegment(loc2));
    assertTrue(!loc0.isOnSameSegment(loc2_5));
    assertTrue(!loc0.isOnSameSegment(loc3));
    assertTrue(loc0_5.isOnSameSegment(loc0));
    assertTrue(loc0_5.isOnSameSegment(loc1));
    assertTrue(!loc0_5.isOnSameSegment(loc2));
    assertTrue(!loc0_5.isOnSameSegment(loc3));
    assertTrue(!loc2.isOnSameSegment(loc0));
    assertTrue(loc2.isOnSameSegment(loc1));
    assertTrue(loc2.isOnSameSegment(loc2));
    assertTrue(loc2.isOnSameSegment(loc3));
    assertTrue(loc2_5.isOnSameSegment(loc3));
    assertTrue(!loc3.isOnSameSegment(loc0));
    assertTrue(loc3.isOnSameSegment(loc2));
    assertTrue(loc3.isOnSameSegment(loc2_5));
    assertTrue(loc3.isOnSameSegment(loc3));
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LocationIndexedLine(com.revolsys.geometry.linearref.LocationIndexedLine) LinearLocation(com.revolsys.geometry.linearref.LinearLocation) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

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