vtm-core: supplement Box (#609)

This commit is contained in:
Gustl22 2018-12-09 21:27:10 +01:00 committed by Emux
parent 357ec99b44
commit 20352f2053
No known key found for this signature in database
GPG Key ID: 64ED9980896038C3
2 changed files with 33 additions and 3 deletions

View File

@ -1,5 +1,6 @@
/*
* Copyright 2013 Hannes Janetzek
* Copyright 2018 Gustl22
*
* 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.
*
@ -50,6 +62,9 @@ public class Box {
this.ymax = ymax;
}
/**
* Copy constructor.
*/
public Box(Box bbox) {
this.xmin = bbox.xmin;
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() {
double minLon = MercatorProjection.toLongitude(xmin);
@ -156,12 +171,27 @@ public class Box {
ymax *= d;
}
/**
* Init or overwrite extents of box.
*
* @param points the points to extend to
*/
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;
x1 = x2 = points[0];
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];
if (x < x1)
x1 = x;

View File

@ -112,7 +112,7 @@ public class S3DBLayer extends BuildingLayer {
float p1 = element.points[k];
float p2 = element.points[k + 1];
if (bb == null)
bb = new Box(p1, p2, p1, p2);
bb = new Box(p1, p2);
else {
bb.add(p1, p2);
}