Search in sources :

Example 6 with RouteTypeRule

use of net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule in project Osmand by osmandapp.

the class RouteDataObject method getLanes.

public int getLanes() {
    int sz = types.length;
    for (int i = 0; i < sz; i++) {
        RouteTypeRule r = region.quickGetEncodingRule(types[i]);
        int ln = r.lanes();
        if (ln > 0) {
            return ln;
        }
    }
    return -1;
}
Also used : RouteTypeRule(net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule)

Example 7 with RouteTypeRule

use of net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule in project OsmAnd-tools by osmandapp.

the class BinaryMapIndexWriter method writeRouteRawEncodingRules.

public void writeRouteRawEncodingRules(List<BinaryMapRouteReaderAdapter.RouteTypeRule> types) throws IOException {
    checkPeekState(ROUTE_INDEX_INIT);
    for (int i = 1; i < types.size(); i++) {
        RouteEncodingRule.Builder builder = OsmandOdb.OsmAndRoutingIndex.RouteEncodingRule.newBuilder();
        RouteTypeRule rule = types.get(i);
        builder.setTag(rule.getTag());
        if (rule.getValue() != null) {
            builder.setValue(rule.getValue());
        } else {
            builder.setValue("");
        }
        RouteEncodingRule rulet = builder.build();
        codedOutStream.writeMessage(OsmandOdb.OsmAndRoutingIndex.RULES_FIELD_NUMBER, rulet);
    }
}
Also used : RouteTypeRule(net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule) RouteEncodingRule(net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteEncodingRule)

Example 8 with RouteTypeRule

use of net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule in project Osmand by osmandapp.

the class RouteDataObject method getHighway.

public static String getHighway(int[] types, RouteRegion region) {
    String highway = null;
    int sz = types.length;
    for (int i = 0; i < sz; i++) {
        RouteTypeRule r = region.quickGetEncodingRule(types[i]);
        highway = r.highwayRoad();
        if (highway != null) {
            break;
        }
    }
    return highway;
}
Also used : RouteTypeRule(net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule)

Example 9 with RouteTypeRule

use of net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule in project Osmand by osmandapp.

the class RouteResultPreparation method printAdditionalPointInfo.

private void printAdditionalPointInfo(RouteSegmentResult res) {
    boolean plus = res.getStartPointIndex() < res.getEndPointIndex();
    for (int k = res.getStartPointIndex(); k != res.getEndPointIndex(); ) {
        int[] tp = res.getObject().getPointTypes(k);
        String[] pointNames = res.getObject().getPointNames(k);
        int[] pointNameTypes = res.getObject().getPointNameTypes(k);
        if (tp != null || pointNameTypes != null) {
            StringBuilder bld = new StringBuilder();
            bld.append("<point " + (k));
            if (tp != null) {
                for (int t = 0; t < tp.length; t++) {
                    RouteTypeRule rr = res.getObject().region.quickGetEncodingRule(tp[t]);
                    bld.append(" " + rr.getTag() + "=\"" + rr.getValue() + "\"");
                }
            }
            if (pointNameTypes != null) {
                for (int t = 0; t < pointNameTypes.length; t++) {
                    RouteTypeRule rr = res.getObject().region.quickGetEncodingRule(pointNameTypes[t]);
                    bld.append(" " + rr.getTag() + "=\"" + pointNames[t] + "\"");
                }
            }
            bld.append("/>");
            println("\t" + bld.toString());
        }
        if (plus) {
            k++;
        } else {
            k--;
        }
    }
}
Also used : RouteTypeRule(net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule)

Example 10 with RouteTypeRule

use of net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule in project Osmand by osmandapp.

the class RouteCalculationResult method attachAlarmInfo.

private static void attachAlarmInfo(List<AlarmInfo> alarms, RouteSegmentResult res, int intId, int locInd) {
    int[] pointTypes = res.getObject().getPointTypes(intId);
    if (pointTypes != null) {
        RouteRegion reg = res.getObject().region;
        for (int r = 0; r < pointTypes.length; r++) {
            RouteTypeRule typeRule = reg.quickGetEncodingRule(pointTypes[r]);
            int x31 = res.getObject().getPoint31XTile(intId);
            int y31 = res.getObject().getPoint31YTile(intId);
            Location loc = new Location("");
            loc.setLatitude(MapUtils.get31LatitudeY(y31));
            loc.setLongitude(MapUtils.get31LongitudeX(x31));
            AlarmInfo info = AlarmInfo.createAlarmInfo(typeRule, locInd, loc);
            // For STOP first check if it has directional info
            if ((info != null) && !((info.getType() == AlarmInfoType.STOP) && !res.getObject().isStopApplicable(res.isForwardDirection(), intId, res.getStartPointIndex(), res.getEndPointIndex()))) {
                alarms.add(info);
            }
        }
    }
}
Also used : RouteRegion(net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion) RouteTypeRule(net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule) LocationPoint(net.osmand.data.LocationPoint) Location(net.osmand.Location)

Aggregations

RouteTypeRule (net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule)11 RouteRegion (net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion)3 LocationPoint (net.osmand.data.LocationPoint)2 TIntObjectIterator (gnu.trove.iterator.TIntObjectIterator)1 TLongArrayList (gnu.trove.list.array.TLongArrayList)1 TIntObjectHashMap (gnu.trove.map.hash.TIntObjectHashMap)1 IOException (java.io.IOException)1 Location (net.osmand.Location)1 BinaryMapDataObject (net.osmand.binary.BinaryMapDataObject)1 MapIndex (net.osmand.binary.BinaryMapIndexReader.MapIndex)1 RouteSubregion (net.osmand.binary.BinaryMapRouteReaderAdapter.RouteSubregion)1 RouteEncodingRule (net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteEncodingRule)1 RouteDataObject (net.osmand.binary.RouteDataObject)1 AmenityRoutePoint (net.osmand.data.Amenity.AmenityRoutePoint)1 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)1 AlarmInfo (net.osmand.plus.routing.AlarmInfo)1