Search in sources :

Example 76 with PointDoubleXY

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

the class ConnectedInteriorTester method findDifferentPoint.

public static Point findDifferentPoint(final LineString line, final Point point) {
    final int vertexCount = line.getVertexCount();
    for (int vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++) {
        final double x = line.getX(vertexIndex);
        final double y = line.getY(vertexIndex);
        if (!point.equalsVertex(x, y)) {
            return new PointDoubleXY(x, y);
        }
    }
    return null;
}
Also used : PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 77 with PointDoubleXY

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

the class OsmPbfRecordIterator method parseDenseNodes.

private void parseDenseNodes(final ProtocolBufferInputStream in) throws IOException {
    final List<Long> ids = new ArrayList<>();
    final List<Double> latitudes = new ArrayList<>();
    final List<Double> longitudes = new ArrayList<>();
    final List<String> keysAndValues = new ArrayList<>();
    DenseInfo denseInfo = null;
    final int inLength = in.startLengthDelimited();
    boolean running = true;
    while (running) {
        final int tag = in.readTag();
        switch(tag) {
            case 0:
                running = false;
                break;
            case 8:
                in.readLong(ids);
                break;
            case 10:
                in.readLongs(ids);
                break;
            case 42:
                denseInfo = parseDenseInfo(in);
                break;
            case 64:
                readDegreesById(in, latitudes);
                break;
            case 66:
                readDegreesByIds(in, latitudes);
                break;
            case 72:
                readDegreesById(in, longitudes);
                break;
            case 74:
                readDegreesByIds(in, longitudes);
                break;
            case 80:
                readStringById(in, keysAndValues);
                break;
            case 82:
                readStringsByIds(in, keysAndValues);
                break;
            default:
                in.skipField(tag);
                break;
        }
    }
    in.endLengthDelimited(inLength);
    if (ids.size() != latitudes.size() || ids.size() != longitudes.size()) {
        throw new RuntimeException("Number of ids (" + ids.size() + "), latitudes (" + latitudes.size() + "), and longitudes (" + longitudes.size() + ") don't match");
    }
    if (denseInfo == null && keysAndValues.isEmpty()) {
        for (int i = 0; i < ids.size(); i++) {
            final long id = ids.get(i);
            final double latitude = latitudes.get(i);
            final double longitude = longitudes.get(i);
            final Point point = new PointDoubleXY(longitude, latitude);
            this.nodePoints.put(id, point);
        }
    } else {
        final Iterator<String> keysAndValuesIterator = keysAndValues.iterator();
        long id = 0;
        for (int i = 0; i < ids.size(); i++) {
            final long idOffset = ids.get(i);
            id += idOffset;
            final double latitude = latitudes.get(i);
            final double longitude = longitudes.get(i);
            final Point point = OsmConstants.WGS84_2D.point(longitude, latitude);
            this.nodePoints.put(id, point);
            OsmNode node = null;
            while (keysAndValuesIterator.hasNext()) {
                final String key = keysAndValuesIterator.next();
                if (key.length() == 0) {
                    break;
                }
                if (!keysAndValuesIterator.hasNext()) {
                    throw new RuntimeException("The PBF DenseInfo keys/values list contains a key with no corresponding value.");
                }
                if (node == null) {
                    node = new OsmNode();
                    node.setId(id);
                    node.setGeometryValue(point);
                    this.currentRecords.add(node);
                }
                final String value = keysAndValuesIterator.next();
                node.addTag(key, value);
            }
            if (denseInfo != null && node != null) {
                node.setVersion(denseInfo.versions.get(i));
                node.setChangeset(denseInfo.changesets.get(i));
                node.setTimestamp(denseInfo.timestamps.get(i));
                node.setUid(denseInfo.uids.get(i));
                node.setUser(denseInfo.userNames.get(i));
                node.setVisible(denseInfo.visibles.get(i));
            }
        }
    }
}
Also used : OsmNode(com.revolsys.record.io.format.openstreetmap.model.OsmNode) ArrayList(java.util.ArrayList) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 78 with PointDoubleXY

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

the class MoepBinaryIterator method loadHeader.

private void loadHeader() throws IOException {
    this.fileType = (byte) read();
    if (this.fileType / 100 == 0) {
        this.coordinateBytes = 2;
    } else {
        this.fileType %= 100;
        this.coordinateBytes = 4;
    }
    String mapsheet = readString(11);
    mapsheet = mapsheet.replaceAll("\\.", "").toLowerCase();
    final Bcgs20000RectangularMapGrid bcgsGrid = new Bcgs20000RectangularMapGrid();
    final UtmRectangularMapGrid utmGrid = new UtmRectangularMapGrid();
    final double latitude = bcgsGrid.getLatitude(mapsheet) + 0.05;
    final double longitude = bcgsGrid.getLongitude(mapsheet) - 0.1;
    final int crsId = utmGrid.getNad83Srid(longitude, latitude);
    final CoordinateSystem coordinateSystem = EpsgCoordinateSystems.getCoordinateSystem(crsId);
    final String submissionDateString = readString(6);
    final double centreX = readLEInt(this.in);
    final double centreY = readLEInt(this.in);
    this.center = new PointDoubleXY(centreX, centreY);
    this.factory = GeometryFactory.fixed3d(coordinateSystem.getCoordinateSystemId(), 1.0, 1.0, 1.0);
    setProperty(IoConstants.GEOMETRY_FACTORY, this.factory);
}
Also used : Bcgs20000RectangularMapGrid(com.revolsys.gis.grid.Bcgs20000RectangularMapGrid) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) UtmRectangularMapGrid(com.revolsys.gis.grid.UtmRectangularMapGrid) LineString(com.revolsys.geometry.model.LineString) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 79 with PointDoubleXY

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

the class PreparedPolygonIntersectsPerfTest method newLines.

List newLines(final BoundingBox env, final int nItems, final double size, final int nPts) {
    final int nCells = (int) Math.sqrt(nItems);
    final List geoms = new ArrayList();
    final double width = env.getWidth();
    final double xInc = width / nCells;
    final double yInc = width / nCells;
    for (int i = 0; i < nCells; i++) {
        for (int j = 0; j < nCells; j++) {
            final Point base = new PointDoubleXY(env.getMinX() + i * xInc, env.getMinY() + j * yInc);
            final Geometry line = newLine(base, size, nPts);
            geoms.add(line);
        }
    }
    return geoms;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 80 with PointDoubleXY

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

the class PreparedPolygonIntersectsPerfTest method test.

public void test(final int nPts) {
    // Geometry poly = newCircle(new BaseLasPoint((double)0, 0), 100, nPts);
    final Geometry sinePoly = newSineStar(new PointDoubleXY(0, 0), 100, nPts);
    // System.out.println(poly);
    // Geometry target = sinePoly.getBoundary();
    final Geometry target = sinePoly;
    final List lines = newLines(target.getBoundingBox(), NUM_LINES, 1.0, NUM_LINE_PTS);
    // System.out.println();
    // System.out.println("Running with " + nPts + " points");
    test(target, lines);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) List(java.util.List) ArrayList(java.util.ArrayList) 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