Search in sources :

Example 6 with TransportRoute

use of net.osmand.data.TransportRoute in project Osmand by osmandapp.

the class BinaryInspector method printTransportDetailInfo.

private void printTransportDetailInfo(VerboseInfo verbose, BinaryMapIndexReader index, TransportIndex p) throws IOException {
    SearchRequest<TransportStop> sr = BinaryMapIndexReader.buildSearchTransportRequest(MapUtils.get31TileNumberX(verbose.lonleft), MapUtils.get31TileNumberX(verbose.lonright), MapUtils.get31TileNumberY(verbose.lattop), MapUtils.get31TileNumberY(verbose.latbottom), -1, null);
    List<TransportStop> stops = index.searchTransportIndex(sr);
    Map<Long, TransportRoute> rs = new LinkedHashMap<>();
    List<String> lrs = new ArrayList<>();
    println("\nStops:");
    for (TransportStop s : stops) {
        lrs.clear();
        for (int pnt : s.getReferencesToRoutes()) {
            TransportRoute route;
            if (!lrs.contains(pnt)) {
                TIntObjectHashMap<TransportRoute> pts = index.getTransportRoutes(new int[] { pnt });
                route = pts.valueCollection().iterator().next();
                rs.put((long) pnt, route);
            } else {
                route = rs.get(pnt);
            }
            if (route != null) {
                // lrs.add(route.getRef() + " " + route.getName(verbose.lang));
                lrs.add(route.getRef() + " " + route.getType());
            }
        }
        println("  " + s.getName(verbose.lang) + ": " + lrs + " " + s.getLocation());
    }
    println("\nRoutes:");
    for (TransportRoute s : rs.values()) {
        List<String> stopsString = new ArrayList<>();
        for (TransportStop st : s.getForwardStops()) {
            stopsString.add(st.getName(verbose.lang));
        }
        println("  " + s.getRef() + " " + s.getType() + " " + s.getName(verbose.lang) + ": " + stopsString);
    }
}
Also used : TransportRoute(net.osmand.data.TransportRoute) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) TLongArrayList(gnu.trove.list.array.TLongArrayList) TransportStop(net.osmand.data.TransportStop) LinkedHashMap(java.util.LinkedHashMap)

Example 7 with TransportRoute

use of net.osmand.data.TransportRoute in project Osmand by osmandapp.

the class BinaryMapIndexReader method testTransportSearch.

private static void testTransportSearch(BinaryMapIndexReader reader) throws IOException {
    // test transport
    for (TransportIndex i : reader.transportIndexes) {
        println("Transport bounds : " + i.left + " " + i.right + " " + i.top + " " + i.bottom);
    }
    for (TransportStop s : reader.searchTransportIndex(buildSearchTransportRequest(sleft, sright, stop, sbottom, -1, null))) {
        println(s.getName());
        TIntObjectHashMap<TransportRoute> routes = reader.getTransportRoutes(s.getReferencesToRoutes());
        for (net.osmand.data.TransportRoute route : routes.valueCollection()) {
            println(" " + route.getRef() + " " + route.getName() + " " + route.getDistance() + " " + route.getAvgBothDistance());
            StringBuilder b = new StringBuilder();
            for (Way w : route.getForwardWays()) {
                b.append(w.getNodes()).append(" ");
            }
            println("  forward ways: " + b.toString());
        }
    }
}
Also used : TransportRoute(net.osmand.data.TransportRoute) TransportRoute(net.osmand.data.TransportRoute) TransportIndex(net.osmand.binary.BinaryMapTransportReaderAdapter.TransportIndex) TransportStop(net.osmand.data.TransportStop) Way(net.osmand.osm.edit.Way)

Example 8 with TransportRoute

use of net.osmand.data.TransportRoute in project Osmand by osmandapp.

the class EntityParser method parserRoute.

public static TransportRoute parserRoute(Relation r, String ref) {
    TransportRoute rt = new TransportRoute();
    parseMapObject(rt, r, r.getTags());
    rt.setRef(ref);
    return rt;
}
Also used : TransportRoute(net.osmand.data.TransportRoute)

Aggregations

TransportRoute (net.osmand.data.TransportRoute)8 TIntArrayList (gnu.trove.list.array.TIntArrayList)2 ArrayList (java.util.ArrayList)2 TransportIndex (net.osmand.binary.BinaryMapTransportReaderAdapter.TransportIndex)2 TransportStop (net.osmand.data.TransportStop)2 Relation (net.osmand.osm.edit.Relation)2 TransportStopRoute (net.osmand.plus.transport.TransportStopRoute)2 TransportStopType (net.osmand.plus.transport.TransportStopType)2 TLongArrayList (gnu.trove.list.array.TLongArrayList)1 TIntObjectHashMap (gnu.trove.map.hash.TIntObjectHashMap)1 TLongObjectHashMap (gnu.trove.map.hash.TLongObjectHashMap)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Entry (java.util.Map.Entry)1 Way (net.osmand.osm.edit.Way)1