use of net.osmand.data.TransportRoute 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.data.TransportRoute 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);
}
}
}
use of net.osmand.data.TransportRoute in project Osmand by osmandapp.
the class BinaryMapIndexReader method getTransportRoutes.
/**
* Transport public methods
*/
public TIntObjectHashMap<TransportRoute> getTransportRoutes(int[] filePointers) throws IOException {
TIntObjectHashMap<TransportRoute> result = new TIntObjectHashMap<TransportRoute>();
Map<TransportIndex, TIntArrayList> groupPoints = new HashMap<TransportIndex, TIntArrayList>();
for (int filePointer : filePointers) {
TransportIndex ind = getTransportIndex(filePointer);
if (ind != null) {
if (!groupPoints.containsKey(ind)) {
groupPoints.put(ind, new TIntArrayList());
}
groupPoints.get(ind).add(filePointer);
}
}
Iterator<Entry<TransportIndex, TIntArrayList>> it = groupPoints.entrySet().iterator();
if (it.hasNext()) {
Entry<TransportIndex, TIntArrayList> e = it.next();
TransportIndex ind = e.getKey();
TIntArrayList pointers = e.getValue();
pointers.sort();
TIntObjectHashMap<String> stringTable = new TIntObjectHashMap<String>();
for (int i = 0; i < pointers.size(); i++) {
int filePointer = pointers.get(i);
TransportRoute transportRoute = transportAdapter.getTransportRoute(filePointer, stringTable, false);
result.put(filePointer, transportRoute);
}
transportAdapter.initializeStringTable(ind, stringTable);
for (TransportRoute r : result.values(new TransportRoute[result.size()])) {
transportAdapter.initializeNames(false, r, stringTable);
}
}
return result;
}
use of net.osmand.data.TransportRoute in project Osmand by osmandapp.
the class TransportStopController method addRoutes.
private void addRoutes(List<TransportStopRoute> routes, boolean useEnglishNames, TransportIndexRepository t, TransportStop s, TransportStop refStop, int dist) {
Collection<TransportRoute> rts = t.getRouteForStop(s);
if (rts != null) {
for (TransportRoute rs : rts) {
TransportStopType type = TransportStopType.findType(rs.getType());
if (topType == null && type != null && type.isTopType()) {
topType = type;
}
if (!containsRef(routes, rs)) {
TransportStopRoute r = new TransportStopRoute();
r.type = type;
r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
r.route = rs;
r.refStop = refStop;
r.stop = s;
r.distance = dist;
routes.add(r);
}
}
}
}
use of net.osmand.data.TransportRoute in project Osmand by osmandapp.
the class AmenityMenuController method addRoutes.
private void addRoutes(boolean useEnglishNames, TransportIndexRepository t, TransportStop s, int dist, boolean isSubwayEntrance) {
Collection<TransportRoute> rts = t.getRouteForStop(s);
if (rts != null) {
for (TransportRoute rs : rts) {
if (!containsRef(rs)) {
TransportStopType type = TransportStopType.findType(rs.getType());
if (isSubwayEntrance && type != TransportStopType.SUBWAY && dist > 150) {
continue;
}
TransportStopRoute r = new TransportStopRoute();
r.type = type;
r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
r.route = rs;
r.stop = s;
r.distance = dist;
this.routes.add(r);
}
}
}
}
Aggregations