@Override protected void parseWays(List<Osmformat.Way> osmWays) { if (exception == null) { try { for (Osmformat.Way w : osmWays) { final Info info = w.getInfo(); if (!info.hasVersion()) discourageUpload = true; final Way way = new Way(w.getId(), info.hasVersion() ? info.getVersion() : 1); setMetadata(way, info); Map<String, String> keys = new HashMap<>(); for (int i = 0; i < w.getKeysCount(); i++) { keys.put(getStringById(w.getKeys(i)), getStringById(w.getVals(i))); } way.setKeys(keys); long previousId = 0; // Node ids are delta coded Collection<Long> nodeIds = new ArrayList<>(); for (Long id : w.getRefsList()) { nodeIds.add(previousId += id); } ways.put(way.getUniqueId(), nodeIds); externalIdMap.put(way.getPrimitiveId(), way); } } catch (IllegalDataException e) { exception = e; } } }
/** * Creates new way objects for the way chunks and transfers the keys from the original way. * * @param way the original way whose keys are transferred * @param wayChunks the way chunks * @return the new way objects */ protected static List<Way> createNewWaysFromChunks(Way way, Iterable<List<Node>> wayChunks) { final List<Way> newWays = new ArrayList<>(); for (List<Node> wayChunk : wayChunks) { Way wayToAdd = new Way(); wayToAdd.setKeys(way.getKeys()); wayToAdd.setNodes(wayChunk); newWays.add(wayToAdd); } return newWays; }