Search in sources :

Example 11 with PointDoubleXY

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

the class PerturbedGridPolygonBuilder method buildGrid.

private Geometry buildGrid() {
    final LineString[] lines = new LineString[this.numLines * 2];
    int index = 0;
    for (int i = 0; i < this.numLines; i++) {
        final Point p0 = new PointDoubleXY(getRandOrdinate(), 0);
        final Point p1 = new PointDoubleXY(getRandOrdinate(), this.gridWidth);
        final LineString line = this.geomFactory.lineString(new Point[] { p0, p1 });
        lines[index++] = line;
    }
    for (int i = 0; i < this.numLines; i++) {
        final Point p0 = new PointDoubleXY(0, getRandOrdinate());
        final Point p1 = new PointDoubleXY(this.gridWidth, getRandOrdinate());
        final LineString line = this.geomFactory.lineString(new Point[] { p0, p1 });
        lines[index++] = line;
    }
    final Lineal ml = this.geomFactory.lineal(lines);
    final Geometry grid = ml.buffer(this.lineWidth);
    // System.out.println(grid);
    return grid;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 12 with PointDoubleXY

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

the class RobustLineIntersectorTest method testA.

public void testA() {
    final Point p1 = new PointDoubleXY(-123456789, -40);
    final Point p2 = new PointDoubleXY(381039468754763d, 123456789);
    final GeometryFactory geometryFactory = GeometryFactory.DEFAULT_3D;
    final LineString l = geometryFactory.lineString(new Point[] { p1, p2 });
    final Point p = geometryFactory.point(0.0, 0.0);
    assertEquals(false, l.intersects(p));
    assertEquals(false, geometryFactory.lineString(p1, p2).isOnLine(p));
    assertEquals(-1, CGAlgorithmsDD.orientationIndex(p1, p2, p));
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 13 with PointDoubleXY

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

the class RobustLineIntersectorTest method testCollinear1.

public void testCollinear1() {
    final RobustLineIntersector i = new RobustLineIntersector();
    final Point p1 = new PointDoubleXY(10, 10);
    final Point p2 = new PointDoubleXY(20, 10);
    final Point q1 = new PointDoubleXY(22, 10);
    final Point q2 = new PointDoubleXY(30, 10);
    i.computeIntersectionPoints(p1, p2, q1, q2);
    assertEquals(LineIntersector.NO_INTERSECTION, i.getIntersectionCount());
    assertTrue(!i.isProper());
    assertTrue(!i.hasIntersection());
}
Also used : RobustLineIntersector(com.revolsys.geometry.algorithm.RobustLineIntersector) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 14 with PointDoubleXY

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

the class RobustLineIntersectorTest method testEndpointIntersection.

public void testEndpointIntersection() {
    this.i.computeIntersectionPoints(new PointDoubleXY(100, 100), new PointDoubleXY(10, 100), new PointDoubleXY(100, 10), new PointDoubleXY(100, 100));
    assertTrue(this.i.hasIntersection());
    assertEquals(1, this.i.getIntersectionCount());
}
Also used : PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 15 with PointDoubleXY

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

the class RobustLineIntersectorTest method testEndpointIntersection2.

public void testEndpointIntersection2() {
    this.i.computeIntersectionPoints(new PointDoubleXY(190, 50), new PointDoubleXY(120, 100), new PointDoubleXY(120, 100), new PointDoubleXY(50, 150));
    assertTrue(this.i.hasIntersection());
    assertEquals(1, this.i.getIntersectionCount());
    assertEquals(new PointDoubleXY(120, 100), this.i.getIntersection(1));
}
Also used : 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