Search in sources :

Example 61 with PointDoubleXY

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

the class LengthIndexedLineTest method testProjectExtractPoint.

/**
 * From GEOS Ticket #323
 */
public void testProjectExtractPoint() {
    final Geometry linearGeom = read("MULTILINESTRING ((0 2, 0 0), (-1 1, 1 1))");
    final LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom);
    final double index = indexedLine.project(new PointDoubleXY(1, 0));
    final Point pt = indexedLine.extractPoint(index);
    assertTrue(pt.equals(new PointDoubleXY(0, 0)));
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LengthIndexedLine(com.revolsys.geometry.linearref.LengthIndexedLine) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 62 with PointDoubleXY

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

the class LengthIndexedLineTest method testComputeZ.

/**
 * Tests that z values are interpolated
 */
public void testComputeZ() {
    final Geometry linearGeom = read("LINESTRINGZ(0 0 0, 10 10 10)");
    final LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom);
    final double projIndex = indexedLine.project(new PointDoubleXY(5, 5));
    final Point projPt = indexedLine.extractPoint(projIndex);
    // System.out.println(projPt);
    assertTrue(projPt.equals(3, new PointDoubleXYZ(5.0, 5, 5)));
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) PointDoubleXYZ(com.revolsys.geometry.model.impl.PointDoubleXYZ) LengthIndexedLine(com.revolsys.geometry.linearref.LengthIndexedLine) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 63 with PointDoubleXY

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

the class LengthIndexedLineTest method testExtractPointBeyondRange.

public void testExtractPointBeyondRange() {
    final Geometry linearGeom = read("LINESTRING (0 0, 10 10)");
    final LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom);
    final Point pt = indexedLine.extractPoint(100);
    assertTrue(pt.equals(new PointDoubleXY(10, 10)));
    final Point pt2 = indexedLine.extractPoint(0);
    assertTrue(pt2.equals(new PointDoubleXY(0, 0)));
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LengthIndexedLine(com.revolsys.geometry.linearref.LengthIndexedLine) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 64 with PointDoubleXY

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

the class RecordWriterPerformanceTest method newRecord.

private static Record newRecord(final RecordDefinition recordDefinition, final int index) {
    final Record record = new ArrayRecord(recordDefinition);
    record.setValue("boolean", index % 2 == 0);
    record.setValue("byte", index % 256 + Byte.MIN_VALUE);
    record.setValue("short", index % 65536 + Short.MIN_VALUE);
    record.setValue("int", index);
    record.setValue("long", index);
    record.setValue("float", index + index % 1000 / 1000.0);
    record.setValue("double", index + index % 1000 / 1000.0);
    record.setValue("string", "String with some special characters " + index + "\\/\"'\t\n\r");
    final Calendar calendar = new GregorianCalendar();
    calendar.set(2016, 11, index % 28 + 1, 0, 0);
    final Date date = new Date(calendar.getTimeInMillis());
    record.setValue("date", date);
    calendar.set(Calendar.MINUTE, index % 60);
    final java.util.Date dateTime = new java.util.Date(calendar.getTimeInMillis());
    record.setValue("dateTime", dateTime);
    calendar.set(Calendar.MILLISECOND, index % 1000);
    final Timestamp timestamp = new Timestamp(calendar.getTimeInMillis());
    record.setValue("timestamp", timestamp);
    record.setValue("geometry", new PointDoubleXY(index, index * 2));
    return record;
}
Also used : ArrayRecord(com.revolsys.record.ArrayRecord) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) Record(com.revolsys.record.Record) ArrayRecord(com.revolsys.record.ArrayRecord) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Timestamp(java.sql.Timestamp) Date(java.sql.Date)

Example 65 with PointDoubleXY

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

the class RectangleIntersectsPerfTest method test.

void test(final int nPts) {
    final double size = 100;
    final Point origin = new PointDoubleXY(0, 0);
    final Geometry sinePoly = newSineStar(origin, size, nPts).getBoundary();
    GeometryFactory geometryFactory = sinePoly.getGeometryFactory();
    geometryFactory = GeometryFactory.fixed(geometryFactory.getCoordinateSystemId(), geometryFactory.getAxisCount(), size / 10, size / 10, geometryFactory.getScaleZ());
    final Geometry newGeometry = sinePoly.convertGeometry(geometryFactory);
    /**
     * Make the geometry "crinkly" by rounding off the points.
     * This defeats the  MonotoneChain optimization in the full relate
     * algorithm, and provides a more realistic test.
     */
    final Geometry sinePolyCrinkly = newGeometry;
    final Geometry target = sinePolyCrinkly;
    final Geometry rect = newRectangle(origin, 5);
    // System.out.println(target);
    // System.out.println("Running with " + nPts + " points");
    testRectangles(target, 100, 5);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) 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