Search in sources :

Example 11 with TagValuePair

use of net.osmand.binary.BinaryMapIndexReader.TagValuePair in project Osmand by osmandapp.

the class BinaryInspector method printMapDetails.

public static void printMapDetails(BinaryMapDataObject obj, StringBuilder b, boolean vmapCoordinates) {
    boolean multipolygon = obj.getPolygonInnerCoordinates() != null && obj.getPolygonInnerCoordinates().length > 0;
    if (multipolygon) {
        b.append("Multipolygon");
    } else {
        b.append(obj.area ? "Area" : (obj.getPointsLength() > 1 ? "Way" : "Point"));
    }
    int[] types = obj.getTypes();
    b.append(" types [");
    for (int j = 0; j < types.length; j++) {
        if (j > 0) {
            b.append(", ");
        }
        TagValuePair pair = obj.getMapIndex().decodeType(types[j]);
        if (pair == null) {
            System.err.println("Type " + types[j] + "was not found");
            continue;
        // throw new NullPointerException("Type " + obj.getAdditionalTypes()[j] + "was not found");
        }
        b.append(pair.toSimpleString() + " (" + types[j] + ")");
    }
    b.append("]");
    if (obj.getAdditionalTypes() != null && obj.getAdditionalTypes().length > 0) {
        b.append(" add_types [");
        for (int j = 0; j < obj.getAdditionalTypes().length; j++) {
            if (j > 0) {
                b.append(", ");
            }
            TagValuePair pair = obj.getMapIndex().decodeType(obj.getAdditionalTypes()[j]);
            if (pair == null) {
                System.err.println("Type " + obj.getAdditionalTypes()[j] + "was not found");
                continue;
            // throw new NullPointerException("Type " + obj.getAdditionalTypes()[j] + "was not found");
            }
            b.append(pair.toSimpleString() + "(" + obj.getAdditionalTypes()[j] + ")");
        }
        b.append("]");
    }
    TIntObjectHashMap<String> names = obj.getObjectNames();
    TIntArrayList order = obj.getNamesOrder();
    if (names != null && !names.isEmpty()) {
        b.append(" Names [");
        // int[] keys = names.keys();
        for (int j = 0; j < order.size(); j++) {
            if (j > 0) {
                b.append(", ");
            }
            TagValuePair pair = obj.getMapIndex().decodeType(order.get(j));
            if (pair == null) {
                throw new NullPointerException("Type " + order.get(j) + "was not found");
            }
            b.append(pair.toSimpleString() + "(" + order.get(j) + ")");
            b.append(" - ").append(names.get(order.get(j)));
        }
        b.append("]");
    }
    b.append(" id ").append(obj.getId());
    b.append(" osmid ").append((obj.getId() >> (SHIFT_ID + 1)));
    if (vmapCoordinates) {
        b.append(" lat/lon : ");
        for (int i = 0; i < obj.getPointsLength(); i++) {
            float x = (float) MapUtils.get31LongitudeX(obj.getPoint31XTile(i));
            float y = (float) MapUtils.get31LatitudeY(obj.getPoint31YTile(i));
            b.append(y).append(" / ").append(x).append(" , ");
        }
    }
}
Also used : TagValuePair(net.osmand.binary.BinaryMapIndexReader.TagValuePair) TIntArrayList(gnu.trove.list.array.TIntArrayList)

Example 12 with TagValuePair

use of net.osmand.binary.BinaryMapIndexReader.TagValuePair in project Osmand by osmandapp.

the class RenderingRuleProperty method createAdditionalStringProperty.

public static RenderingRuleProperty createAdditionalStringProperty(String name) {
    return new RenderingRuleProperty(name, STRING_TYPE, true) {

        @Override
        public boolean accept(int ruleValue, int renderingProperty, RenderingRuleSearchRequest req) {
            BinaryMapDataObject obj = req.getObject();
            String val = req.getStorage().getStringValue(ruleValue);
            if (obj == null) {
                int vl = req.getIntPropertyValue(this);
                if (vl == -1) {
                    return false;
                }
                String val2 = req.getStorage().getStringValue(vl);
                return val != null && val.equals(val2);
            }
            int k = val.indexOf('=');
            if (k != -1) {
                String ts = val.substring(0, k);
                String vs = val.substring(k + 1);
                Integer ruleInd = req.getObject().getMapIndex().getRule(ts, vs);
                if (ruleInd != null) {
                    if (req.getObject().containsAdditionalType(ruleInd)) {
                        return true;
                    }
                }
            } else {
                String ts = val;
                int[] additionalTypes = obj.getAdditionalTypes();
                for (int i = 0; i < additionalTypes.length; i++) {
                    TagValuePair vp = obj.getMapIndex().decodeType(additionalTypes[i]);
                    if (vp != null && ts.equals(vp.tag)) {
                        return true;
                    }
                }
            }
            return false;
        }
    };
}
Also used : BinaryMapDataObject(net.osmand.binary.BinaryMapDataObject) TagValuePair(net.osmand.binary.BinaryMapIndexReader.TagValuePair)

Example 13 with TagValuePair

use of net.osmand.binary.BinaryMapIndexReader.TagValuePair in project Osmand by osmandapp.

the class OsmandRenderer method drawObject.

void drawObject(RenderingContext rc, Canvas cv, RenderingRuleSearchRequest req, List<MapDataObjectPrimitive> array, int objOrder) {
    // double polygonLimit = 100;
    // float orderToSwitch = 0;
    double minPolygonSize = 1. / rc.polygonMinSizeToDisplay;
    for (int i = 0; i < array.size(); i++) {
        rc.allObjects++;
        BinaryMapDataObject mObj = array.get(i).obj;
        TagValuePair pair = mObj.getMapIndex().decodeType(mObj.getTypes()[array.get(i).typeInd]);
        if (array.get(i).objectType == 3) {
            if (array.get(i).order > minPolygonSize + ((int) array.get(i).order)) {
                continue;
            }
            // polygon
            drawPolygon(mObj, req, cv, rc, pair, array.get(i).area);
        } else if (array.get(i).objectType == 2) {
            drawPolyline(mObj, req, cv, rc, pair, mObj.getSimpleLayer(), objOrder == 1);
        } else if (array.get(i).objectType == 1) {
            drawPoint(mObj, req, cv, rc, pair, array.get(i).typeInd == 0);
        }
        if (i % 25 == 0 && rc.interrupted) {
            return;
        }
    }
}
Also used : BinaryMapDataObject(net.osmand.binary.BinaryMapDataObject) TagValuePair(net.osmand.binary.BinaryMapIndexReader.TagValuePair) Paint(android.graphics.Paint)

Aggregations

TagValuePair (net.osmand.binary.BinaryMapIndexReader.TagValuePair)13 BinaryMapDataObject (net.osmand.binary.BinaryMapDataObject)8 TIntArrayList (gnu.trove.list.array.TIntArrayList)4 ArrayList (java.util.ArrayList)4 Paint (android.graphics.Paint)3 IOException (java.io.IOException)3 MapIndex (net.osmand.binary.BinaryMapIndexReader.MapIndex)3 TLongArrayList (gnu.trove.list.array.TLongArrayList)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 ResultMatcher (net.osmand.ResultMatcher)2 BinaryMapIndexReader (net.osmand.binary.BinaryMapIndexReader)2 OsmandRegions (net.osmand.map.OsmandRegions)2 WorldRegion (net.osmand.map.WorldRegion)2 IndexItem (net.osmand.plus.download.IndexItem)2 SpannableString (android.text.SpannableString)1 TextPaint (android.text.TextPaint)1 TLongIterator (gnu.trove.iterator.TLongIterator)1 TIntHashSet (gnu.trove.set.hash.TIntHashSet)1 File (java.io.File)1