Skip to content

Commit 7f952d2

Browse files
authored
Merge pull request GIScience#3 from GIScience/nodeTagsToWayTags
Fix memory usage
2 parents b032573 + 800460e commit 7f952d2

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

reader-osm/src/main/java/com/graphhopper/reader/osm/OSMReader.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ public class OSMReader implements DataReader {
127127
// Modification by Maxim Rylov
128128
private boolean calcDistance3D = true;
129129

130+
public static final String[] HGV_VALUES = new String[] { "maxheight", "maxweight", "maxweight:hgv", "maxwidth", "maxlength", "maxlength:hgv", "maxaxleload" };
131+
public static final Set<String> hgv_tags = new HashSet<>(Arrays.asList(HGV_VALUES));
132+
133+
130134
public OSMReader(GraphHopperStorage ghStorage) {
131135
this.ghStorage = ghStorage;
132136
this.graph = ghStorage;
@@ -609,7 +613,17 @@ boolean addNode(ReaderNode node) {
609613
addTowerNode(node.getId(), lat, lon, ele);
610614
} else if (nodeType == PILLAR_NODE) {
611615
pillarInfo.setNode(nextPillarId, lat, lon, ele);
612-
osmNodeIdToReaderNodeMap.put(node.getId(), node.getTags());
616+
java.util.Iterator<Entry<String, Object>> it = node.getTags().entrySet().iterator();
617+
Map<String, Object> temp = new HashMap<>();
618+
619+
while (it.hasNext()) {
620+
Map.Entry<String, Object> pairs = it.next();
621+
String key = pairs.getKey();
622+
if(!hgv_tags.contains(key))
623+
continue;
624+
temp.put(key, pairs.getValue());
625+
}
626+
if(!temp.isEmpty()) osmNodeIdToReaderNodeMap.put(node.getId(), temp);
613627
getNodeMap().put(node.getId(), nextPillarId + 3);
614628
nextPillarId++;
615629
}

0 commit comments

Comments
 (0)