private static boolean pixelPosValid(final GeoCoding geoCoding, final GeoPos geoPos, final PixelPos pixelPos, final int width, final int height) { geoCoding.getPixelPos(geoPos, pixelPos); return (pixelPos.isValid() && pixelPos.x >= 0 && pixelPos.x < width && pixelPos.y >= 0 && pixelPos.y < height); }
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(); }
private static SimpleFeature createFeature(SimpleFeatureType type, GeoCoding geoCoding, int pointIndex, float lat, float lon, double data) { PixelPos pixelPos = geoCoding.getPixelPos(new GeoPos(lat, lon), null); if (!pixelPos.isValid()) { return null; } SimpleFeatureBuilder fb = new SimpleFeatureBuilder(type); GeometryFactory gf = new GeometryFactory(); /*0*/ fb.add(gf.createPoint(new Coordinate(pixelPos.x, pixelPos.y))); /*1*/ fb.add(gf.createPoint(new Coordinate(lon, lat))); /*2*/ fb.add(data); return fb.buildFeature(String.format("ID%08d", pointIndex)); }
private void updateXYParams(GeoPos geoPos1, GeoPos geoPos2) { final GeoCoding geoCoding = product.getSceneGeoCoding(); final PixelPos pixelPos1 = geoCoding.getPixelPos(geoPos1, null); if (!pixelPos1.isValid()) { pixelPos1.setLocation(0, 0); } final PixelPos pixelPos2 = geoCoding.getPixelPos(geoPos2, null); if (!pixelPos2.isValid()) { pixelPos2.setLocation(product.getSceneRasterWidth(), product.getSceneRasterHeight()); } final Rectangle.Float region = new Rectangle.Float(); region.setFrameFromDiagonal(pixelPos1.x, pixelPos1.y, pixelPos2.x, pixelPos2.y); final Rectangle.Float productBounds = new Rectangle.Float(0, 0, product.getSceneRasterWidth(), product.getSceneRasterHeight()); Rectangle2D finalRegion = productBounds.createIntersection(region); paramX1.setValue((int) finalRegion.getMinX(), null); paramY1.setValue((int) finalRegion.getMinY(), null); paramX2.setValue((int) finalRegion.getMaxX() - 1, null); paramY2.setValue((int) finalRegion.getMaxY() - 1, null); }
thisGeoCoding.getGeoPos(imageCenter, geoCenter); thatGeoCoding.getPixelPos(geoCenter, imageCenter); if (imageCenter.isValid()) { thatView.getBaseImageLayer().getImageToModelTransform().transform(imageCenter, modelCenter); thatViewport.setZoomFactor(thisViewport.getZoomFactor(), modelCenter.getX(), modelCenter.getY());
@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); }
getPixelPos(c.y, c.x, slvGeoCoding, slvPixelPos); if (slvPixelPos.isValid() && slvPixelPos.x >= 0 && slvPixelPos.x < slvImageWidth && slvPixelPos.y >= 0 && slvPixelPos.y < slvImageHeight) { if (tgtPixelPos.isValid() && tgtPixelPos.x >= 0 && tgtPixelPos.x < targImageWidth && tgtPixelPos.y >= 0 && tgtPixelPos.y < targImageHeight) {
mstGeoCoding.getPixelPos(geoPos, pixPos); if (pixPos.isValid() && pixPos.x != -1 && pixPos.y != -1) { if (pixPos.x < minX) { minX = Math.max(0, pixPos.x);