Update bbox
This commit is contained in:
parent
26596e3957
commit
2d9c367960
1 changed files with 41 additions and 0 deletions
|
@ -156,6 +156,45 @@ public class OsmandRegions {
|
|||
return t % 2 == 1;
|
||||
}
|
||||
|
||||
public boolean intersect(BinaryMapDataObject bo, int lx, int ty, int rx, int by) {
|
||||
int t = 0;
|
||||
// 1. polygon in object
|
||||
if(contain(bo, lx, ty)) {
|
||||
return true;
|
||||
}
|
||||
// 2. object in polygon
|
||||
if(bo.getPointsLength() == 0) {
|
||||
return false;
|
||||
}
|
||||
if(bo.getPoint31XTile(0) >= lx && bo.getPoint31XTile(0) <= rx &&
|
||||
bo.getPoint31YTile(0) >= ty && bo.getPoint31YTile(0) <= by ){
|
||||
return true;
|
||||
}
|
||||
|
||||
// 3. find intersection
|
||||
for (int i = 1; i < bo.getPointsLength(); i++) {
|
||||
int px = bo.getPoint31XTile(i - 1);
|
||||
int x = bo.getPoint31XTile(i);
|
||||
int py = bo.getPoint31YTile(i - 1);
|
||||
int y = bo.getPoint31YTile(i);
|
||||
if(x < lx && px < lx) {
|
||||
continue;
|
||||
} else if(x > rx && px > rx) {
|
||||
continue;
|
||||
} else if(y > by && py > by) {
|
||||
continue;
|
||||
} else if(y < ty && py < ty) {
|
||||
continue;
|
||||
}
|
||||
long in = MapAlgorithms.calculateIntersection(px, py, x, y, lx, rx, by, ty);
|
||||
if(in != -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<BinaryMapDataObject> getCountries(int tile31x, int tile31y) {
|
||||
HashSet<String> set = new HashSet<String>(quadTree.queryInBox(new QuadRect(tile31x, tile31y, tile31x, tile31y),
|
||||
new ArrayList<String>()));
|
||||
|
@ -485,4 +524,6 @@ public class OsmandRegions {
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue