vtm-core: supplement Box (#609)
This commit is contained in:
parent
357ec99b44
commit
20352f2053
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 Hannes Janetzek
|
* Copyright 2013 Hannes Janetzek
|
||||||
|
* Copyright 2018 Gustl22
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
*
|
*
|
||||||
@ -33,6 +34,17 @@ public class Box {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple box instantiation (for adding extents).
|
||||||
|
*
|
||||||
|
* @param x the initial x value
|
||||||
|
* @param y the initial y value
|
||||||
|
*/
|
||||||
|
public Box(double x, double y) {
|
||||||
|
this.xmax = this.xmin = x;
|
||||||
|
this.ymax = this.ymin = y;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new Box.
|
* Instantiates a new Box.
|
||||||
*
|
*
|
||||||
@ -50,6 +62,9 @@ public class Box {
|
|||||||
this.ymax = ymax;
|
this.ymax = ymax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
public Box(Box bbox) {
|
public Box(Box bbox) {
|
||||||
this.xmin = bbox.xmin;
|
this.xmin = bbox.xmin;
|
||||||
this.ymin = bbox.ymin;
|
this.ymin = bbox.ymin;
|
||||||
@ -129,7 +144,7 @@ public class Box {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* convrt map coordinates to lat/lon.
|
* Convert map coordinates to lat/lon.
|
||||||
*/
|
*/
|
||||||
public void map2mercator() {
|
public void map2mercator() {
|
||||||
double minLon = MercatorProjection.toLongitude(xmin);
|
double minLon = MercatorProjection.toLongitude(xmin);
|
||||||
@ -156,12 +171,27 @@ public class Box {
|
|||||||
ymax *= d;
|
ymax *= d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init or overwrite extents of box.
|
||||||
|
*
|
||||||
|
* @param points the points to extend to
|
||||||
|
*/
|
||||||
public void setExtents(float[] points) {
|
public void setExtents(float[] points) {
|
||||||
|
setExtents(points, points.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init or overwrite extents of box.
|
||||||
|
*
|
||||||
|
* @param points the points to extend to
|
||||||
|
* @param length the number of considered points
|
||||||
|
*/
|
||||||
|
public void setExtents(float[] points, int length) {
|
||||||
float x1, y1, x2, y2;
|
float x1, y1, x2, y2;
|
||||||
x1 = x2 = points[0];
|
x1 = x2 = points[0];
|
||||||
y1 = y2 = points[1];
|
y1 = y2 = points[1];
|
||||||
|
|
||||||
for (int i = 2, n = points.length; i < n; i += 2) {
|
for (int i = 2; i < length; i += 2) {
|
||||||
float x = points[i];
|
float x = points[i];
|
||||||
if (x < x1)
|
if (x < x1)
|
||||||
x1 = x;
|
x1 = x;
|
||||||
|
@ -112,7 +112,7 @@ public class S3DBLayer extends BuildingLayer {
|
|||||||
float p1 = element.points[k];
|
float p1 = element.points[k];
|
||||||
float p2 = element.points[k + 1];
|
float p2 = element.points[k + 1];
|
||||||
if (bb == null)
|
if (bb == null)
|
||||||
bb = new Box(p1, p2, p1, p2);
|
bb = new Box(p1, p2);
|
||||||
else {
|
else {
|
||||||
bb.add(p1, p2);
|
bb.add(p1, p2);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user