private CoordinateReferenceSystem getMapCrs() { return product.getSceneGeoCoding().getMapCRS(); }
@Override public CoordinateReferenceSystem getCRS(GeoPos referencePos) { Product collocationProduct = collocateProductSelector.getSelectedProduct(); if (collocationProduct != null) { return collocationProduct.getSceneGeoCoding().getMapCRS(); } return null; }
private void processLandWaterMask() { boolean isHigherResolutionInput = sourceProduct.getBand("B2") != null && sourceProduct.getBand("B2").getGeoCoding().getMapCRS().getName().toString().contains("UTM") && sourceProduct.getBand("B2").getImageToModelTransform().getScaleX() < LAND_WATER_MASK_RESOLUTION; HashMap<String, Object> waterMaskParameters = new HashMap<>(); waterMaskParameters.put("resolution", LAND_WATER_MASK_RESOLUTION); if (isHigherResolutionInput) { System.out.println("No subsampling of " + sourceProduct.getBand("B2").getImageToModelTransform().getScaleX() + " m product necessary to access " + LAND_WATER_MASK_RESOLUTION + " m water mask"); waterMaskParameters.put("subSamplingFactorX", 1); waterMaskParameters.put("subSamplingFactorY", 1); } else { waterMaskParameters.put("subSamplingFactorX", OVERSAMPLING_FACTOR_X); waterMaskParameters.put("subSamplingFactorY", OVERSAMPLING_FACTOR_Y); } waterMaskProduct = GPF.createProduct("LandWaterMask", waterMaskParameters, sourceProduct); }
return collocationProduct.getSceneGeoCoding().getMapCRS();
private boolean isGeographicLatLon(GeoCoding geoCoding) { if (geoCoding instanceof MapGeoCoding) { MapGeoCoding mapGeoCoding = (MapGeoCoding) geoCoding; MapTransformDescriptor transformDescriptor = mapGeoCoding.getMapInfo() .getMapProjection().getMapTransform().getDescriptor(); String typeID = transformDescriptor.getTypeID(); if (typeID.equals(IdentityTransformDescriptor.TYPE_ID)) { return true; } } else if (geoCoding instanceof CrsGeoCoding) { return CRS.equalsIgnoreMetadata(geoCoding.getMapCRS(), DefaultGeographicCRS.WGS84); } return false; }
final CoordinateReferenceSystem mapCRS = geoCoding.getMapCRS(); if (!mapCRS.equals(DefaultGeographicCRS.WGS84)) { try {
double y = pol.getCoordinates()[index].y; try { DirectPosition pos = CRS.findMathTransform(product.getSceneGeoCoding().getMapCRS(), product.getSceneGeoCoding().getImageCRS()).transform(new DirectPosition2D(x, y), null); double[] values = pos.getCoordinate(); xCoordinates[index] = (int) values[0];
/** * Utility methods */ private double[] getPixelSize(GeoCoding sourceGeoCoding, CoordinateReferenceSystem targetCRS) { double[] size = null; try { size = new double[2]; DirectPosition geoPos1 = sourceGeoCoding.getImageToMapTransform() .transform(new DirectPosition2D(0, 0), null); Coordinate c1 = new Coordinate(geoPos1.getOrdinate(0), geoPos1.getOrdinate(1)); DirectPosition geoPos2 = sourceGeoCoding.getImageToMapTransform() .transform(new DirectPosition2D(0, 1), null); Coordinate c2 = new Coordinate(geoPos2.getOrdinate(0), geoPos2.getOrdinate(1)); DirectPosition geoPos3 = sourceGeoCoding.getImageToMapTransform() .transform(new DirectPosition2D(1, 0), null); Coordinate c3 = new Coordinate(geoPos3.getOrdinate(0), geoPos3.getOrdinate(1)); final CoordinateReferenceSystem sourceCRS = sourceGeoCoding.getMapCRS(); size[0] = distance(sourceCRS, targetCRS, c3, c1); size[1] = distance(sourceCRS, targetCRS, c2, c1); } catch (TransformException tex) { tex.printStackTrace(); } return size; }
@Override public void actionPerformed(ActionEvent e) { ProductSceneView view = SnapApp.getDefault().getSelectedProductSceneView(); final GeoCoding geoCoding = view.getProduct().getSceneGeoCoding(); boolean isGeographic = false; if (geoCoding instanceof MapGeoCoding) { MapGeoCoding mapGeoCoding = (MapGeoCoding) geoCoding; MapTransformDescriptor transformDescriptor = mapGeoCoding.getMapInfo() .getMapProjection().getMapTransform().getDescriptor(); String typeID = transformDescriptor.getTypeID(); if (typeID.equals(IdentityTransformDescriptor.TYPE_ID)) { isGeographic = true; } } else if (geoCoding instanceof CrsGeoCoding) { isGeographic = CRS.equalsIgnoreMetadata(geoCoding.getMapCRS(), DefaultGeographicCRS.WGS84); } if (isGeographic) { exportImage(view); } else { String message = "Product must be in ''Geographic Lat/Lon'' projection."; Dialogs.showInformation(message, null); } }
private void resetPositionTableModel() { positionModel.clear(); if (currentRaster != null) { final GeoCoding geoCoding = currentRaster.getGeoCoding(); positionModel.addRow("Image-X", "", "pixel"); positionModel.addRow("Image-Y", "", "pixel"); //todo [Multisize_products] ask for something else than multisize (scenetomodeltransform) if (getCurrentProduct().isMultiSize()) { positionModel.addRow("Scene-X", "", "pixel"); positionModel.addRow("Scene-Y", "", "pixel"); } if (geoCoding != null) { positionModel.addRow("Longitude", "", "degree"); positionModel.addRow("Latitude", "", "degree"); if (geoCoding instanceof MapGeoCoding) { final MapGeoCoding mapGeoCoding = (MapGeoCoding) geoCoding; final String mapUnit = mapGeoCoding.getMapInfo().getMapProjection().getMapUnit(); positionModel.addRow("Map-X", "", mapUnit); positionModel.addRow("Map-Y", "", mapUnit); } else if (geoCoding instanceof CrsGeoCoding) { String xAxisUnit = geoCoding.getMapCRS().getCoordinateSystem().getAxis(0).getUnit().toString(); String yAxisUnit = geoCoding.getMapCRS().getCoordinateSystem().getAxis(1).getUnit().toString(); positionModel.addRow("Map-X", "", xAxisUnit); positionModel.addRow("Map-Y", "", yAxisUnit); } } } }
if (geoCoding instanceof CrsGeoCoding) { try { final Integer epsgCode = CRS.lookupEpsgCode(geoCoding.getMapCRS(), true); GmlRectifiedGrid rectifiedGrid = new GmlRectifiedGrid(); rectifiedGrid.setEpsgNumber(epsgCode);