diff --git a/vtm/src/org/oscim/core/Box.java b/vtm/src/org/oscim/core/Box.java index 08c16836..b089eef0 100644 --- a/vtm/src/org/oscim/core/Box.java +++ b/vtm/src/org/oscim/core/Box.java @@ -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; diff --git a/vtm/src/org/oscim/layers/tile/buildings/S3DBLayer.java b/vtm/src/org/oscim/layers/tile/buildings/S3DBLayer.java index 93b0cee5..77ed8959 100644 --- a/vtm/src/org/oscim/layers/tile/buildings/S3DBLayer.java +++ b/vtm/src/org/oscim/layers/tile/buildings/S3DBLayer.java @@ -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); }