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(" , ");
}
}
}
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;
}
};
}
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;
}
}
}
Aggregations