From 6739195793b5464d2b742c8e28c39e92fbc32de6 Mon Sep 17 00:00:00 2001 From: Max Schenkelberg Date: Tue, 29 May 2012 15:15:05 -0500 Subject: [PATCH] Issue #665 fixed bug with lat/lon vs pixel space for inspect Change-Id: I038f9fec306e81725932ed5a17db885d251fed73 Former-commit-id: 71fe0a468ada934dbb4838baa01c6e3c30136731 [formerly 1934bfa28c001e94a0661e14332dd6144929f561] [formerly 71fe0a468ada934dbb4838baa01c6e3c30136731 [formerly 1934bfa28c001e94a0661e14332dd6144929f561] [formerly 76e99b4037f6d4a00d2928b6c9379cd45bd5554a [formerly 2be9620b338140fa27efba037d0cc321558bec62]]] Former-commit-id: 76e99b4037f6d4a00d2928b6c9379cd45bd5554a Former-commit-id: 4c65ff8c2031bfc819e46b89825960eac35b4d3a [formerly 8f377d3fb8f1421086cc74048d225108d11aedd1] Former-commit-id: 01a1c143491e36832674a197c03d67fe6ffe1ec7 --- .../viz/mpe/ui/rsc/MPEGageResource.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java index f13a4175c3..2e79a7355e 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java @@ -451,18 +451,17 @@ public class MPEGageResource extends AbstractMPEInputResource { for (ListIterator it = gages.listIterator(); it .hasNext();) { MPEGageData gageData = it.next(); - Coordinate xy = gageData.getLatLon(); - double[] pixel = descriptor.worldToPixel(new double[] { xy.x, - xy.y }); - xy = new Coordinate(pixel[0], pixel[1]); - dataMap.put(xy, gageData); + Coordinate latLon = gageData.getLatLon(); + double[] pixel = descriptor.worldToPixel(new double[] { + latLon.x, latLon.y }); + dataMap.put(new Coordinate(pixel[0], pixel[1]), gageData); /* Create a small envelope around the point */ - Coordinate p1 = new Coordinate(xy.x + 10, xy.y + 10); - Coordinate p2 = new Coordinate(xy.x - 10, xy.y - 10); + Coordinate p1 = new Coordinate(latLon.x + .05, latLon.y + .05); + Coordinate p2 = new Coordinate(latLon.x - .05, latLon.y - .05); Envelope env = new Envelope(p1, p2); ArrayList data = new ArrayList(); - data.add(xy); + data.add(latLon); data.add("GAGE: " + gageData.getId() + " VALUE: " + gageData.getGval()); strTree.insert(env, data); @@ -562,7 +561,7 @@ public class MPEGageResource extends AbstractMPEInputResource { protected boolean handleMouseUp(int x, int y, int mouseButton) { if (mouseButton == 1) { Coordinate coord = getResourceContainer().translateClick(x, y); - double maxdist = 99999; + double mindist = Double.MAX_VALUE; double testdist; MPEGageData bestData = null; // Find closest gage... @@ -573,8 +572,8 @@ public class MPEGageResource extends AbstractMPEInputResource { testdist = Math.pow((coord.x - lon), 2) + Math.pow((coord.y - lat), 2); testdist = Math.pow(testdist, .5); - if (testdist < maxdist) { - maxdist = testdist; + if (testdist < mindist) { + mindist = testdist; bestData = data; } }