use of net.osmand.data.preparation.TagsTransformer in project OsmAnd-tools by osmandapp.
the class FixBasemapRoads method process.
private void process(File read, File write, List<File> relationFiles) throws IOException, XMLStreamException, XmlPullParserException, SQLException {
MapRenderingTypesEncoder renderingTypes = new MapRenderingTypesEncoder("basemap");
OsmandRegions or = prepareRegions();
TagsTransformer transformer = new TagsTransformer();
for (File relFile : relationFiles) {
LOG.info("Parse relations file " + relFile.getName());
OsmBaseStorage storage = parseOsmFile(relFile);
int total = 0;
for (EntityId e : storage.getRegisteredEntities().keySet()) {
if (e.getType() == EntityType.RELATION) {
total++;
if (total % 1000 == 0) {
LOG.info("Processed " + total + " relations");
}
Relation es = (Relation) storage.getRegisteredEntities().get(e);
transformer.handleRelationPropogatedTags(es, renderingTypes, null, EntityConvertApplyType.MAP);
}
}
}
LOG.info("Parse main file " + read.getName());
OsmBaseStorage storage = parseOsmFile(read);
Map<EntityId, Entity> entities = new HashMap<EntityId, Entity>(storage.getRegisteredEntities());
int total = 0;
for (EntityId e : entities.keySet()) {
if (e.getType() == EntityType.WAY) {
Way es = (Way) storage.getRegisteredEntities().get(e);
total++;
if (total % 1000 == 0) {
LOG.info("Processed " + total + " ways");
}
addRegionTag(or, es);
transformer.addPropogatedTags(es);
Map<String, String> ntags = renderingTypes.transformTags(es.getModifiableTags(), EntityType.WAY, EntityConvertApplyType.MAP);
if (es.getModifiableTags() != ntags) {
es.getModifiableTags().putAll(ntags);
}
processWay(es);
}
}
List<EntityId> toWrite = new ArrayList<EntityId>();
processRegion(toWrite);
OsmStorageWriter writer = new OsmStorageWriter();
LOG.info("Writing file... ");
writer.saveStorage(new FileOutputStream(write), storage, toWrite, true);
LOG.info("DONE");
}
Aggregations