Issue #665 fixed bug with lat/lon vs pixel space for inspect

Change-Id: I038f9fec306e81725932ed5a17db885d251fed73

Former-commit-id: 1934bfa28c [formerly 1934bfa28c [formerly 2be9620b338140fa27efba037d0cc321558bec62]]
Former-commit-id: 76e99b4037
Former-commit-id: 8f377d3fb8
This commit is contained in:
Max Schenkelberg 2012-05-29 15:15:05 -05:00
parent e3ad085501
commit 01a1c14349

View file

@ -451,18 +451,17 @@ public class MPEGageResource extends AbstractMPEInputResource {
for (ListIterator<MPEGageData> it = gages.listIterator(); it for (ListIterator<MPEGageData> it = gages.listIterator(); it
.hasNext();) { .hasNext();) {
MPEGageData gageData = it.next(); MPEGageData gageData = it.next();
Coordinate xy = gageData.getLatLon(); Coordinate latLon = gageData.getLatLon();
double[] pixel = descriptor.worldToPixel(new double[] { xy.x, double[] pixel = descriptor.worldToPixel(new double[] {
xy.y }); latLon.x, latLon.y });
xy = new Coordinate(pixel[0], pixel[1]); dataMap.put(new Coordinate(pixel[0], pixel[1]), gageData);
dataMap.put(xy, gageData);
/* Create a small envelope around the point */ /* Create a small envelope around the point */
Coordinate p1 = new Coordinate(xy.x + 10, xy.y + 10); Coordinate p1 = new Coordinate(latLon.x + .05, latLon.y + .05);
Coordinate p2 = new Coordinate(xy.x - 10, xy.y - 10); Coordinate p2 = new Coordinate(latLon.x - .05, latLon.y - .05);
Envelope env = new Envelope(p1, p2); Envelope env = new Envelope(p1, p2);
ArrayList<Object> data = new ArrayList<Object>(); ArrayList<Object> data = new ArrayList<Object>();
data.add(xy); data.add(latLon);
data.add("GAGE: " + gageData.getId() + " VALUE: " data.add("GAGE: " + gageData.getId() + " VALUE: "
+ gageData.getGval()); + gageData.getGval());
strTree.insert(env, data); strTree.insert(env, data);
@ -562,7 +561,7 @@ public class MPEGageResource extends AbstractMPEInputResource {
protected boolean handleMouseUp(int x, int y, int mouseButton) { protected boolean handleMouseUp(int x, int y, int mouseButton) {
if (mouseButton == 1) { if (mouseButton == 1) {
Coordinate coord = getResourceContainer().translateClick(x, y); Coordinate coord = getResourceContainer().translateClick(x, y);
double maxdist = 99999; double mindist = Double.MAX_VALUE;
double testdist; double testdist;
MPEGageData bestData = null; MPEGageData bestData = null;
// Find closest gage... // Find closest gage...
@ -573,8 +572,8 @@ public class MPEGageResource extends AbstractMPEInputResource {
testdist = Math.pow((coord.x - lon), 2) testdist = Math.pow((coord.x - lon), 2)
+ Math.pow((coord.y - lat), 2); + Math.pow((coord.y - lat), 2);
testdist = Math.pow(testdist, .5); testdist = Math.pow(testdist, .5);
if (testdist < maxdist) { if (testdist < mindist) {
maxdist = testdist; mindist = testdist;
bestData = data; bestData = data;
} }
} }