Search in sources :

Example 91 with PointDoubleXY

use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.

the class MiscellaneousTest2 method testDirectedEdgeToEdges.

public void testDirectedEdgeToEdges() {
    final DirectedEdge d1 = new DirectedEdge(new Node(0, 0), new Node(10, 10), new PointDoubleXY(10, 10), true);
    final DirectedEdge d2 = new DirectedEdge(new Node(20, 0), new Node(20, 10), new PointDoubleXY(20, 10), false);
    final List edges = DirectedEdge.toEdges(Arrays.asList(d1, d2));
    assertEquals(2, edges.size());
    assertNull(edges.get(0));
    assertNull(edges.get(1));
}
Also used : DirectedEdge(com.revolsys.geometry.planargraph.DirectedEdge) Node(com.revolsys.geometry.planargraph.Node) List(java.util.List) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 92 with PointDoubleXY

use of com.revolsys.geometry.model.impl.PointDoubleXY 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));
}
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 93 with PointDoubleXY

use of com.revolsys.geometry.model.impl.PointDoubleXY 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);
}
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 94 with PointDoubleXY

use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.

the class AffineTransformationFactory method newFromControlVectors.

/**
 * Creates an AffineTransformation defined by a pair of control vectors. A
 * control vector consists of a source point and a destination point, which is
 * the image of the source point under the desired transformation. The
 * computed transformation is a combination of one or more of a uniform scale,
 * a rotation, and a translation (i.e. there is no shear component and no
 * reflection)
 *
 * @param src0
 * @param src1
 * @param dest0
 * @param dest1
 * @return the computed transformation
 * @return null if the control vectors do not determine a well-defined transformation
 */
public static AffineTransformation newFromControlVectors(final Point src0, final Point src1, final Point dest0, final Point dest1) {
    final Point rotPt = new PointDoubleXY(dest1.getX() - dest0.getX(), dest1.getY() - dest0.getY());
    final double ang = Angle.angleBetweenOriented(src1, src0, rotPt);
    final double srcDist = src1.distancePoint(src0);
    final double destDist = dest1.distancePoint(dest0);
    if (srcDist == 0.0) {
        return null;
    }
    final double scale = destDist / srcDist;
    final AffineTransformation trans = AffineTransformation.translationInstance(-src0.getX(), -src0.getY());
    trans.rotate(ang);
    trans.scale(scale, scale);
    trans.translate(dest0.getX(), dest0.getY());
    return trans;
}
Also used : Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 95 with PointDoubleXY

use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.

the class KochSnowflakeBuilder method getBoundary.

private Point[] getBoundary(final int level, final Point origin, final double width) {
    double y = origin.getY();
    // "arm" to centre it
    if (level > 0) {
        y += THIRD_HEIGHT * width;
    }
    final Point p0 = new PointDoubleXY(origin.getX(), y);
    final Point p1 = new PointDoubleXY(origin.getX() + width / 2, y + width * HEIGHT_FACTOR);
    final Point p2 = new PointDoubleXY(origin.getX() + width, y);
    addSide(level, p0, p1);
    addSide(level, p1, p2);
    addSide(level, p2, p0);
    this.coordList.closeRing();
    return this.coordList.toPointArray();
}
Also used : Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Aggregations

PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)138 Point (com.revolsys.geometry.model.Point)91 Geometry (com.revolsys.geometry.model.Geometry)36 ArrayList (java.util.ArrayList)19 BoundingBox (com.revolsys.geometry.model.BoundingBox)10 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)10 List (java.util.List)9 LineString (com.revolsys.geometry.model.LineString)8 Polygon (com.revolsys.geometry.model.Polygon)6 RobustLineIntersector (com.revolsys.geometry.algorithm.RobustLineIntersector)5 LengthIndexedLine (com.revolsys.geometry.linearref.LengthIndexedLine)5 LinearLocation (com.revolsys.geometry.linearref.LinearLocation)5 LocationIndexedLine (com.revolsys.geometry.linearref.LocationIndexedLine)5 LineSegmentDouble (com.revolsys.geometry.model.segment.LineSegmentDouble)5 PointDoubleXYZ (com.revolsys.geometry.model.impl.PointDoubleXYZ)4 LineSegment (com.revolsys.geometry.model.segment.LineSegment)4 AffineTransformation (com.revolsys.geometry.model.util.AffineTransformation)4 GeometricShapeFactory (com.revolsys.geometry.util.GeometricShapeFactory)4 Vertex (com.revolsys.geometry.model.vertex.Vertex)3 KdNode (com.revolsys.geometry.index.kdtree.KdNode)2