Commit ef413298 authored by Riegel's avatar Riegel
Browse files

Feature: Add 2D WKT representation for bbox

parent b50c5f13
...@@ -161,4 +161,29 @@ public class BoundingBox { ...@@ -161,4 +161,29 @@ public class BoundingBox {
public double getDiagonalLength() { public double getDiagonalLength() {
return bbox[1].getDistance(bbox[0]); return bbox[1].getDistance(bbox[0]);
} }
/**
* Returns a WKT polygon representation in 2D (the "shadow") of this bbox
*
* @return WKT String of this bbox's shadow
*/
public String toWktShadow() {
double x1 = bbox[0].getX();
double y1 = bbox[0].getY();
double x2 = x1 + bbox[1].getX();
double y2 = y1 + bbox[1].getY();
double minX = Math.min(x1, x2);
double minY = Math.min(y1, y2);
double maxX = Math.max(x1, x2);
double maxY = Math.max(y1, y2);
return String.format("POLYGON((%.3f %.3f, %.3f %.3f, %.3f %.3f, %.3f %.3f, %.3f %.3f))",
minX, minY,
maxX, minY,
maxX, maxY,
minX, maxY,
minX, minY
);
}
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment