use of com.revolsys.geometry.linearref.LocationIndexedLine 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);
}
use of com.revolsys.geometry.linearref.LocationIndexedLine 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));
}
use of com.revolsys.geometry.linearref.LocationIndexedLine in project com.revolsys.open by revolsys.
the class LinearLocationTest method testGetSegmentMultiLineString.
public void testGetSegmentMultiLineString() throws Exception {
final Geometry line = this.geometryFactory.geometry("MULTILINESTRING ((0 0, 10 0, 20 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 loc2B = new LinearLocation(1, 0, 0.0);
final LinearLocation loc2_5 = indexedLine.indexOf(new PointDoubleXY(25, 0));
final LinearLocation loc3 = indexedLine.indexOf(new PointDoubleXY(30, 0));
final LineSegment seg0 = new LineSegmentDouble(new PointDoubleXY(0, 0), new PointDoubleXY(10, 0));
final LineSegment seg1 = new LineSegmentDouble(new PointDoubleXY(10, 0), new PointDoubleXY(20, 0));
final LineSegment seg2 = new LineSegmentDouble(new PointDoubleXY(20, 0), new PointDoubleXY(30, 0));
assertTrue(loc0.getSegment(line).equals(seg0));
assertTrue(loc0_5.getSegment(line).equals(seg0));
assertTrue(loc1.getSegment(line).equals(seg1));
assertTrue(loc2.getSegment(line).equals(seg1));
assertTrue(loc2_5.getSegment(line).equals(seg2));
assertTrue(loc3.getSegment(line).equals(seg2));
}
use of com.revolsys.geometry.linearref.LocationIndexedLine in project com.revolsys.open by revolsys.
the class LinearLocationTest method testSameSegmentMultiLineString.
public void testSameSegmentMultiLineString() throws Exception {
final Geometry line = this.geometryFactory.geometry("MULTILINESTRING ((0 0, 10 0, 20 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 loc2B = new LinearLocation(1, 0, 0.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(loc2B.isOnSameSegment(loc3));
assertTrue(loc2_5.isOnSameSegment(loc3));
assertTrue(!loc3.isOnSameSegment(loc0));
assertTrue(!loc3.isOnSameSegment(loc2));
assertTrue(loc3.isOnSameSegment(loc2B));
assertTrue(loc3.isOnSameSegment(loc2_5));
assertTrue(loc3.isOnSameSegment(loc3));
}
use of com.revolsys.geometry.linearref.LocationIndexedLine in project com.revolsys.open by revolsys.
the class LinearLocationTest method testZeroLengthLineString.
public void testZeroLengthLineString() throws Exception {
final Geometry line = this.geometryFactory.geometry("LINESTRING (10 0, 10 0)");
final LocationIndexedLine indexedLine = new LocationIndexedLine(line);
final LinearLocation loc0 = indexedLine.indexOf(new PointDoubleXY(11, 0));
assertTrue(loc0.compareTo(new LinearLocation(1, 0.0)) == 0);
}
Aggregations