private void getGeoPosInternal(int pixelX, int pixelY, GeoPos geoPos) { if(pixelX >= 0 && pixelX < width && pixelY >= 0 && pixelY < height) { int i = pixelY*width + pixelX; if(lats[i] >= -90 && lats[i] <= 90 && lons[i] >= -180 && lons[i] <= 180) { geoPos.setLocation(lats[i], lons[i]); return; } } geoPos.setInvalid(); }
GeoApproximation getGeoPos(PixelPos p, GeoPos g) { GeoApproximation approximation = null; if (approximations != null) { if (g == null) { g = new GeoPos(); } if (p.isValid()) { approximation = GeoApproximation.findSuitable(approximations, p); if (approximation != null) { final double x = p.getX(); final double y = p.getY(); final Point2D q = new Point2D.Double(x, y); approximation.p2g(q); final double lon = q.getX(); final double lat = q.getY(); if (lon >= -180.0 && lon <= 180.0 && lat >= -90.0 && lat <= 90.0) { g.setLocation((float) lat, (float) lon); } else { g.setInvalid(); } } else { g.setInvalid(); } } else { g.setInvalid(); } } return approximation; }
/** * Returns the latitude and longitude value for a given pixel co-ordinate. * * @param pixelPos the pixel's co-ordinates given as x,y * @param geoPos an instance of <code>GeoPos</code> to be used as retun value. If this parameter is * <code>null</code>, the method creates a new instance which it then returns. * @return the geographical position as lat/lon in the coodinate system determined by {@link #getDatum()} */ public GeoPos getGeoPos(PixelPos pixelPos, GeoPos geoPos) { final int index = computeIndex(pixelPos); final GeoCoding gc = gcList.get(index); if (gc != null) { return gc.getGeoPos(new PixelPos(pixelPos.x, pixelPos.y - gcStripeSceneHeight * index), geoPos); } else { if (geoPos == null) { geoPos = new GeoPos(); } geoPos.setInvalid(); return geoPos; } }
/** * Returns the latitude and longitude value for a given pixel co-ordinate. * * @param pixelPos the pixel's co-ordinates given as x,y * @param geoPos an instance of <code>GeoPos</code> to be used as retun value. If this parameter is * <code>null</code>, the method creates a new instance which it then returns. * @return the geographical position as lat/lon in the coodinate system determined by {@link #getDatum()} */ public GeoPos getGeoPos(PixelPos pixelPos, GeoPos geoPos) { final int index = computeIndex(pixelPos); final GeoCoding gc = _gcList.get(index); if (gc != null) { return gc.getGeoPos(new PixelPos(pixelPos.x, pixelPos.y - getScanlineHeight() * index + getScanlineOffset()), geoPos); } else { if (geoPos == null) { geoPos = new GeoPos(); } geoPos.setInvalid(); return geoPos; } }
GeoPos geoPos2 = new GeoPos(); for(int y=0; y<height; y++) { geoPos1.setInvalid(); geoPos2.setInvalid(); for(int x=0; x<width/2; x++) { getGeoPosInternal(x, y, geoPos1);
@Override public GeoPos getGeoPos(PixelPos pixelPos, GeoPos geoPos) { if (geoPos == null) { geoPos = new GeoPos(); } try { DirectPosition directPixelPos = new DirectPosition2D(pixelPos); DirectPosition directGeoPos = imageToGeo.transform(directPixelPos, null); geoPos.setLocation((float) directGeoPos.getOrdinate(1), (float) directGeoPos.getOrdinate(0)); } catch (Exception ignored) { geoPos.setInvalid(); } return geoPos; }
/** * Returns the latitude and longitude value for a given pixel co-ordinate. * * @param pixelPos the pixel's co-ordinates given as x,y * @param geoPos an instance of <code>GeoPos</code> to be used as retun value. If this parameter is * <code>null</code>, the method creates a new instance which it then returns. * * @return the geographical position as lat/lon. */ @Override public GeoPos getGeoPos(final PixelPos pixelPos, GeoPos geoPos) { if (geoPos == null) { geoPos = new GeoPos(); } if (pixelPos.x < 0 || pixelPos.x > latGrid.getSceneRasterWidth() || pixelPos.y < 0 || pixelPos.y > latGrid.getSceneRasterHeight()) { geoPos.setInvalid(); } else { geoPos.lat = latGrid.getPixelFloat(pixelPos.x, pixelPos.y); geoPos.lon = lonGrid.getPixelFloat(pixelPos.x, pixelPos.y); } return geoPos; }
geoPos = new GeoPos(); geoPos.setInvalid(); if (pixelPos.isValid()) { int x0 = (int) Math.floor(pixelPos.getX());
geoCoding.getGeoPos(pixelPos, geoPos); } else { geoPos.setInvalid();
geoPos = new GeoPos(); geoPos.setInvalid(); if (pixelPos.isValid() && pixelPosIsInsideRasterWH(pixelPos)) { int x0 = (int) Math.floor(pixelPos.getX());
geoPos.setInvalid(); return geoPos;
public void testSetInvalid() { GeoPos geoPos = new GeoPos(); assertTrue(geoPos.isValid()); geoPos.setInvalid(); assertFalse(geoPos.isValid()); assertEquals("Inv N", geoPos.getLatString()); assertEquals("Inv E", geoPos.getLonString()); }