use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class Edge method addEdgeToEdgesByLine.
public static <T> void addEdgeToEdgesByLine(final Map<LineString, Set<Edge<T>>> lineEdgeMap, final Edge<T> edge) {
final LineString line = edge.getLineString();
for (final Entry<LineString, Set<Edge<T>>> entry : lineEdgeMap.entrySet()) {
final LineString keyLine = entry.getKey();
if (LineStringUtil.equalsIgnoreDirection2d(line, keyLine)) {
final Set<Edge<T>> edges = entry.getValue();
edges.add(edge);
return;
}
}
final HashSet<Edge<T>> edges = new HashSet<>();
edges.add(edge);
lineEdgeMap.put(line, edges);
}
use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class Edge method compareTo.
@Override
public int compareTo(final Object other) {
if (other instanceof Edge<?>) {
final Edge<?> edge = (Edge<?>) other;
if (this == edge) {
return 0;
} else if (isRemoved()) {
return 1;
} else if (edge.isRemoved()) {
return -1;
} else {
final Node<?> otherFromNode = edge.getFromNode();
final Node<?> fromNode = getFromNode();
final int fromCompare = fromNode.compareTo(otherFromNode.getX(), otherFromNode.getY());
if (fromCompare == 0) {
final Node<?> otherToNode = edge.getToNode();
final Node<T> toNode = getToNode();
final int toCompare = toNode.compareTo(otherToNode.getX(), otherToNode.getY());
if (toCompare == 0) {
final double otherLength = edge.getLength();
final double length = getLength();
final int lengthCompare = Double.compare(length, otherLength);
if (lengthCompare == 0) {
final String name = toSuperString();
final String otherName = edge.toSuperString();
final int nameCompare = name.compareTo(otherName);
if (nameCompare == 0) {
return ((Integer) this.id).compareTo(edge.id);
} else {
return nameCompare;
}
}
return lengthCompare;
} else {
return toCompare;
}
} else {
return fromCompare;
}
}
} else if (other instanceof LineString) {
final LineString otherLine = (LineString) other;
final LineString line = getLineString();
return line.compareTo(otherLine);
}
return 1;
}
use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class Edge method getFromAngle.
public double getFromAngle() {
final LineString line = getLineString();
final LineString points = line;
return CoordinatesListUtil.angleToNext(points, 0);
}
use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class MonotoneChainEdge method computeIntersectsForChain.
public void computeIntersectsForChain(final int chainIndex0, final MonotoneChainEdge mce, final int chainIndex1, final SegmentIntersector si) {
final Edge edge1 = this.edge;
final Edge edge2 = mce.edge;
final LineString line1 = edge1.getLineString();
final LineString line2 = edge2.getLineString();
computeIntersectsForChain(edge1, line1, this.startIndex[chainIndex0], this.startIndex[chainIndex0 + 1], edge2, line2, mce.startIndex[chainIndex1], mce.startIndex[chainIndex1 + 1], si);
}
use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class LineContainsWithinToleranceFilter method test.
@Override
public boolean test(final LineString line) {
if (this.envelope.intersects(line.getBoundingBox())) {
final LineString points = line;
final boolean contains;
if (this.flip) {
contains = CoordinatesListUtil.containsWithinTolerance(points, this.points, this.tolerance);
} else {
contains = CoordinatesListUtil.containsWithinTolerance(this.points, points, this.tolerance);
}
if (contains) {
return true;
} else {
return false;
}
} else {
return false;
}
}
Aggregations