Overzoom: separate GeometryType.POINT (#574)
This commit is contained in:
parent
da09a62605
commit
6fa1c5aa94
@ -46,7 +46,7 @@ class OverzoomDataSink implements ITileDataSink {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(MapElement element) {
|
public void process(MapElement element) {
|
||||||
if (element.isBuilding() || element.isBuildingPart()) {
|
if (element.isBuilding() || element.isBuildingPart() || element.isPoint()) {
|
||||||
if (!separator.separate(element))
|
if (!separator.separate(element))
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -16,8 +16,13 @@
|
|||||||
package org.oscim.utils.geom;
|
package org.oscim.utils.geom;
|
||||||
|
|
||||||
import org.oscim.core.GeometryBuffer;
|
import org.oscim.core.GeometryBuffer;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class TileSeparator {
|
public class TileSeparator {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(TileSeparator.class);
|
||||||
|
|
||||||
private float xmin;
|
private float xmin;
|
||||||
private float xmax;
|
private float xmax;
|
||||||
private float ymin;
|
private float ymin;
|
||||||
@ -30,6 +35,10 @@ public class TileSeparator {
|
|||||||
this.ymax = ymax;
|
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) {
|
public void setRect(float xmin, float ymin, float xmax, float ymax) {
|
||||||
this.xmin = xmin;
|
this.xmin = xmin;
|
||||||
this.ymin = ymin;
|
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
|
* @param geom the geometry to be separated
|
||||||
* @return true if geometry is inside the tile, false otherwise
|
* @return true if geometry is inside the tile, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean separate(GeometryBuffer geom) {
|
public boolean separate(GeometryBuffer geom) {
|
||||||
if (!geom.isPoly())
|
if (geom.isPoint()) {
|
||||||
return false;
|
if (geom.index.length > 1 && geom.index[0] == 2) {
|
||||||
|
float cx = geom.points[0];
|
||||||
|
float cy = geom.points[1];
|
||||||
|
|
||||||
int pointPos = 0;
|
if (isInside(cx, cy))
|
||||||
|
|
||||||
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 */
|
|
||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user