/** * Tests whether or not all given geo-positions are valid. * * @return true, if so */ public static boolean areValid(GeoPos[] gepPositions) { for (GeoPos geoPos : gepPositions) { if (!geoPos.isValid()) { return false; } } return true; }
private static Placemark[] getValidGcps(ProductNodeGroup<Placemark> gcpGroup) { final List<Placemark> gcpList = new ArrayList<Placemark>(gcpGroup.getNodeCount()); for (int i = 0; i < gcpGroup.getNodeCount(); i++) { final Placemark p = gcpGroup.get(i); final PixelPos pixelPos = p.getPixelPos(); final GeoPos geoPos = p.getGeoPos(); if (pixelPos != null && pixelPos.isValid() && geoPos != null && geoPos.isValid()) { gcpList.add(p); } } return gcpList.toArray(new Placemark[gcpList.size()]); }
private static boolean isValid(Placemark p) { final PixelPos pixelPos = p.getPixelPos(); final GeoPos geoPos = p.getGeoPos(); return pixelPos != null && pixelPos.isValid() && geoPos != null && geoPos.isValid(); }
@Override public PixelPos getPixelPos(final GeoPos geoPos, PixelPos pixelPos) { if (pixelPos == null) { pixelPos = new PixelPos(); } pixelPos.setInvalid(); if (geoPos.isValid()) { getPixelPosUsingQuadTreeSearch(geoPos, pixelPos); } return pixelPos; }
public void testIsInvalid() { assertTrue(new GeoPos(+90, +180).isValid()); assertTrue(new GeoPos(+90, 0).isValid()); assertTrue(new GeoPos(+90, -180).isValid()); assertTrue(new GeoPos(0, +180).isValid()); assertTrue(new GeoPos(0, 0).isValid()); assertTrue(new GeoPos(0, -180).isValid()); assertTrue(new GeoPos(-90, +180).isValid()); assertTrue(new GeoPos(-90, 0).isValid()); assertTrue(new GeoPos(-90, -180).isValid()); assertTrue(new GeoPos(0, -181).isValid()); assertTrue(new GeoPos(0, 181).isValid()); assertFalse(new GeoPos(-91, 0).isValid()); assertFalse(new GeoPos(91, 0).isValid()); assertFalse(new GeoPos(Float.NaN, Float.NaN).isValid()); assertFalse(new GeoPos(Float.NaN, 0).isValid()); assertFalse(new GeoPos(0, Float.NaN).isValid()); }
@Override public PixelPos getPixelPos(final GeoPos geoPos, PixelPos pixelPos) { if (pixelPos == null) { pixelPos = new PixelPos(); } if (geoPos.isValid()) { // ensurePixelPosEstimatorExist(); // if (pixelPosEstimator.canGetPixelPos()) { pixelPosEstimator.getPixelPos(geoPos, pixelPos); if (pixelPos.isValid()) { pixelFinder.findPixelPos(geoPos, pixelPos); } // } else { // pixelPos.setInvalid(); // } } else { pixelPos.setInvalid(); } return pixelPos; }
@Test public void testCreateGeoBoundary() { final GeoPos[] geoPoses = ProductUtils.createGeoBoundary(createTestProduct(), null, 20, false); for (int i = 0; i < geoPoses.length; i++) { GeoPos geoPos = geoPoses[i]; assertTrue(String.format("geoPos at <%d> is invalid", i), geoPos.isValid()); } }
/** * Returns the pixel co-ordinates as x/y for a given geographical position given as lat/lon. * * @param geoPos the geographical position as lat/lon. * @param pixelPos an instance of <code>Point</code> to be used as return value. If this parameter is * <code>null</code>, the method creates a new instance which it then returns. * * @return the pixel co-ordinates as x/y */ @Override public PixelPos getPixelPos(final GeoPos geoPos, PixelPos pixelPos) { initialize(); if (pixelPos == null) { pixelPos = new PixelPos(); } if (geoPos.isValid()) { if (pixelPosEstimator != null) { getPixelPosUsingEstimator(geoPos, pixelPos); } else { getPixelPosUsingQuadTreeSearch(geoPos, pixelPos); } } else { pixelPos.setInvalid(); } return pixelPos; }
private void initCoordinates(Placemark[] gcps) { for (final Placemark gcp : gcps) { final PixelPos pixelPos = gcp.getPixelPos(); final GeoPos geoPos = gcp.getGeoPos(); if (pixelPos == null || !pixelPos.isValid() || geoPos == null || !geoPos.isValid()) { throw new IllegalArgumentException("Invalid ground control point."); } } x = new double[gcps.length]; y = new double[gcps.length]; lons = new double[gcps.length]; lats = new double[gcps.length]; for (int i = 0; i < gcps.length; i++) { final PixelPos pixelPos = gcps[i].getPixelPos(); x[i] = pixelPos.getX(); y[i] = pixelPos.getY(); final GeoPos geoPos = gcps[i].getGeoPos(); lons[i] = geoPos.getLon(); lats[i] = geoPos.getLat(); } }
dataProvider.getGeoPosInteger(x0, y0, geoPos); if (!geoPos.isValid()) { if (formerGeocoding != null && formerGeocoding.canGetGeoPos()) { formerGeocoding.getGeoPos(pixelPos, geoPos);
@Override public void paintOverlay(LayerCanvas canvas, Rendering rendering) { if (geoPosition == null || !geoPosition.isValid()) { return; } final GeoCoding geoCoding = sceneView.getRaster().getGeoCoding(); if (!geoCoding.canGetPixelPos()) { return; } final Product product = sceneView.getRaster().getProduct(); final PixelPos pixelPos = geoCoding.getPixelPos(geoPosition, null); if (!pixelPos.isValid() || !product.containsPixel(pixelPos)) { return; } final Viewport viewport = canvas.getViewport(); drawCursor(rendering.getGraphics(), viewport, pixelPos); }
GeoApproximation approximation = null; if (approximations != null) { if (g.isValid()) { final double lat = g.getLat(); final double lon = g.getLon();