use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class Node method getPoint.
@Override
public Point getPoint() {
final Graph<T> graph = getGraph();
final GeometryFactory geometryFactory = graph.getGeometryFactory();
return geometryFactory.point(this);
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class LineStringRelate method getOverlap.
public Lineal getOverlap() {
final List<List<Point>> intersections = new ArrayList<>();
final LineString points1 = this.line1;
final List<Point> currentCoordinates = new ArrayList<>();
Node<LineSegment> previousNode = this.graph1.getNode(this.fromPoint1);
do {
final List<Edge<LineSegment>> outEdges = previousNode.getOutEdges();
if (outEdges.isEmpty()) {
previousNode = null;
} else if (outEdges.size() > 1) {
System.err.println("Cannot handle overlaps\n" + getLine1() + "\n " + getLine2());
final GeometryFactory factory = this.line1.getGeometryFactory();
return factory.lineString();
} else {
final Edge<LineSegment> edge = outEdges.get(0);
final LineSegment line = edge.getObject();
final Node<LineSegment> nextNode = edge.getToNode();
if (this.graph2.hasEdgeBetween(previousNode, nextNode)) {
if (currentCoordinates.size() == 0) {
currentCoordinates.add(line.getPoint(0));
}
currentCoordinates.add(line.getPoint(1));
} else {
if (currentCoordinates.size() > 0) {
final List<Point> points = new ArrayList<>();
intersections.add(points);
currentCoordinates.clear();
}
}
previousNode = nextNode;
}
} while (previousNode != null && !previousNode.equals(2, this.fromPoint1));
if (currentCoordinates.size() > 0) {
final List<Point> points = new ArrayList<>();
intersections.add(points);
}
final GeometryFactory factory = this.line1.getGeometryFactory();
return factory.lineal(intersections);
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class Densifier method densify.
private static LineString densify(final LineString line, final double distanceTolerance) {
final List<Point> points = densifyPoints(line, distanceTolerance);
final GeometryFactory geometryFactory = line.getGeometryFactory();
return geometryFactory.lineString(points);
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class Densifier method densify.
private static Polygonal densify(final Polygonal polygonal, final double distanceTolerance) {
final List<Polygon> polygons = new ArrayList<>();
for (final Polygon polygon : polygonal.getPolygons()) {
final Polygon newPolygon = densify(polygon, distanceTolerance);
polygons.add(newPolygon);
}
final GeometryFactory geometryFactory = polygonal.getGeometryFactory();
final Polygonal newMultiPolygon = geometryFactory.polygonal(polygons);
return (Polygonal) newMultiPolygon.buffer(0);
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class LineSegment method getIntersection.
default LineSegment getIntersection(BoundingBox boundingBox) {
final GeometryFactory geometryFactory = getGeometryFactory();
boundingBox = boundingBox.convert(geometryFactory);
final Point lineStart = getPoint(0);
final Point lineEnd = getPoint(1);
final boolean contains1 = boundingBox.covers(lineStart);
final boolean contains2 = boundingBox.covers(lineEnd);
if (contains1) {
if (contains2) {
return this;
} else {
final Point c1 = lineStart;
final Point c2 = getCrossing(lineEnd, lineStart, boundingBox);
return new LineSegmentDoubleGF(geometryFactory, c1, c2);
}
} else {
if (contains2) {
final Point c1 = getCrossing(lineStart, lineEnd, boundingBox);
final Point c2 = lineEnd;
return new LineSegmentDoubleGF(geometryFactory, c1, c2);
} else {
final Point c1 = getCrossing(lineStart, lineEnd, boundingBox);
final Point c2 = getCrossing(lineEnd, lineStart, boundingBox);
return new LineSegmentDoubleGF(geometryFactory, c1, c2);
}
}
}
Aggregations