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;
}
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));
}
}
}
}
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);
}
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;
}
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);
}
Aggregations