use of de.topobyte.adt.multicollections.CountingMultiValMap in project osm4j-geometry by topobyte.
the class RelationUtil method buildWayTailMap.
/**
* For all ways given, build a multivalmap from node-ids to ways. Head and
* tail of each way are put as key and the way as value.
*/
public static CountingMultiValMap<Long, OsmWay> buildWayTailMap(MultiSet<OsmWay> ways) {
CountingMultiValMap<Long, OsmWay> waysNodes = new CountingMultiValMap<>();
for (OsmWay way : ways) {
// add all of them to waysNodes. implement iterator correctly...
int nnodes = way.getNumberOfNodes();
if (nnodes < 2) {
throw new IllegalArgumentException("Only ways with 2 or more nodes are allowed");
}
long node1 = way.getNodeId(0);
long nodeN = way.getNodeId(nnodes - 1);
waysNodes.add(node1, way);
waysNodes.add(nodeN, way);
}
return waysNodes;
}
Aggregations