@BeforeClass public static void setUpTestClass() throws Exception { product = new Product("world", "myWorld", 20, 10); product.setSceneGeoCoding(new CrsGeoCoding(DefaultGeographicCRS.WGS84, 20, 10, -180, 90, 18, 18, 0.0, 0.0)); File tempTempFile = File.createTempFile("temp", null); tempDir = new File(tempTempFile.getParentFile(), "ExportGeometryActionTest"); tempDir.mkdir(); tempTempFile.delete(); }
private void initBandsGeoCoding(Band targetBand, TileComponent tileComp) { GeoCoding geoCoding = null; int width = tileComp.getNumColumns(); int height = tileComp.getNumRows(); double stepSize = tileComp.getStepSize(); double originX = tileComp.getOriginX(); double originY = tileComp.getOriginY(); String crsCode = tileComp.computeCRSCode(); try { assert crsCode != null; CoordinateReferenceSystem crs = CRS.decode(crsCode); geoCoding = new CrsGeoCoding(crs, width, height, originX, originY, stepSize, stepSize, 0.0, 0.0); } catch(Exception e) { logger.warning(e.getMessage()); } targetBand.setGeoCoding(geoCoding); }
private static GeoCoding buildGeoCoding(Dataset gdalProduct) { String wellKnownText = gdalProduct.GetProjectionRef(); if (!StringUtils.isNullOrEmpty(wellKnownText)) { int imageWidth = gdalProduct.getRasterXSize(); int imageHeight = gdalProduct.getRasterYSize(); double[] adfGeoTransform = new double[6]; gdalProduct.GetGeoTransform(adfGeoTransform); double originX = adfGeoTransform[0]; double originY = adfGeoTransform[3]; double pixelSizeX = adfGeoTransform[1]; double pixelSizeY = (adfGeoTransform[5] > 0) ? adfGeoTransform[5] : -adfGeoTransform[5]; try { CoordinateReferenceSystem crs = CRS.parseWKT(wellKnownText); return new CrsGeoCoding(crs, imageWidth, imageHeight, originX, originY, pixelSizeX, pixelSizeY); } catch (Exception ex) { logger.log(Level.SEVERE, ex.getMessage(), ex); } } return null; }
private void initGeoCoding(Product product) { try { String projectionCode = metadata.getProjectionCode(); if (projectionCode != null && projectionCode.startsWith("epsg")) { CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", null); CoordinateReferenceSystem crs = factory.createProjectedCRS(projectionCode); if (crs != null) { AffineTransform transformation = new AffineTransform(); transformation.translate(metadata.getRasterGeoRefY(), metadata.getRasterGeoRefX()); transformation.scale(metadata.getRasterGeoRefSizeX(), -metadata.getRasterGeoRefSizeY()); transformation.rotate(-Math.toRadians(imageMetadata.getOrientation())); // Why do we need to do this??? Because it seems that the coordinates given were somehow // offset during processing transformation.translate(-product.getSceneRasterHeight(), -product.getSceneRasterWidth()); Rectangle rectangle = new Rectangle(metadata.getRasterWidth(), metadata.getRasterHeight()); CrsGeoCoding geoCoding = new CrsGeoCoding(crs, rectangle, transformation); product.setSceneGeoCoding(geoCoding); } } } catch (FactoryException e) { e.printStackTrace(); } catch (TransformException e) { e.printStackTrace(); } }
geoCoding = new CrsGeoCoding(targetCRS, targetWidth, targetHeight,
private void initBandGeoCoding(ImageMetadata imageMetadata, Band band, int sceneWidth, int sceneHeight) { int bandWidth = imageMetadata.getRasterWidth(); int bandHeight = imageMetadata.getRasterHeight(); GeoCoding geoCoding = null; ImageMetadata.InsertionPoint insertPoint = imageMetadata.getInsertPoint(); String crsCode = imageMetadata.getCRSCode(); try { CoordinateReferenceSystem crs = CRS.decode(crsCode); if (imageMetadata.hasInsertPoint()) { geoCoding = new CrsGeoCoding(crs, bandWidth, bandHeight, insertPoint.x, insertPoint.y, insertPoint.stepX, insertPoint.stepY, 0.0, 0.0); } else { if (sceneWidth != bandWidth) { AffineTransform2D transform2D = new AffineTransform2D((float) sceneWidth / bandWidth, 0.0, 0.0, (float) sceneHeight / bandHeight, 0.0, 0.0); geoCoding = addTiePointGridGeo(imageMetadata, bandWidth, bandHeight); band.setImageToModelTransform(transform2D); } } } catch (Exception e) { logger.warning(e.getMessage()); } band.setGeoCoding(geoCoding); }
private void initBandGeoCoding(ImageMetadata imageMetadata, Band band, int sceneWidth, int sceneHeight) { int bandWidth = imageMetadata.getRasterWidth(); int bandHeight = imageMetadata.getRasterHeight(); GeoCoding geoCoding = null; ImageMetadata.InsertionPoint insertPoint = imageMetadata.getInsertPoint(); String crsCode = imageMetadata.getCRSCode(); try { CoordinateReferenceSystem crs = CRS.decode(crsCode); if (imageMetadata.hasInsertPoint()) { geoCoding = new CrsGeoCoding(crs, bandWidth, bandHeight, insertPoint.x, insertPoint.y, insertPoint.stepX, insertPoint.stepY, 0.0, 0.0); } else { if (sceneWidth != bandWidth) { AffineTransform2D transform2D = new AffineTransform2D((float) sceneWidth / bandWidth, 0.0, 0.0, (float) sceneHeight / bandHeight, 0.0, 0.0); geoCoding = addTiePointGridGeo(imageMetadata, bandWidth, bandHeight); band.setImageToModelTransform(transform2D); } } } catch (Exception e) { logger.warning(e.getMessage()); } if(band.getGeoCoding() == null) { band.setGeoCoding(geoCoding); } }
public CrsGeoCoding getCrsGeoCoding () { Coordinate2D coordUpperLeft = getUpperLeft(); CrsGeoCoding crsGeoCoding = null; String EPSG = getEPSG(); try { crsGeoCoding = new CrsGeoCoding(CRS.decode("EPSG:" + EPSG), getRasterWidth(), getRasterHeight(), coordUpperLeft.x, coordUpperLeft.y, getBestResolution(), getBestResolution(), 0.0, 0.0); } catch (FactoryException e) { e.printStackTrace(); } catch (TransformException e) { e.printStackTrace(); } return crsGeoCoding; }
band.setGeoCoding(new CrsGeoCoding(CRS.decode("EPSG:" + metadata.getEPSG()), band.getRasterWidth(), band.getRasterHeight(),
geoCoding = new CrsGeoCoding(targetCRS, targetWidth, targetHeight,
public static Product createProduct5() { try { Product product = new Product("Test_Product_5_CRS", "Test_Type_5_CRS", 512, 512); product.getMetadataRoot().addElement(new MetadataElement("Global_Attributes")); product.getMetadataRoot().addElement(new MetadataElement("Local_Attributes")); product.setModified(false); product.addBand("Band_A", "sin(4 * PI * sqrt( sq(X/1000.0 - 1) + sq(Y/500.0 - 1) ))"); product.setSceneGeoCoding(new CrsGeoCoding(DefaultGeographicCRS.WGS84, 512, 512, 0, 10, 1, 1)); final String b_expression = "sin(4 * PI * sqrt( 2.0 * abs(X/1000.0 * Y/500.0) ))"; final VirtualBand band_b = new VirtualBand("Band_B", ProductData.TYPE_FLOAT32, 1024, 256, b_expression); band_b.setGeoCoding(new CrsGeoCoding(DefaultGeographicCRS.WGS84, 1024, 256, 0, 10, 0.5, 2.0)); band_b.setNoDataValueUsed(true); product.addBand(band_b); return product; } catch (FactoryException | TransformException e) { return null; } }
@Before public void setup() throws TransformException, FactoryException { final AffineTransform i2m = new AffineTransform(); i2m.scale(2.0, 2.0); final GeoCoding geoCoding = new CrsGeoCoding(DefaultGeographicCRS.WGS84, new Rectangle(0, 0, 10, 10), i2m); final Product product = new Product("P", "T", 10, 10); product.setSceneGeoCoding(geoCoding); placemark = Placemark.createPointPlacemark(PinDescriptor.getInstance(), "P1", "L", "", new PixelPos(1.0f, 1.0f), null, product.getSceneGeoCoding()); product.getPinGroup().add(placemark); }
mask.setGeoCoding(new CrsGeoCoding(CRS.decode(epsgCode), mask.getRasterWidth(), mask.getRasterHeight(),
@Test public void testReadTrack() throws Exception { CrsGeoCoding geoCoding = new CrsGeoCoding(DefaultGeographicCRS.WGS84, new Rectangle(360, 180), new AffineTransform()); InputStreamReader reader = new InputStreamReader(getClass().getResourceAsStream("TrackData.csv")); FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection = ImportTrackAction.readTrack(reader, geoCoding); assertNotNull(featureCollection); assertEquals(23, featureCollection.size()); // test ordering SimpleFeature[] simpleFeatures = featureCollection.toArray(new SimpleFeature[0]); assertEquals(23, simpleFeatures.length); assertEquals("ID00000000", simpleFeatures[0].getID()); assertEquals("ID00000011", simpleFeatures[11].getID()); assertEquals("ID00000022", simpleFeatures[22].getID()); } }
public static void main(String[] args) throws TransformException, FactoryException { Product product1 = new Product("A", "B", 360, 180); product1.setSceneGeoCoding(new CrsGeoCoding(DefaultGeographicCRS.WGS84, 360, 180, -180.0, 90.0, 1.0, 1.0, 0.0, 0.0)); PinDescriptor descriptor = PinDescriptor.getInstance(); Placemark pin1 = Placemark.createPointPlacemark(descriptor, "pin_1", "Pin 1", "Schnatter!", new PixelPos(0, 0), new GeoPos(), product1.getSceneGeoCoding()); product1.getPinGroup().add(pin1); showEditPlacemarkDialog(null, product1, pin1, descriptor); } }
band.setGeoCoding(new CrsGeoCoding(CRS.decode(epsgCode), band.getRasterWidth(), band.getRasterHeight(),
public Product getBoundaryProduct() throws FactoryException, TransformException { final CoordinateReferenceSystem mapCRS = getTargetCRS(); if (mapCRS != null) { final ReferencedEnvelope envelope = getTargetEnvelope(); final Envelope mapEnvelope = envelope.transform(mapCRS, true); final double pixelSizeX = (Double) getPropertyValue(PROPERTY_PIXEL_SIZE_X); final double pixelSizeY = (Double) getPropertyValue(PROPERTY_PIXEL_SIZE_Y); final int w = MathUtils.floorInt(mapEnvelope.getSpan(0) / pixelSizeX); final int h = MathUtils.floorInt(mapEnvelope.getSpan(1) / pixelSizeY); final Product product = new Product("mosaic", "MosaicBounds", w, h); final GeoCoding geoCoding = new CrsGeoCoding(mapCRS, w, h, mapEnvelope.getMinimum(0), mapEnvelope.getMaximum(1), pixelSizeX, pixelSizeY); product.setSceneGeoCoding(geoCoding); return product; } return null; }
public Product getBoundaryProduct() throws FactoryException, TransformException { final CoordinateReferenceSystem mapCRS = getTargetCRS(); if (mapCRS != null) { final ReferencedEnvelope envelope = getTargetEnvelope(); final Envelope mapEnvelope = envelope.transform(mapCRS, true); final double pixelSizeX = (Double) getPropertyValue(PROPERTY_PIXEL_SIZE_X); final double pixelSizeY = (Double) getPropertyValue(PROPERTY_PIXEL_SIZE_Y); final int w = MathUtils.floorInt(mapEnvelope.getSpan(0) / pixelSizeX); final int h = MathUtils.floorInt(mapEnvelope.getSpan(1) / pixelSizeY); final Product product = new Product("Multi-seize Mosaic", "MosaicBounds", w, h); final GeoCoding geoCoding = new CrsGeoCoding(mapCRS, w, h, mapEnvelope.getMinimum(0), mapEnvelope.getMaximum(1), pixelSizeX, pixelSizeY); product.setSceneGeoCoding(geoCoding); return product; } return null; }
CrsGeoCoding geoCoding = new CrsGeoCoding(targetImageGeometry.getMapCrs(), targetRect, targetImageGeometry.getImage2MapTransform());
final CrsGeoCoding geoCoding = new CrsGeoCoding(targetCRS, width, height, targetEnvelope.getLowerCorner().getOrdinate(0),