private void checkWaysForUsefullNodes(List<Way> ways) { for (Osmformat.Way i : ways) { List<Tag> listeTags = new ArrayList<Tag>(); for (int j = 0; j < i.getKeysCount(); j++) { Tag tag = new Tag(); tag.setKey(getStringById(i.getKeys(j))); tag.setValue(getStringById(i.getVals(j))); listeTags.add(tag); } long lastId = 0; List<Nd> listeLocalisationsRef = new ArrayList<Nd>(); for (long j : i.getRefsList()) { Nd nd = new Nd(); nd.setRef(j + lastId); listeLocalisationsRef.add(nd); lastId = j + lastId; } com.osm2xp.model.osm.Way way = new com.osm2xp.model.osm.Way(); way.getTag().addAll(listeTags); way.setId(i.getId()); way.getNd().addAll(listeLocalisationsRef); try { List<Long> ids = new ArrayList<Long>(); for (Nd nd : way.getNd()) { ids.add(nd.getRef()); } if (translator.mustStoreWay(way)) { for (Nd nd : way.getNd()) { com.osm2xp.model.osm.Node node = new com.osm2xp.model.osm.Node(); node.setId(nd.getRef()); node.setLat(0); node.setLon(0); processor.storeNode(node); } } } catch (DataSinkException e) { Osm2xpLogger.error("Error processing way.", e); } } }
private void sendWaysToTranslator(List<Way> ways) { for (Osmformat.Way i : ways) { List<Tag> listeTags = new ArrayList<Tag>(); for (int j = 0; j < i.getKeysCount(); j++) { Tag tag = new Tag(); tag.setKey(getStringById(i.getKeys(j))); tag.setValue(getStringById(i.getVals(j))); listeTags.add(tag); } long lastId = 0; List<Nd> listeLocalisationsRef = new ArrayList<Nd>(); for (long j : i.getRefsList()) { Nd nd = new Nd(); nd.setRef(j + lastId); listeLocalisationsRef.add(nd); lastId = j + lastId; } com.osm2xp.model.osm.Way way = new com.osm2xp.model.osm.Way(); way.getTag().addAll(listeTags); way.setId(i.getId()); way.getNd().addAll(listeLocalisationsRef); // if roof color information is available, add it to the current way if (this.roofsColorMap != null && this.roofsColorMap.get(way.getId()) != null) { String hexColor = Integer.toHexString(this.roofsColorMap.get(way.getId()).getRGB() & 0x00ffffff); Tag roofColorTag = new Tag("building:roof:color", hexColor); way.getTag().add(roofColorTag); } try { List<Long> ids = new ArrayList<Long>(); for (Nd nd : way.getNd()) { ids.add(nd.getRef()); } List<com.osm2xp.model.osm.Node> nodes = processor.getNodes(ids); if (nodes != null) { OsmPolygon polygon = new OsmPolygon(way.getId(), way.getTag(), nodes); translator.processPolygon(polygon); } } catch (Osm2xpBusinessException e) { Osm2xpLogger.error("Error processing way.", e); } catch (DataSinkException e) { Osm2xpLogger.error("Error processing way.", e); } } }