You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/**
* Chains together several ways which are close together (e.g. as part of a relation) to one,
* correctly ordered way. This is a computational expensive method which might be worth
* refactoring!
*
* @param waysToChain the ways from a relation
* @param radius the radius that should be considered for search for the next connection point
* between two ways
* @param wayId the id of the newly created way
* @return A concatenated {@link Way} built from a collection of {@link Way}s
* @deprecated ATTENTION! DON'T REMOVE: This method is currently not under test and has to be
* revised thoroughly
*/
@Deprecated
public static Way wayFromWays(List<Way> waysToChain, Quantity<Length> radius, int wayId) {
LinkedList<Way> waysCopy = new LinkedList<>(waysToChain);
HashMap<Node, Way> nodeToWayMap = new HashMap<>();
for (Way way : waysToChain) {
way.getNodes().forEach(node -> nodeToWayMap.put(node, way));
}
LinkedList<Node> nodesList = new LinkedList<>(waysToChain.get(0).getNodes());
waysCopy.remove(waysToChain.get(0));
while (!waysCopy.isEmpty()) {
Node lastNode = nodesList.getLast();
Polygon circle = radiusWithCircleAsPolygon(lastNode.getLatlon(), radius);
double distance = Double.POSITIVE_INFINITY;
Way nextWay = null;
Node nextLastNode = null;
for (Map.Entry<Node, Way> entry : nodeToWayMap.entrySet()) {
if (rayCasting(circle, entry.getKey().getLatlon())) {
double tempDistance;
tempDistance =
calcHaversine(
lastNode.getLatlon().getLat(),
lastNode.getLatlon().getLon(),
entry.getKey().getLatlon().getLat(),
entry.getKey().getLatlon().getLon())
.to(KILOMETRE)
.getValue()
.doubleValue();
if (tempDistance < distance) {
distance = tempDistance;
nextWay = entry.getValue();
nextLastNode = entry.getKey();
}
}
}
if (nextWay != null) {
if (nextWay.getNodes().indexOf(nextLastNode) == nextWay.getNodes().size() - 1) {
Collections.reverse(nextWay.getNodes());
}
nodesList.addAll(nextWay.getNodes());
logger.debug("Removing way with id {}", nextWay.getId());
}
nodeToWayMap.values().removeAll(Collections.singleton(nextWay));
waysCopy.remove(nextWay);
}
return new Way(wayId, new Tags(), nodesList);
}
The text was updated successfully, but these errors were encountered:
Refactor and move to new scala GeoUtils package
The text was updated successfully, but these errors were encountered: