sed 's/m\(in\|ax\)\(X\|Y\)/\L\2m\1/g'
This commit is contained in:
parent
c48c620963
commit
52813ea29f
@ -35,10 +35,10 @@ public class QuadTreeTest {
|
|||||||
ArrayList<Item> items = new ArrayList<Item>(numItems + 16);
|
ArrayList<Item> items = new ArrayList<Item>(numItems + 16);
|
||||||
|
|
||||||
for (int i = 0; i < numItems; i++) {
|
for (int i = 0; i < numItems; i++) {
|
||||||
box.minX = (int) (rand.nextDouble() * 10000 - 5000);
|
box.xmin = (int) (rand.nextDouble() * 10000 - 5000);
|
||||||
box.minY = (int) (rand.nextDouble() * 10000 - 5000);
|
box.ymin = (int) (rand.nextDouble() * 10000 - 5000);
|
||||||
box.maxX = (int) (box.minX + rand.nextDouble() * 500);
|
box.xmax = (int) (box.xmin + rand.nextDouble() * 500);
|
||||||
box.maxY = (int) (box.minY + rand.nextDouble() * 500);
|
box.ymax = (int) (box.ymin + rand.nextDouble() * 500);
|
||||||
|
|
||||||
Item it = new Item(box, i);
|
Item it = new Item(box, i);
|
||||||
q.insert(box, it);
|
q.insert(box, it);
|
||||||
@ -77,8 +77,8 @@ public class QuadTreeTest {
|
|||||||
}, it);
|
}, it);
|
||||||
|
|
||||||
if (f == matched[0])
|
if (f == matched[0])
|
||||||
out.println((it.bbox.maxX - it.bbox.minX)
|
out.println((it.bbox.xmax - it.bbox.xmin)
|
||||||
+ " x " + (it.bbox.maxY - it.bbox.minY)
|
+ " x " + (it.bbox.ymax - it.bbox.ymin)
|
||||||
+ " ==> " + it);
|
+ " ==> " + it);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,8 +135,8 @@ public class QuadTreeTest {
|
|||||||
int cnt = numItems;
|
int cnt = numItems;
|
||||||
for (Item it : items) {
|
for (Item it : items) {
|
||||||
if (!q.remove(it.bbox, it)) {
|
if (!q.remove(it.bbox, it)) {
|
||||||
out.println((it.bbox.maxX - it.bbox.minX)
|
out.println((it.bbox.xmax - it.bbox.xmin)
|
||||||
+ " x " + (it.bbox.maxY - it.bbox.minY)
|
+ " x " + (it.bbox.ymax - it.bbox.ymin)
|
||||||
+ " ==> " + it);
|
+ " ==> " + it);
|
||||||
|
|
||||||
q.search(it.bbox, new SearchCb<Item>() {
|
q.search(it.bbox, new SearchCb<Item>() {
|
||||||
@ -160,8 +160,8 @@ public class QuadTreeTest {
|
|||||||
cnt = numItems;
|
cnt = numItems;
|
||||||
for (Item it : items) {
|
for (Item it : items) {
|
||||||
if (!q.remove(it.bbox, it))
|
if (!q.remove(it.bbox, it))
|
||||||
out.println((it.bbox.maxX - it.bbox.minX)
|
out.println((it.bbox.xmax - it.bbox.xmin)
|
||||||
+ " x " + (it.bbox.maxY - it.bbox.minY)
|
+ " x " + (it.bbox.ymax - it.bbox.ymin)
|
||||||
+ " => " + it);
|
+ " => " + it);
|
||||||
|
|
||||||
Assert.assertEquals(--cnt, q.size());
|
Assert.assertEquals(--cnt, q.size());
|
||||||
@ -208,8 +208,8 @@ public class QuadTreeTest {
|
|||||||
}
|
}
|
||||||
//Assert.assertEquals(cnt, found[0]);
|
//Assert.assertEquals(cnt, found[0]);
|
||||||
if (f == matched[0])
|
if (f == matched[0])
|
||||||
out.println((it.bbox.maxX - it.bbox.minX)
|
out.println((it.bbox.xmax - it.bbox.xmin)
|
||||||
+ " x " + (it.bbox.maxY - it.bbox.minY)
|
+ " x " + (it.bbox.ymax - it.bbox.ymin)
|
||||||
+ " ==> " + it);
|
+ " ==> " + it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,16 +22,16 @@ package org.oscim.core;
|
|||||||
public class Box {
|
public class Box {
|
||||||
|
|
||||||
/** The min x. */
|
/** The min x. */
|
||||||
public double minX;
|
public double xmin;
|
||||||
|
|
||||||
/** The max x. */
|
/** The max x. */
|
||||||
public double maxX;
|
public double xmax;
|
||||||
|
|
||||||
/** The min y. */
|
/** The min y. */
|
||||||
public double minY;
|
public double ymin;
|
||||||
|
|
||||||
/** The max y. */
|
/** The max y. */
|
||||||
public double maxY;
|
public double ymax;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new Box with all values being 0.
|
* Instantiates a new Box with all values being 0.
|
||||||
@ -43,23 +43,23 @@ public class Box {
|
|||||||
/**
|
/**
|
||||||
* Instantiates a new Box.
|
* Instantiates a new Box.
|
||||||
*
|
*
|
||||||
* @param minX the min x
|
* @param xmin the min x
|
||||||
* @param minY the min y
|
* @param ymin the min y
|
||||||
* @param maxX the max x
|
* @param xmax the max x
|
||||||
* @param maxY the max y
|
* @param ymax the max y
|
||||||
*/
|
*/
|
||||||
public Box(double minX, double minY, double maxX, double maxY) {
|
public Box(double xmin, double ymin, double xmax, double ymax) {
|
||||||
this.minX = minX;
|
this.xmin = xmin;
|
||||||
this.minY = minY;
|
this.ymin = ymin;
|
||||||
this.maxX = maxX;
|
this.xmax = xmax;
|
||||||
this.maxY = maxY;
|
this.ymax = ymax;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Box(Box bbox) {
|
public Box(Box bbox) {
|
||||||
this.minX = bbox.minX;
|
this.xmin = bbox.xmin;
|
||||||
this.minY = bbox.minY;
|
this.ymin = bbox.ymin;
|
||||||
this.maxX = bbox.maxX;
|
this.xmax = bbox.xmax;
|
||||||
this.maxY = bbox.maxY;
|
this.ymax = bbox.ymax;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,38 +70,38 @@ public class Box {
|
|||||||
* @return true, if point is inside box.
|
* @return true, if point is inside box.
|
||||||
*/
|
*/
|
||||||
public boolean contains(double x, double y) {
|
public boolean contains(double x, double y) {
|
||||||
return (x >= minX && x <= maxY && y >= minY && y <= maxY);
|
return (x >= xmin && x <= ymax && y >= ymin && y <= ymax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if Box contains Point.
|
* Check if Box contains Point.
|
||||||
*/
|
*/
|
||||||
public boolean contains(Point p) {
|
public boolean contains(Point p) {
|
||||||
return (p.x >= minX && p.x <= maxY && p.y >= minY && p.y <= maxY);
|
return (p.x >= xmin && p.x <= ymax && p.y >= ymin && p.y <= ymax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this Box is inside box.
|
* Check if this Box is inside box.
|
||||||
*/
|
*/
|
||||||
public boolean inside(Box box) {
|
public boolean inside(Box box) {
|
||||||
return minX >= box.minX && maxX <= box.maxX && minY >= box.minY && maxY <= box.maxY;
|
return xmin >= box.xmin && xmax <= box.xmax && ymin >= box.ymin && ymax <= box.ymax;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getWidth() {
|
public double getWidth() {
|
||||||
return maxX - minX;
|
return xmax - xmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getHeight() {
|
public double getHeight() {
|
||||||
return maxY - minY;
|
return ymax - ymin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean overlap(Box other) {
|
public boolean overlap(Box other) {
|
||||||
return !(minX > other.maxX || maxX < other.minX || minY > other.maxY || maxY < other.minY);
|
return !(xmin > other.xmax || xmax < other.xmin || ymin > other.ymax || ymax < other.ymin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[" + minX + ',' + minY + ',' + maxX + ',' + maxY + ']';
|
return "[" + xmin + ',' + ymin + ',' + xmax + ',' + ymax + ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ public class Animator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void animateFling(float velocityX, float velocityY,
|
public synchronized void animateFling(float velocityX, float velocityY,
|
||||||
int minX, int maxX, int minY, int maxY) {
|
int xmin, int xmax, int ymin, int ymax) {
|
||||||
|
|
||||||
if (velocityX * velocityX + velocityY * velocityY < 2048)
|
if (velocityX * velocityX + velocityY * velocityY < 2048)
|
||||||
return;
|
return;
|
||||||
@ -166,8 +166,8 @@ public class Animator {
|
|||||||
float flingFactor = 240 / CanvasAdapter.dpi;
|
float flingFactor = 240 / CanvasAdapter.dpi;
|
||||||
mVelocity.x = velocityX * flingFactor;
|
mVelocity.x = velocityX * flingFactor;
|
||||||
mVelocity.y = velocityY * flingFactor;
|
mVelocity.y = velocityY * flingFactor;
|
||||||
mVelocity.x = clamp(mVelocity.x, minX, maxX);
|
mVelocity.x = clamp(mVelocity.x, xmin, xmax);
|
||||||
mVelocity.y = clamp(mVelocity.y, minY, maxY);
|
mVelocity.y = clamp(mVelocity.y, ymin, ymax);
|
||||||
if (Double.isNaN(mVelocity.x) || Double.isNaN(mVelocity.y)) {
|
if (Double.isNaN(mVelocity.x) || Double.isNaN(mVelocity.y)) {
|
||||||
log.debug("fling NaN!");
|
log.debug("fling NaN!");
|
||||||
return;
|
return;
|
||||||
|
@ -196,10 +196,10 @@ public class Viewport {
|
|||||||
|
|
||||||
/* scale map-pixel coordinates at current scale to
|
/* scale map-pixel coordinates at current scale to
|
||||||
* absolute coordinates and apply mercator projection. */
|
* absolute coordinates and apply mercator projection. */
|
||||||
double minLon = MercatorProjection.toLongitude(mMapBBox.minX);
|
double minLon = MercatorProjection.toLongitude(mMapBBox.xmin);
|
||||||
double maxLon = MercatorProjection.toLongitude(mMapBBox.maxX);
|
double maxLon = MercatorProjection.toLongitude(mMapBBox.xmax);
|
||||||
double minLat = MercatorProjection.toLatitude(mMapBBox.maxY);
|
double minLat = MercatorProjection.toLatitude(mMapBBox.ymax);
|
||||||
double maxLat = MercatorProjection.toLatitude(mMapBBox.minY);
|
double maxLat = MercatorProjection.toLatitude(mMapBBox.ymin);
|
||||||
|
|
||||||
return new BoundingBox(minLat, minLon, maxLat, maxLon);
|
return new BoundingBox(minLat, minLon, maxLat, maxLon);
|
||||||
}
|
}
|
||||||
@ -211,22 +211,22 @@ public class Viewport {
|
|||||||
/**
|
/**
|
||||||
* 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:
|
||||||
* minX,minY,maxY,maxY
|
* xmin,ymin,ymax,ymax
|
||||||
*/
|
*/
|
||||||
public synchronized void getBBox(Box box, int expand) {
|
public synchronized void getBBox(Box box, int expand) {
|
||||||
float[] coords = mViewCoords;
|
float[] coords = mViewCoords;
|
||||||
getMapExtents(coords, expand);
|
getMapExtents(coords, expand);
|
||||||
|
|
||||||
box.minX = coords[0];
|
box.xmin = coords[0];
|
||||||
box.maxX = coords[0];
|
box.xmax = coords[0];
|
||||||
box.minY = coords[1];
|
box.ymin = coords[1];
|
||||||
box.maxY = coords[1];
|
box.ymax = coords[1];
|
||||||
|
|
||||||
for (int i = 2; i < 8; i += 2) {
|
for (int i = 2; i < 8; i += 2) {
|
||||||
box.minX = Math.min(box.minX, coords[i]);
|
box.xmin = Math.min(box.xmin, coords[i]);
|
||||||
box.maxX = Math.max(box.maxX, coords[i]);
|
box.xmax = Math.max(box.xmax, coords[i]);
|
||||||
box.minY = Math.min(box.minY, coords[i + 1]);
|
box.ymin = Math.min(box.ymin, coords[i + 1]);
|
||||||
box.maxY = Math.max(box.maxY, coords[i + 1]);
|
box.ymax = Math.max(box.ymax, coords[i + 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//updatePosition();
|
//updatePosition();
|
||||||
@ -234,10 +234,10 @@ public class Viewport {
|
|||||||
double cx = mPos.x * cs;
|
double cx = mPos.x * cs;
|
||||||
double cy = mPos.y * cs;
|
double cy = mPos.y * cs;
|
||||||
|
|
||||||
box.minX = (cx + box.minX) / cs;
|
box.xmin = (cx + box.xmin) / cs;
|
||||||
box.maxX = (cx + box.maxX) / cs;
|
box.xmax = (cx + box.xmax) / cs;
|
||||||
box.minY = (cy + box.minY) / cs;
|
box.ymin = (cy + box.ymin) / cs;
|
||||||
box.maxY = (cy + box.maxY) / cs;
|
box.ymax = (cy + box.ymax) / cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -730,27 +730,27 @@ public class MapDatabase implements ITileDataSource {
|
|||||||
|
|
||||||
//log.debug(numCols + "/" + numRows + " " + mCurrentCol + " " + mCurrentRow);
|
//log.debug(numCols + "/" + numRows + " " + mCurrentCol + " " + mCurrentRow);
|
||||||
if (numRows > 0) {
|
if (numRows > 0) {
|
||||||
int minX = -2;
|
int xmin = -2;
|
||||||
int minY = -2;
|
int ymin = -2;
|
||||||
int maxX = Tile.SIZE + 2;
|
int xmax = Tile.SIZE + 2;
|
||||||
int maxY = Tile.SIZE + 2;
|
int ymax = Tile.SIZE + 2;
|
||||||
|
|
||||||
int w = (int) (Tile.SIZE / (numCols + 1));
|
int w = (int) (Tile.SIZE / (numCols + 1));
|
||||||
int h = (int) (Tile.SIZE / (numRows + 1));
|
int h = (int) (Tile.SIZE / (numRows + 1));
|
||||||
|
|
||||||
if (mCurrentCol > 0)
|
if (mCurrentCol > 0)
|
||||||
minX = (int) (mCurrentCol * w);
|
xmin = (int) (mCurrentCol * w);
|
||||||
|
|
||||||
if (mCurrentCol < numCols)
|
if (mCurrentCol < numCols)
|
||||||
maxX = (int) (mCurrentCol * w + w);
|
xmax = (int) (mCurrentCol * w + w);
|
||||||
|
|
||||||
if (mCurrentRow > 0)
|
if (mCurrentRow > 0)
|
||||||
minY = (int) (mCurrentRow * h);
|
ymin = (int) (mCurrentRow * h);
|
||||||
|
|
||||||
if (mCurrentRow < numRows)
|
if (mCurrentRow < numRows)
|
||||||
maxY = (int) (mCurrentRow * h + h);
|
ymax = (int) (mCurrentRow * h + h);
|
||||||
//log.debug(minX + " " + minY + " " + maxX + " " + maxY);
|
//log.debug(xmin + " " + ymin + " " + xmax + " " + ymax);
|
||||||
mTileClipper.setRect(minX, minY, maxX, maxY);
|
mTileClipper.setRect(xmin, ymin, xmax, ymax);
|
||||||
} else {
|
} else {
|
||||||
mTileClipper.setRect(-2, -2, Tile.SIZE + 2, Tile.SIZE + 2);
|
mTileClipper.setRect(-2, -2, Tile.SIZE + 2, Tile.SIZE + 2);
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,10 @@ public class QuadTree<T> extends BoxTree<BoxItem<T>, T> implements SpatialIndex<
|
|||||||
|
|
||||||
private BoxItem<T> getBox(Box box) {
|
private BoxItem<T> getBox(Box box) {
|
||||||
BoxItem<T> it = boxPool.get();
|
BoxItem<T> it = boxPool.get();
|
||||||
it.x1 = (int) box.minX;
|
it.x1 = (int) box.xmin;
|
||||||
it.y1 = (int) box.minY;
|
it.y1 = (int) box.ymin;
|
||||||
it.x2 = (int) box.maxX;
|
it.x2 = (int) box.xmax;
|
||||||
it.y2 = (int) box.maxY;
|
it.y2 = (int) box.ymax;
|
||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,21 +129,21 @@ public class RTree<T> implements SpatialIndex<T>, Iterable<T> {
|
|||||||
static class Rect {
|
static class Rect {
|
||||||
|
|
||||||
/** dimensions of bounding box */
|
/** dimensions of bounding box */
|
||||||
double minX, minY, maxX, maxY;
|
double xmin, ymin, xmax, ymax;
|
||||||
|
|
||||||
public Rect() {
|
public Rect() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rect(Box box) {
|
public Rect(Box box) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
assert (minX <= maxX);
|
assert (xmin <= xmax);
|
||||||
assert (minY <= maxY);
|
assert (ymin <= ymax);
|
||||||
}
|
}
|
||||||
|
|
||||||
minX = box.minX;
|
xmin = box.xmin;
|
||||||
minY = box.minY;
|
ymin = box.ymin;
|
||||||
maxX = box.maxX;
|
xmax = box.xmax;
|
||||||
maxY = box.maxY;
|
ymax = box.ymax;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rect(double[] min, double[] max) {
|
public Rect(double[] min, double[] max) {
|
||||||
@ -153,48 +153,48 @@ public class RTree<T> implements SpatialIndex<T>, Iterable<T> {
|
|||||||
assert (min[index] <= max[index]);
|
assert (min[index] <= max[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
minX = min[0];
|
xmin = min[0];
|
||||||
minY = min[1];
|
ymin = min[1];
|
||||||
maxX = max[0];
|
xmax = max[0];
|
||||||
maxY = max[1];
|
ymax = max[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the n-dimensional volume of a rectangle
|
* Calculate the n-dimensional volume of a rectangle
|
||||||
*/
|
*/
|
||||||
public double calcRectVolume() {
|
public double calcRectVolume() {
|
||||||
return (maxX - minX) * (maxY - minY);
|
return (xmax - xmin) * (ymax - ymin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decide whether two rectangles overlap.
|
* Decide whether two rectangles overlap.
|
||||||
*/
|
*/
|
||||||
public boolean overlap(Rect other) {
|
public boolean overlap(Rect other) {
|
||||||
return !(minX > other.maxX || maxX < other.minX || minY > other.maxY || maxY < other.minY);
|
return !(xmin > other.xmax || xmax < other.xmin || ymin > other.ymax || ymax < other.ymin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Combine two rectangles into larger one containing both
|
* Combine two rectangles into larger one containing both
|
||||||
*/
|
*/
|
||||||
public void combine(Rect rectA, Rect rectB) {
|
public void combine(Rect rectA, Rect rectB) {
|
||||||
minX = Math.min(rectA.minX, rectB.minX);
|
xmin = Math.min(rectA.xmin, rectB.xmin);
|
||||||
minY = Math.min(rectA.minY, rectB.minY);
|
ymin = Math.min(rectA.ymin, rectB.ymin);
|
||||||
maxX = Math.max(rectA.maxX, rectB.maxX);
|
xmax = Math.max(rectA.xmax, rectB.xmax);
|
||||||
maxY = Math.max(rectA.maxY, rectB.maxY);
|
ymax = Math.max(rectA.ymax, rectB.ymax);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(Rect rect) {
|
public void add(Rect rect) {
|
||||||
minX = Math.min(minX, rect.minX);
|
xmin = Math.min(xmin, rect.xmin);
|
||||||
minY = Math.min(minY, rect.minY);
|
ymin = Math.min(ymin, rect.ymin);
|
||||||
maxX = Math.max(maxX, rect.maxX);
|
xmax = Math.max(xmax, rect.xmax);
|
||||||
maxY = Math.max(maxY, rect.maxY);
|
ymax = Math.max(ymax, rect.ymax);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(Rect rect) {
|
public void set(Rect rect) {
|
||||||
minX = rect.minX;
|
xmin = rect.xmin;
|
||||||
minY = rect.minY;
|
ymin = rect.ymin;
|
||||||
maxX = rect.maxX;
|
xmax = rect.xmax;
|
||||||
maxY = rect.maxY;
|
ymax = rect.ymax;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(double[] min, double[] max) {
|
public void set(double[] min, double[] max) {
|
||||||
@ -204,21 +204,21 @@ public class RTree<T> implements SpatialIndex<T>, Iterable<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
minX = min[0];
|
xmin = min[0];
|
||||||
minY = min[1];
|
ymin = min[1];
|
||||||
maxX = max[0];
|
xmax = max[0];
|
||||||
maxY = max[1];
|
ymax = max[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(Box box) {
|
public void set(Box box) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
assert (box.minX <= box.maxX);
|
assert (box.xmin <= box.xmax);
|
||||||
assert (box.minY <= box.maxY);
|
assert (box.ymin <= box.ymax);
|
||||||
}
|
}
|
||||||
minX = box.minX;
|
xmin = box.xmin;
|
||||||
minY = box.minY;
|
ymin = box.ymin;
|
||||||
maxX = box.maxX;
|
xmax = box.xmax;
|
||||||
maxY = box.maxY;
|
ymax = box.ymax;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -486,8 +486,8 @@ public class RTree<T> implements SpatialIndex<T>, Iterable<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final static double mergedArea(Rect a, Rect b) {
|
final static double mergedArea(Rect a, Rect b) {
|
||||||
return ((a.maxX > b.maxX ? a.maxX : b.maxX) - (a.minX < b.minX ? a.minX : b.minX)
|
return ((a.xmax > b.xmax ? a.xmax : b.xmax) - (a.xmin < b.xmin ? a.xmin : b.xmin)
|
||||||
* ((a.maxY > b.maxY ? a.maxY : b.maxY) - (a.minY < b.minY ? a.minY : b.minY)));
|
* ((a.ymax > b.ymax ? a.ymax : b.ymax) - (a.ymin < b.ymin ? a.ymin : b.ymin)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1290,7 +1290,7 @@ class Partition {
|
|||||||
// /** dimensions of bounding box */
|
// /** dimensions of bounding box */
|
||||||
// double bounds[] = new double[NUMDIMS * 2];
|
// double bounds[] = new double[NUMDIMS * 2];
|
||||||
//
|
//
|
||||||
// //double minX, minY, maxX, maxY;
|
// //double xmin, ymin, xmax, ymax;
|
||||||
//
|
//
|
||||||
// public Rect() {
|
// public Rect() {
|
||||||
// }
|
// }
|
||||||
|
@ -84,7 +84,7 @@ public abstract class ScanBox {
|
|||||||
private Edge bc = new Edge();
|
private Edge bc = new Edge();
|
||||||
private Edge ca = new Edge();
|
private Edge ca = new Edge();
|
||||||
|
|
||||||
private int minX, maxX;
|
private int xmin, xmax;
|
||||||
|
|
||||||
protected int mZoom;
|
protected int mZoom;
|
||||||
|
|
||||||
@ -113,8 +113,8 @@ public abstract class ScanBox {
|
|||||||
if (min == max)
|
if (min == max)
|
||||||
max++;
|
max++;
|
||||||
|
|
||||||
minX = (int) min;
|
xmin = (int) min;
|
||||||
maxX = (int) max;
|
xmax = (int) max;
|
||||||
|
|
||||||
// top-left -> top-right
|
// top-left -> top-right
|
||||||
ab.set(box[0], box[1], box[2], box[3]);
|
ab.set(box[0], box[1], box[2], box[3]);
|
||||||
@ -210,11 +210,11 @@ public abstract class ScanBox {
|
|||||||
|
|
||||||
int x1 = (int) Math.floor(e1.x0 + m1 * dy);
|
int x1 = (int) Math.floor(e1.x0 + m1 * dy);
|
||||||
|
|
||||||
if (x1 < minX)
|
if (x1 < xmin)
|
||||||
x1 = minX;
|
x1 = xmin;
|
||||||
|
|
||||||
if (x0 > maxX)
|
if (x0 > xmax)
|
||||||
x0 = maxX;
|
x0 = xmax;
|
||||||
|
|
||||||
if (x1 < x0)
|
if (x1 < x0)
|
||||||
setVisible(y, x1, x0);
|
setVisible(y, x1, x0);
|
||||||
|
@ -26,25 +26,25 @@ import org.oscim.core.GeometryBuffer;
|
|||||||
* based on http://www.cs.rit.edu/~icss571/clipTrans/PolyClipBack.html
|
* based on http://www.cs.rit.edu/~icss571/clipTrans/PolyClipBack.html
|
||||||
*/
|
*/
|
||||||
public class TileClipper {
|
public class TileClipper {
|
||||||
private float minX;
|
private float xmin;
|
||||||
private float maxX;
|
private float xmax;
|
||||||
private float minY;
|
private float ymin;
|
||||||
private float maxY;
|
private float ymax;
|
||||||
|
|
||||||
public TileClipper(float minX, float minY, float maxX, float maxY) {
|
public TileClipper(float xmin, float ymin, float xmax, float ymax) {
|
||||||
this.minX = minX;
|
this.xmin = xmin;
|
||||||
this.minY = minY;
|
this.ymin = ymin;
|
||||||
this.maxX = maxX;
|
this.xmax = xmax;
|
||||||
this.maxY = maxY;
|
this.ymax = ymax;
|
||||||
mLineClipper = new LineClipper(minX, minY, maxX, maxY);
|
mLineClipper = new LineClipper(xmin, ymin, xmax, ymax);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRect(float minX, float minY, float maxX, float maxY) {
|
public void setRect(float xmin, float ymin, float xmax, float ymax) {
|
||||||
this.minX = minX;
|
this.xmin = xmin;
|
||||||
this.minY = minY;
|
this.ymin = ymin;
|
||||||
this.maxX = maxX;
|
this.xmax = xmax;
|
||||||
this.maxY = maxY;
|
this.ymax = ymax;
|
||||||
mLineClipper.setRect(minX, minY, maxX, maxY);
|
mLineClipper.setRect(xmin, ymin, xmax, ymax);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final LineClipper mLineClipper;
|
private final LineClipper mLineClipper;
|
||||||
@ -157,20 +157,20 @@ public class TileClipper {
|
|||||||
for (int i = pointPos; i < end;) {
|
for (int i = pointPos; i < end;) {
|
||||||
float cx = in.points[i++];
|
float cx = in.points[i++];
|
||||||
float cy = in.points[i++];
|
float cy = in.points[i++];
|
||||||
if (cx > minX) {
|
if (cx > xmin) {
|
||||||
/* current is inside */
|
/* current is inside */
|
||||||
if (px > minX) {
|
if (px > xmin) {
|
||||||
/* previous was inside */
|
/* previous was inside */
|
||||||
out.addPoint(cx, cy);
|
out.addPoint(cx, cy);
|
||||||
} else {
|
} else {
|
||||||
/* previous was outside, add edge point */
|
/* previous was outside, add edge point */
|
||||||
out.addPoint(minX, py + (cy - py) * (minX - px) / (cx - px));
|
out.addPoint(xmin, py + (cy - py) * (xmin - px) / (cx - px));
|
||||||
out.addPoint(cx, cy);
|
out.addPoint(cx, cy);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (px > minX) {
|
if (px > xmin) {
|
||||||
/* previous was inside, add edge point */
|
/* previous was inside, add edge point */
|
||||||
out.addPoint(minX, py + (cy - py) * (minX - px) / (cx - px));
|
out.addPoint(xmin, py + (cy - py) * (xmin - px) / (cx - px));
|
||||||
}
|
}
|
||||||
/* else skip point */
|
/* else skip point */
|
||||||
}
|
}
|
||||||
@ -188,16 +188,16 @@ public class TileClipper {
|
|||||||
float cx = in.points[i++];
|
float cx = in.points[i++];
|
||||||
float cy = in.points[i++];
|
float cy = in.points[i++];
|
||||||
|
|
||||||
if (cx < maxX) {
|
if (cx < xmax) {
|
||||||
if (px < maxX) {
|
if (px < xmax) {
|
||||||
out.addPoint(cx, cy);
|
out.addPoint(cx, cy);
|
||||||
} else {
|
} else {
|
||||||
out.addPoint(maxX, py + (cy - py) * (maxX - px) / (cx - px));
|
out.addPoint(xmax, py + (cy - py) * (xmax - px) / (cx - px));
|
||||||
out.addPoint(cx, cy);
|
out.addPoint(cx, cy);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (px < maxX) {
|
if (px < xmax) {
|
||||||
out.addPoint(maxX, py + (cy - py) * (maxX - px) / (cx - px));
|
out.addPoint(xmax, py + (cy - py) * (xmax - px) / (cx - px));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
px = cx;
|
px = cx;
|
||||||
@ -214,16 +214,16 @@ public class TileClipper {
|
|||||||
float cx = in.points[i++];
|
float cx = in.points[i++];
|
||||||
float cy = in.points[i++];
|
float cy = in.points[i++];
|
||||||
|
|
||||||
if (cy < maxY) {
|
if (cy < ymax) {
|
||||||
if (py < maxY) {
|
if (py < ymax) {
|
||||||
out.addPoint(cx, cy);
|
out.addPoint(cx, cy);
|
||||||
} else {
|
} else {
|
||||||
out.addPoint(px + (cx - px) * (maxY - py) / (cy - py), maxY);
|
out.addPoint(px + (cx - px) * (ymax - py) / (cy - py), ymax);
|
||||||
out.addPoint(cx, cy);
|
out.addPoint(cx, cy);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (py < maxY) {
|
if (py < ymax) {
|
||||||
out.addPoint(px + (cx - px) * (maxY - py) / (cy - py), maxY);
|
out.addPoint(px + (cx - px) * (ymax - py) / (cy - py), ymax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
px = cx;
|
px = cx;
|
||||||
@ -239,16 +239,16 @@ public class TileClipper {
|
|||||||
for (int i = pointPos; i < len;) {
|
for (int i = pointPos; i < len;) {
|
||||||
float cx = in.points[i++];
|
float cx = in.points[i++];
|
||||||
float cy = in.points[i++];
|
float cy = in.points[i++];
|
||||||
if (cy > minY) {
|
if (cy > ymin) {
|
||||||
if (py > minY) {
|
if (py > ymin) {
|
||||||
out.addPoint(cx, cy);
|
out.addPoint(cx, cy);
|
||||||
} else {
|
} else {
|
||||||
out.addPoint(px + (cx - px) * (minY - py) / (cy - py), minY);
|
out.addPoint(px + (cx - px) * (ymin - py) / (cy - py), ymin);
|
||||||
out.addPoint(cx, cy);
|
out.addPoint(cx, cy);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (py > minY) {
|
if (py > ymin) {
|
||||||
out.addPoint(px + (cx - px) * (minY - py) / (cy - py), minY);
|
out.addPoint(px + (cx - px) * (ymin - py) / (cy - py), ymin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
px = cx;
|
px = cx;
|
||||||
|
@ -92,10 +92,10 @@ public class BoxTree<T extends BoxItem<E>, E> extends TileIndex<BoxNode<T>, T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BoxItem(org.oscim.core.Box box, T item) {
|
public BoxItem(org.oscim.core.Box box, T item) {
|
||||||
this.x1 = (int) box.minX;
|
this.x1 = (int) box.xmin;
|
||||||
this.y1 = (int) box.minY;
|
this.y1 = (int) box.ymin;
|
||||||
this.x2 = (int) box.maxX;
|
this.x2 = (int) box.xmax;
|
||||||
this.y2 = (int) box.maxY;
|
this.y2 = (int) box.ymax;
|
||||||
this.item = item;
|
this.item = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user