use of net.osmand.osm.edit.Relation in project OsmAnd-tools by osmandapp.
the class IndexCreator method indexRelations.
private void indexRelations(OsmDbAccessor accessor, IProgress progress) throws SQLException, InterruptedException {
if (indexAddress || indexMap || indexRouting || indexPOI || indexTransport) {
// $NON-NLS-1$
setGeneralProgress(progress, "[30 / 100]");
// $NON-NLS-1$
progress.startTask(Messages.getString("IndexCreator.PREINDEX_BOUNDARIES_RELATIONS"), accessor.getAllRelations());
accessor.iterateOverEntities(progress, EntityType.RELATION, new OsmDbVisitor() {
@Override
public void iterateEntity(Entity e, OsmDbAccessorContext ctx) throws SQLException {
if (indexAddress) {
// indexAddressCreator.indexAddressRelation((Relation) e, ctx); streets needs loaded boundaries !!!
indexAddressCreator.indexBoundariesRelation(e, ctx);
}
if (indexMap) {
indexMapCreator.indexMapRelationsAndMultiPolygons(e, ctx);
}
if (indexRouting) {
indexRouteCreator.indexRelations(e, ctx);
}
if (indexPOI) {
indexPoiCreator.iterateRelation((Relation) e, ctx);
}
if (indexTransport) {
indexTransportCreator.indexRelations((Relation) e, ctx);
}
}
});
if (indexMap) {
indexMapCreator.createMapIndexTableIndexes(mapConnection);
}
if (indexAddress) {
// $NON-NLS-1$
setGeneralProgress(progress, "[40 / 100]");
// $NON-NLS-1$
progress.startTask(Messages.getString("IndexCreator.PREINDEX_BOUNDARIES_WAYS"), accessor.getAllWays());
accessor.iterateOverEntities(progress, EntityType.WAY_BOUNDARY, new OsmDbVisitor() {
@Override
public void iterateEntity(Entity e, OsmDbAccessorContext ctx) throws SQLException {
indexAddressCreator.indexBoundariesRelation(e, ctx);
}
});
// $NON-NLS-1$
setGeneralProgress(progress, "[42 / 100]");
// $NON-NLS-1$
progress.startTask(Messages.getString("IndexCreator.BIND_CITIES_AND_BOUNDARIES"), 100);
// finish up the boundaries and cities
indexAddressCreator.tryToAssignBoundaryToFreeCities(progress);
// $NON-NLS-1$
setGeneralProgress(progress, "[45 / 100]");
// $NON-NLS-1$
progress.startTask(Messages.getString("IndexCreator.PREINDEX_ADRESS_MAP"), accessor.getAllRelations());
accessor.iterateOverEntities(progress, EntityType.RELATION, new OsmDbVisitor() {
@Override
public void iterateEntity(Entity e, OsmDbAccessorContext ctx) throws SQLException {
indexAddressCreator.indexAddressRelation((Relation) e, ctx);
}
});
indexAddressCreator.commitToPutAllCities();
}
}
}
use of net.osmand.osm.edit.Relation in project OsmAnd-tools by osmandapp.
the class IndexPoiCreator method iterateRelation.
public void iterateRelation(Relation e, OsmDbAccessorContext ctx) throws SQLException {
Map<String, String> tags = renderingTypes.transformTags(e.getTags(), EntityType.RELATION, EntityConvertApplyType.POI);
for (String t : tags.keySet()) {
boolean index = poiTypes.parseAmenity(t, tags.get(t), true, tags) != null;
if (index) {
ctx.loadEntityRelation(e);
for (RelationMember id : ((Relation) e).getMembers()) {
tagsTransform.registerPropogatedTag(id.getEntityId(), t, tags.get(t));
}
}
}
tagsTransform.handleRelationPropogatedTags(e, renderingTypes, ctx, EntityConvertApplyType.POI);
}
use of net.osmand.osm.edit.Relation in project OsmAnd-tools by osmandapp.
the class IndexRouteCreator method indexRelations.
public void indexRelations(Entity e, OsmDbAccessorContext ctx) throws SQLException {
indexHighwayRestrictions(e, ctx);
if (e instanceof Relation) {
tagsTransformer.handleRelationPropogatedTags((Relation) e, renderingTypes, ctx, EntityConvertApplyType.ROUTING);
Map<String, String> tags = renderingTypes.transformTags(e.getTags(), EntityType.RELATION, EntityConvertApplyType.ROUTING);
if ("enforcement".equals(tags.get("type")) && "maxspeed".equals(tags.get("enforcement"))) {
ctx.loadEntityRelation((Relation) e);
Iterator<RelationMember> from = ((Relation) e).getMembers("from").iterator();
// mark as speed cameras
while (from.hasNext()) {
Entity n = from.next().getEntity();
if (n instanceof Node) {
tagsTransformer.registerPropogatedTag(new EntityId(EntityType.NODE, n.getId()), "highway", "speed_camera");
}
}
}
}
}
use of net.osmand.osm.edit.Relation in project OsmAnd-tools by osmandapp.
the class IndexTransportCreator method iterateMainEntity.
public void iterateMainEntity(Entity e, OsmDbAccessorContext ctx) throws SQLException {
if (e instanceof Relation && e.getTag(OSMTagKey.ROUTE) != null) {
ctx.loadEntityRelation((Relation) e);
List<TransportRoute> troutes = new ArrayList<>();
indexTransportRoute((Relation) e, troutes);
for (TransportRoute route : troutes) {
insertTransportIntoIndex(route);
}
}
}
use of net.osmand.osm.edit.Relation in project OsmAnd-tools by osmandapp.
the class IndexTransportCreator method indexTransportRoute.
private void indexTransportRoute(Relation rel, List<TransportRoute> troutes) {
String ref = rel.getTag(OSMTagKey.REF);
String route = rel.getTag(OSMTagKey.ROUTE);
String operator = rel.getTag(OSMTagKey.OPERATOR);
String color = rel.getTag(OSMTagKey.COLOUR);
Relation master = masterRoutes.get(rel.getId());
if (master != null) {
if (ref == null) {
ref = master.getTag(OSMTagKey.REF);
}
if (route == null) {
route = master.getTag(OSMTagKey.ROUTE);
}
if (operator == null) {
operator = master.getTag(OSMTagKey.OPERATOR);
}
if (color == null) {
color = master.getTag(OSMTagKey.COLOUR);
}
}
if (route == null || ref == null) {
return;
}
if (!acceptedRoutes.contains(route)) {
return;
}
if (color != null) {
String tmp = MapRenderingTypesEncoder.formatColorToPalette(color, false).replaceAll("_", "");
color = "subwayText" + tmp.substring(0, 1).toUpperCase() + tmp.substring(1) + "Color";
}
TransportRoute directRoute = EntityParser.parserRoute(rel, ref);
directRoute.setOperator(operator);
directRoute.setColor(color);
directRoute.setType(route);
directRoute.setRef(ref);
directRoute.setId(directRoute.getId() << 1);
if (processTransportRelationV2(rel, directRoute)) {
// try new transport relations first
troutes.add(directRoute);
} else {
TransportRoute backwardRoute = EntityParser.parserRoute(rel, ref);
backwardRoute.setOperator(operator);
backwardRoute.setColor(color);
backwardRoute.setType(route);
backwardRoute.setRef(ref);
backwardRoute.setName(reverseName(ref, backwardRoute.getName()));
if (!Algorithms.isEmpty(backwardRoute.getEnName(false))) {
backwardRoute.setEnName(reverseName(ref, backwardRoute.getEnName(false)));
}
if (processTransportRelationV1(rel, directRoute, backwardRoute)) {
// old relation style otherwise
backwardRoute.setId((backwardRoute.getId() << 1) + 1);
troutes.add(directRoute);
troutes.add(backwardRoute);
}
}
}
Aggregations