Viewport: remove BoundingBox utility function
This commit is contained in:
parent
1ea26e576e
commit
3402308ced
@ -21,7 +21,7 @@ package org.oscim.layers.marker;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.oscim.core.BoundingBox;
|
import org.oscim.core.Box;
|
||||||
import org.oscim.core.Point;
|
import org.oscim.core.Point;
|
||||||
import org.oscim.event.Gesture;
|
import org.oscim.event.Gesture;
|
||||||
import org.oscim.event.GestureListener;
|
import org.oscim.event.GestureListener;
|
||||||
@ -167,7 +167,9 @@ public class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer<Item>
|
|||||||
int eventY = (int) event.getY() - mMap.getHeight() / 2;
|
int eventY = (int) event.getY() - mMap.getHeight() / 2;
|
||||||
Viewport mapPosition = mMap.viewport();
|
Viewport mapPosition = mMap.viewport();
|
||||||
|
|
||||||
BoundingBox bbox = mapPosition.getBBox(128);
|
Box box = mapPosition.getBBox(null, 128);
|
||||||
|
box.map2mercator();
|
||||||
|
box.scale(1E6);
|
||||||
|
|
||||||
int nearest = -1;
|
int nearest = -1;
|
||||||
int inside = -1;
|
int inside = -1;
|
||||||
@ -179,7 +181,8 @@ public class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer<Item>
|
|||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
Item item = mItemList.get(i);
|
Item item = mItemList.get(i);
|
||||||
|
|
||||||
if (!bbox.contains(item.geoPoint))
|
if (!box.contains(item.geoPoint.longitudeE6,
|
||||||
|
item.geoPoint.latitudeE6))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mapPosition.toScreenPoint(item.getPoint(), mTmpPoint);
|
mapPosition.toScreenPoint(item.getPoint(), mTmpPoint);
|
||||||
|
@ -87,8 +87,8 @@ public abstract class AbstractVectorLayer<T> extends Layer implements UpdateList
|
|||||||
Viewport v = mMap.viewport();
|
Viewport v = mMap.viewport();
|
||||||
BoundingBox bbox;
|
BoundingBox bbox;
|
||||||
synchronized (v) {
|
synchronized (v) {
|
||||||
bbox = v.getBBox();
|
bbox = v.getBBox(null, 0);
|
||||||
v.getMapPosition(t.position);
|
mMap.getMapPosition(t.position);
|
||||||
}
|
}
|
||||||
|
|
||||||
double scale = t.position.scale * Tile.SIZE;
|
double scale = t.position.scale * Tile.SIZE;
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.oscim.map;
|
package org.oscim.map;
|
||||||
|
|
||||||
import org.oscim.core.BoundingBox;
|
|
||||||
import org.oscim.core.Box;
|
import org.oscim.core.Box;
|
||||||
import org.oscim.core.GeoPoint;
|
import org.oscim.core.GeoPoint;
|
||||||
import org.oscim.core.MapPosition;
|
import org.oscim.core.MapPosition;
|
||||||
@ -25,6 +24,8 @@ import org.oscim.core.Point;
|
|||||||
import org.oscim.core.Tile;
|
import org.oscim.core.Tile;
|
||||||
import org.oscim.renderer.GLMatrix;
|
import org.oscim.renderer.GLMatrix;
|
||||||
import org.oscim.utils.FastMath;
|
import org.oscim.utils.FastMath;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Viewport class contains a MapPosition and the projection matrices.
|
* The Viewport class contains a MapPosition and the projection matrices.
|
||||||
@ -34,7 +35,8 @@ import org.oscim.utils.FastMath;
|
|||||||
* Public methods are thread safe.
|
* Public methods are thread safe.
|
||||||
*/
|
*/
|
||||||
public class Viewport {
|
public class Viewport {
|
||||||
//static final Logger log = LoggerFactory.getLogger(Viewport.class);
|
|
||||||
|
static final Logger log = LoggerFactory.getLogger(Viewport.class);
|
||||||
|
|
||||||
private final static int MAX_ZOOMLEVEL = 20;
|
private final static int MAX_ZOOMLEVEL = 20;
|
||||||
private final static int MIN_ZOOMLEVEL = 2;
|
private final static int MIN_ZOOMLEVEL = 2;
|
||||||
@ -72,8 +74,6 @@ public class Viewport {
|
|||||||
protected final float[] mu = new float[4];
|
protected final float[] mu = new float[4];
|
||||||
protected final float[] mViewCoords = new float[8];
|
protected final float[] mViewCoords = new float[8];
|
||||||
|
|
||||||
protected final Box mMapBBox = new Box();
|
|
||||||
|
|
||||||
protected float mHeight, mWidth;
|
protected float mHeight, mWidth;
|
||||||
|
|
||||||
public final static float VIEW_DISTANCE = 3.0f;
|
public final static float VIEW_DISTANCE = 3.0f;
|
||||||
@ -237,35 +237,15 @@ public class Viewport {
|
|||||||
coords[position + 1] = (float) (ny + dist * dy);
|
coords[position + 1] = (float) (ny + dist * dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the minimal axis-aligned BoundingBox that encloses
|
|
||||||
* the visible part of the map.
|
|
||||||
*
|
|
||||||
* @return BoundingBox containing view
|
|
||||||
*/
|
|
||||||
public synchronized BoundingBox getBBox(int expand) {
|
|
||||||
getBBox(mMapBBox, expand);
|
|
||||||
|
|
||||||
/* scale map-pixel coordinates at current scale to
|
|
||||||
* absolute coordinates and apply mercator projection. */
|
|
||||||
double minLon = MercatorProjection.toLongitude(mMapBBox.xmin);
|
|
||||||
double maxLon = MercatorProjection.toLongitude(mMapBBox.xmax);
|
|
||||||
double minLat = MercatorProjection.toLatitude(mMapBBox.ymax);
|
|
||||||
double maxLat = MercatorProjection.toLatitude(mMapBBox.ymin);
|
|
||||||
|
|
||||||
return new BoundingBox(minLat, minLon, maxLat, maxLon);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized BoundingBox getBBox() {
|
|
||||||
return getBBox(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the minimal axis-aligned BoundingBox that encloses
|
* Get the minimal axis-aligned BoundingBox that encloses
|
||||||
* the visible part of the map. Sets box to map coordinates:
|
* the visible part of the map. Sets box to map coordinates:
|
||||||
* xmin,ymin,ymax,ymax
|
* xmin,ymin,xmax,ymax
|
||||||
*/
|
*/
|
||||||
public synchronized void getBBox(Box box, int expand) {
|
public Box getBBox(Box box, int expand) {
|
||||||
|
if (box == null)
|
||||||
|
box = new Box();
|
||||||
|
|
||||||
float[] coords = mViewCoords;
|
float[] coords = mViewCoords;
|
||||||
getMapExtents(coords, expand);
|
getMapExtents(coords, expand);
|
||||||
|
|
||||||
@ -281,7 +261,6 @@ public class Viewport {
|
|||||||
box.ymax = Math.max(box.ymax, coords[i + 1]);
|
box.ymax = Math.max(box.ymax, coords[i + 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//updatePosition();
|
|
||||||
double cs = mPos.scale * Tile.SIZE;
|
double cs = mPos.scale * Tile.SIZE;
|
||||||
double cx = mPos.x * cs;
|
double cx = mPos.x * cs;
|
||||||
double cy = mPos.y * cs;
|
double cy = mPos.y * cs;
|
||||||
@ -290,6 +269,8 @@ public class Viewport {
|
|||||||
box.xmax = (cx + box.xmax) / cs;
|
box.xmax = (cx + box.xmax) / cs;
|
||||||
box.ymin = (cy + box.ymin) / cs;
|
box.ymin = (cy + box.ymin) / cs;
|
||||||
box.ymax = (cy + box.ymax) / cs;
|
box.ymax = (cy + box.ymax) / cs;
|
||||||
|
|
||||||
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user