Overzoom: separate GeometryType.POINT (#574)
This commit is contained in:
parent
da09a62605
commit
6fa1c5aa94
@ -46,7 +46,7 @@ class OverzoomDataSink implements ITileDataSink {
|
||||
|
||||
@Override
|
||||
public void process(MapElement element) {
|
||||
if (element.isBuilding() || element.isBuildingPart()) {
|
||||
if (element.isBuilding() || element.isBuildingPart() || element.isPoint()) {
|
||||
if (!separator.separate(element))
|
||||
return;
|
||||
} else {
|
||||
|
@ -16,8 +16,13 @@
|
||||
package org.oscim.utils.geom;
|
||||
|
||||
import org.oscim.core.GeometryBuffer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TileSeparator {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(TileSeparator.class);
|
||||
|
||||
private float xmin;
|
||||
private float xmax;
|
||||
private float ymin;
|
||||
@ -30,6 +35,10 @@ public class TileSeparator {
|
||||
this.ymax = ymax;
|
||||
}
|
||||
|
||||
private boolean isInside(float cx, float cy) {
|
||||
return cx >= xmin && cx < xmax && cy >= ymin && cy < ymax;
|
||||
}
|
||||
|
||||
public void setRect(float xmin, float ymin, float xmax, float ymax) {
|
||||
this.xmin = xmin;
|
||||
this.ymin = ymin;
|
||||
@ -38,42 +47,47 @@ public class TileSeparator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Separates a poly geometry from tile (doesn't clip it).
|
||||
* Separates geometry from tile without clipping it. Points and polys only.
|
||||
*
|
||||
* @param geom the geometry to be separated
|
||||
* @return true if geometry is inside the tile, false otherwise
|
||||
*/
|
||||
public boolean separate(GeometryBuffer geom) {
|
||||
if (!geom.isPoly())
|
||||
return false;
|
||||
if (geom.isPoint()) {
|
||||
if (geom.index.length > 1 && geom.index[0] == 2) {
|
||||
float cx = geom.points[0];
|
||||
float cy = geom.points[1];
|
||||
|
||||
int pointPos = 0;
|
||||
|
||||
for (int indexPos = 0, n = geom.index.length; indexPos < n; indexPos++) {
|
||||
int len = geom.index[indexPos];
|
||||
if (len < 0)
|
||||
break;
|
||||
|
||||
if (len < 6) {
|
||||
pointPos += len;
|
||||
continue;
|
||||
}
|
||||
|
||||
int end = pointPos + len;
|
||||
|
||||
for (int i = pointPos; i < end; ) {
|
||||
float cx = geom.points[i++];
|
||||
float cy = geom.points[i++];
|
||||
|
||||
if (cx >= xmin && cx < xmax && cy >= ymin && cy < ymax) {
|
||||
/* current is inside */
|
||||
if (isInside(cx, cy))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else
|
||||
log.warn("Geometry (Point) has wrong format: " + geom.toString());
|
||||
} else if (geom.isPoly()) {
|
||||
int pointPos = 0;
|
||||
|
||||
pointPos += len;
|
||||
for (int indexPos = 0, n = geom.index.length; indexPos < n; indexPos++) {
|
||||
int len = geom.index[indexPos];
|
||||
if (len < 0)
|
||||
break;
|
||||
|
||||
if (len < 6) {
|
||||
pointPos += len;
|
||||
continue;
|
||||
}
|
||||
|
||||
int end = pointPos + len;
|
||||
|
||||
for (int i = pointPos; i < end; ) {
|
||||
float cx = geom.points[i++];
|
||||
float cy = geom.points[i++];
|
||||
|
||||
if (isInside(cx, cy))
|
||||
return true;
|
||||
}
|
||||
|
||||
pointPos += len;
|
||||
}
|
||||
}
|
||||
geom.clear();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user