Fix rendering issue for sports and other polygons

This commit is contained in:
Victor Shcherb 2012-05-27 14:03:53 +02:00
parent 88488dc600
commit e50e1fec6d
7 changed files with 46 additions and 62 deletions

View file

@ -46,18 +46,9 @@ public class BinaryInspector {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
inspector(args); inspector(args);
// test cases show info // test cases show info
// inspector(new String[]{"/home/victor/projects/OsmAnd/data/osm-gen/Luxembourg.obf"}); inspector(new String[]{"-vmap", "/home/victor/projects/OsmAnd/data/osm-gen/Map.obf"});
// test case extract parts // test case extract parts
// inspector(new String[]{"-c", "E:\\Information\\OSM maps\\osmand\\Netherlands-addr-trans.map.obf",
// "E:\\Information\\OSM maps\\osmand\\Netherlands.map.obf", "-1"});
// test case // test case
// inspector(new String[]{"-c", "E:\\Information\\OSM maps\\osmand\\Netherlands-addr-trans.map.obf",
// "E:\\Information\\OSM maps\\osmand\\Netherlands.map.obf", "-1",
// "E:\\Information\\OSM maps\\osmand\\Belarus_4.map.obf", "E:\\Information\\OSM maps\\osmand\\Minsk.map.obf"});
// inspector(new String[]{"E:\\Information\\OSM maps\\osmand\\Netherlands-addr-trans.map.obf"});
} }
private static void println(String s) { private static void println(String s) {

View file

@ -45,13 +45,6 @@ public class BinaryMapDataObject {
return name; return name;
} }
public int getObjectType() {
return objectType;
}
public void setObjectType(int objectType) {
this.objectType = objectType;
}
public TIntObjectHashMap<String> getObjectNames() { public TIntObjectHashMap<String> getObjectNames() {
return objectNames; return objectNames;

View file

@ -76,6 +76,7 @@
<!-- input layer check tag, value, point, cycle, area --> <!-- input layer check tag, value, point, cycle, area -->
<!-- Order should be between 0 and 255 (integer) -->
<!-- output ! objectType point = 1, line = 2, polygon = 3 and order --> <!-- output ! objectType point = 1, line = 2, polygon = 3 and order -->
<order> <order>
<!-- point has order 128 --> <!-- point has order 128 -->
@ -83,6 +84,8 @@
<!-- default polygon --> <!-- default polygon -->
<filter cycle="true" layer="-1" tag="" value="" order="3" objectType="3"/> <filter cycle="true" layer="-1" tag="" value="" order="3" objectType="3"/>
<filter area="true" layer="-1" tag="" value="" order="3" objectType="3"/> <filter area="true" layer="-1" tag="" value="" order="3" objectType="3"/>
<filter cycle="true" tag="" value="" order="3" objectType="7"/>
<filter area="true" tag="" value="" order="3" objectType="7"/>
<!-- default line --> <!-- default line -->
<filter layer="-1" tag="" value="" order="10" objectType="2"/> <filter layer="-1" tag="" value="" order="10" objectType="2"/>
<filter tag="" value="" order="11" objectType="2"/> <filter tag="" value="" order="11" objectType="2"/>

View file

@ -355,42 +355,42 @@ public class MapRenderRepositories {
boolean ocean = false; boolean ocean = false;
MapIndex mi = null; MapIndex mi = null;
searchRequest = BinaryMapIndexReader.buildSearchRequest(leftX, rightX, topY, bottomY, zoom, searchFilter); searchRequest = BinaryMapIndexReader.buildSearchRequest(leftX, rightX, topY, bottomY, zoom, searchFilter);
for (BinaryMapIndexReader c : files.values()) { for (BinaryMapIndexReader c : files.values()) {
searchRequest.clearSearchResults(); searchRequest.clearSearchResults();
List<BinaryMapDataObject> res = c.searchMapIndex(searchRequest); List<BinaryMapDataObject> res = c.searchMapIndex(searchRequest);
for (BinaryMapDataObject r : res) { for (BinaryMapDataObject r : res) {
if (PerformanceFlags.checkForDuplicateObjectIds) { if (PerformanceFlags.checkForDuplicateObjectIds) {
if (ids.contains(r.getId()) && r.getId() > 0) { if (ids.contains(r.getId()) && r.getId() > 0) {
// do not add object twice // do not add object twice
continue; continue;
}
ids.add(r.getId());
} }
count++; ids.add(r.getId());
}
count++;
if (r.containsType(r.getMapIndex().coastlineEncodingType)) { if (r.containsType(r.getMapIndex().coastlineEncodingType)) {
if(c.isBasemap()){ if (c.isBasemap()) {
basemapCoastLines.add(r); basemapCoastLines.add(r);
} else {
coastLines.add(r);
}
} else { } else {
// do not mess coastline and other types coastLines.add(r);
if(c.isBasemap()){
basemapResult.add(r);
} else {
tempResult.add(r);
}
} }
if (checkWhetherInterrupted()) { } else {
return false; // do not mess coastline and other types
if (c.isBasemap()) {
basemapResult.add(r);
} else {
tempResult.add(r);
} }
} }
if (checkWhetherInterrupted()) {
if(searchRequest.isOcean() ){ return false;
}
}
if (searchRequest.isOcean()) {
mi = c.getMapIndexes().get(0); mi = c.getMapIndexes().get(0);
ocean = true; ocean = true;
} else if(searchRequest.isLand()) { } else if (searchRequest.isLand()) {
mi = c.getMapIndexes().get(0); mi = c.getMapIndexes().get(0);
} }
} }

View file

@ -217,9 +217,9 @@ public class OsmandRenderer {
boolean shadowDrawn = false; boolean shadowDrawn = false;
for (int k = 0; k < keys.length; k++) { for (int k = 0; k < keys.length; k++) {
if (!shadowDrawn && keys[k] >= rc.shadowLevelMin && keys[k] <= rc.shadowLevelMax && rc.shadowRenderingMode > 1) { if (!shadowDrawn && (keys[k]>>2) >= rc.shadowLevelMin && (keys[k]>>2) <= rc.shadowLevelMax && rc.shadowRenderingMode > 1) {
for (int ki = k; ki < keys.length; ki++) { for (int ki = k; ki < keys.length; ki++) {
if (keys[ki] > rc.shadowLevelMax || rc.interrupted) { if ((keys[ki]>>2) > rc.shadowLevelMax || rc.interrupted) {
break; break;
} }
TIntArrayList list = orderMap.get(keys[ki]); TIntArrayList list = orderMap.get(keys[ki]);
@ -230,7 +230,7 @@ public class OsmandRenderer {
BinaryMapDataObject obj = objects.get(ind); BinaryMapDataObject obj = objects.get(ind);
// show text only for main type // show text only for main type
drawObj(obj, render, cv, rc, l, l == 0, true); drawObj(obj, render, cv, rc, l, l == 0, true, (keys[ki] & 3));
objCount++; objCount++;
} }
} }
@ -248,10 +248,10 @@ public class OsmandRenderer {
BinaryMapDataObject obj = objects.get(ind); BinaryMapDataObject obj = objects.get(ind);
// show text only for main type // show text only for main type
drawObj(obj, render, cv, rc, l, l == 0, false); drawObj(obj, render, cv, rc, l, l == 0, false, (keys[k] & 3));
objCount++; objCount++;
} }
rc.lastRenderedKey = keys[k]; rc.lastRenderedKey = (keys[k] >> 2);
if (objCount > 25) { if (objCount > 25) {
notifyListeners(notifyList); notifyListeners(notifyList);
objCount = 0; objCount = 0;
@ -359,9 +359,9 @@ public class OsmandRenderer {
render.setBooleanFilter(render.ALL.R_POINT, o.getPointsLength() == 1); render.setBooleanFilter(render.ALL.R_POINT, o.getPointsLength() == 1);
render.setBooleanFilter(render.ALL.R_CYCLE, o.isCycle()); render.setBooleanFilter(render.ALL.R_CYCLE, o.isCycle());
if (render.search(RenderingRulesStorage.ORDER_RULES)) { if (render.search(RenderingRulesStorage.ORDER_RULES)) {
o.setObjectType(render.getIntPropertyValue(render.ALL.R_OBJECT_TYPE)); int objectType = render.getIntPropertyValue(render.ALL.R_OBJECT_TYPE);
int order = render.getIntPropertyValue(render.ALL.R_ORDER); int order = render.getIntPropertyValue(render.ALL.R_ORDER);
put(orderMap, order, sh + j, init); put(orderMap, (order << 2) | objectType, sh + j, init);
if (render.isSpecified(render.ALL.R_SHADOW_LEVEL)) { if (render.isSpecified(render.ALL.R_SHADOW_LEVEL)) {
rc.shadowLevelMin = Math.min(rc.shadowLevelMin, order); rc.shadowLevelMin = Math.min(rc.shadowLevelMin, order);
rc.shadowLevelMax = Math.max(rc.shadowLevelMax, order); rc.shadowLevelMax = Math.max(rc.shadowLevelMax, order);
@ -388,9 +388,8 @@ public class OsmandRenderer {
} }
protected void drawObj(BinaryMapDataObject obj, RenderingRuleSearchRequest render, Canvas canvas, RenderingContext rc, int l, protected void drawObj(BinaryMapDataObject obj, RenderingRuleSearchRequest render, Canvas canvas, RenderingContext rc, int l,
boolean renderText, boolean drawOnlyShadow) { boolean renderText, boolean drawOnlyShadow, int type) {
rc.allObjects++; rc.allObjects++;
int type = obj.getObjectType();
TagValuePair pair = obj.getMapIndex().decodeType(obj.getTypes()[l]); TagValuePair pair = obj.getMapIndex().decodeType(obj.getTypes()[l]);
if (type == MapRenderingTypes.POINT_TYPE && !drawOnlyShadow) { if (type == MapRenderingTypes.POINT_TYPE && !drawOnlyShadow) {
drawPoint(obj, render, canvas, rc, pair, renderText); drawPoint(obj, render, canvas, rc, pair, renderText);

View file

@ -19,7 +19,6 @@ public:
std::vector<tag_value> types; std::vector<tag_value> types;
std::vector<tag_value> additionalTypes; std::vector<tag_value> additionalTypes;
int objectType;
coordinates points; coordinates points;
std::vector < coordinates > polygonInnerCoordinates; std::vector < coordinates > polygonInnerCoordinates;

View file

@ -438,9 +438,8 @@ void drawPoint(MapDataObject* mObj, RenderingRuleSearchRequest* req, SkCanvas* c
} }
void drawObject(RenderingContext* rc, MapDataObject* mObj, SkCanvas* cv, RenderingRuleSearchRequest* req, void drawObject(RenderingContext* rc, MapDataObject* mObj, SkCanvas* cv, RenderingRuleSearchRequest* req,
SkPaint* paint, int l, int renderText, int drawOnlyShadow) { SkPaint* paint, int l, int renderText, int drawOnlyShadow, int t) {
rc->allObjects++; rc->allObjects++;
int t = mObj->objectType;
tag_value pair = mObj->types.at(l); tag_value pair = mObj->types.at(l);
if (t == 1 && !drawOnlyShadow) { if (t == 1 && !drawOnlyShadow) {
// point // point
@ -514,9 +513,9 @@ HMAP::hash_map<int, std::vector<int> > sortObjectsByProperOrder(std::vector <Map
req->setIntFilter(req->props()->R_POINT, mobj->points.size() == 1); req->setIntFilter(req->props()->R_POINT, mobj->points.size() == 1);
req->setIntFilter(req->props()->R_CYCLE, mobj->cycle()); req->setIntFilter(req->props()->R_CYCLE, mobj->cycle());
if (req->searchRule(RenderingRulesStorage::ORDER_RULES)) { if (req->searchRule(RenderingRulesStorage::ORDER_RULES)) {
mobj->objectType = req->getIntPropertyValue(req->props()->R_OBJECT_TYPE); int objectType = req->getIntPropertyValue(req->props()->R_OBJECT_TYPE);
int order = req->getIntPropertyValue(req->props()->R_ORDER); int order = req->getIntPropertyValue(req->props()->R_ORDER);
orderMap[order].push_back(sh + j); orderMap[(order << 2)|objectType].push_back(sh + j);
if (req->getIntPropertyValue(req->props()->R_SHADOW_LEVEL) > 0) { if (req->getIntPropertyValue(req->props()->R_SHADOW_LEVEL) > 0) {
rc->shadowLevelMin = std::min(rc->shadowLevelMin, order); rc->shadowLevelMin = std::min(rc->shadowLevelMin, order);
rc->shadowLevelMax = std::max(rc->shadowLevelMax, order); rc->shadowLevelMax = std::max(rc->shadowLevelMax, order);
@ -548,9 +547,9 @@ void doRendering(std::vector <MapDataObject* > mapDataObjects, SkCanvas* canvas,
} }
bool shadowDrawn = false; bool shadowDrawn = false;
for (std::set<int>::iterator ks = keys.begin(); ks != keys.end(); ks++) { for (std::set<int>::iterator ks = keys.begin(); ks != keys.end(); ks++) {
if (!shadowDrawn && *ks >= rc->shadowLevelMin && *ks <= rc->shadowLevelMax && rc->getShadowRenderingMode() > 1) { if (!shadowDrawn && ((*ks)>>2) >= rc->shadowLevelMin && ((*ks)>>2) <= rc->shadowLevelMax && rc->getShadowRenderingMode() > 1) {
for (std::set<int>::iterator ki = ks; ki != keys.end(); ki++) { for (std::set<int>::iterator ki = ks; ki != keys.end(); ki++) {
if (*ki > rc->shadowLevelMax || rc->interrupted()) { if (((*ki)>>2) > rc->shadowLevelMax || rc->interrupted()) {
break; break;
} }
std::vector<int> list = orderMap[*ki]; std::vector<int> list = orderMap[*ki];
@ -562,7 +561,7 @@ void doRendering(std::vector <MapDataObject* > mapDataObjects, SkCanvas* canvas,
// show text only for main type // show text only for main type
drawObject(rc, mapObject, canvas, req, paint, l, l == 0, true); drawObject(rc, mapObject, canvas, req, paint, l, l == 0, true, (*ki)&3);
} }
} }
shadowDrawn = true; shadowDrawn = true;
@ -576,9 +575,9 @@ void doRendering(std::vector <MapDataObject* > mapDataObjects, SkCanvas* canvas,
MapDataObject* mapObject = mapDataObjects.at(ind); MapDataObject* mapObject = mapDataObjects.at(ind);
// show text only for main type // show text only for main type
drawObject(rc, mapObject, canvas, req, paint, l, l == 0, false); drawObject(rc, mapObject, canvas, req, paint, l, l == 0, false, (*ks)&3);
} }
rc->lastRenderedKey = *ks; rc->lastRenderedKey = (*ks) >>2;
if (rc->interrupted()) { if (rc->interrupted()) {
return; return;
} }