From c3fea5750db406d7c6602c802ae05b1986ed8f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Galland?= Date: Thu, 23 Nov 2017 17:58:58 +0100 Subject: [PATCH] [giscore] Bounding of a MapPolyline is too big when it is a wide polyline. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bounding box of a polyline is expanded with 2 times the width of the polyline. It should be one time. This commit fixes this issue. Signed-off-by: Stéphane Galland --- .../java/org/arakhne/afc/gis/mapelement/MapPolyline.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapPolyline.java b/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapPolyline.java index 61c922103..205be75b1 100644 --- a/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapPolyline.java +++ b/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapPolyline.java @@ -637,14 +637,14 @@ public final void toPath2D(Path2d path, double startPosition, double endPosition @Pure protected Rectangle2d calcBounds() { final Rectangle2d bounds = super.calcBounds().toBoundingBox(); - if (bounds != null && this.isWidePolyline) { + if (bounds != null && isWidePolyline()) { final double w = getWidth(); final double mx = bounds.getMinX(); final double my = bounds.getMinY(); final double xx = bounds.getMaxX(); final double xy = bounds.getMaxY(); - bounds.add(mx - w, my - w); - bounds.add(xx + w, xy + w); + final double dw = w / 2.; + bounds.setFromCorners(mx - dw, my - dw, xx + dw, xy + dw); } return bounds; }