CrsGeoCoding extends AbstractGeoCoding { @Override public Datum getDatum() { return datum; } CrsGeoCoding(CoordinateReferenceSystem mapCRS,
                        int imageWidth,
                        int imageHeight,
                        double easting,
                        double northing,
                        double pixelSizeX,
                        double pixelSizeY);  CrsGeoCoding(CoordinateReferenceSystem mapCRS,
                        int imageWidth,
                        int imageHeight,
                        double easting,
                        double northing,
                        double pixelSizeX,
                        double pixelSizeY,
                        double referencePixelX,
                        double referencePixelY);  CrsGeoCoding(final CoordinateReferenceSystem mapCRS,
                        final Rectangle imageBounds,
                        final AffineTransform imageToMap); @Override MathTransform getImageToMapTransform(); @Override boolean transferGeoCoding(Scene srcScene, Scene destScene, ProductSubsetDef subsetDef); @Override boolean canGetGeoPos(); @Override boolean canGetPixelPos(); @Override void dispose(); @Override Datum getDatum(); @Override GeoPos getGeoPos(PixelPos pixelPos, GeoPos geoPos); @Override PixelPos getPixelPos(GeoPos geoPos, PixelPos pixelPos); final void getPixels(final int x1, final int y1, final int w, final int h,
                                final float[] latPixels, final float[] lonPixels); @Override boolean isCrossingMeridianAt180(); @Override String toString();  }
@Test public void testTransferGeoCodingWithSubset_Region() { final ProductSubsetDef subsetDef = new ProductSubsetDef("subset"); subsetDef.setRegion(2, 2, 4, 4); final boolean transfered = srcScene.transferGeoCodingTo(destScene, subsetDef); assertTrue(transfered); final GeoCoding destGeoCoding = destScene.getGeoCoding(); assertNotNull(destGeoCoding); assertNotSame(srcGeoCoding, destGeoCoding); assertEquals(srcGeoCoding.getDatum(), destGeoCoding.getDatum()); assertEquals(srcGeoCoding.getMapCRS(), destGeoCoding.getMapCRS()); comparePixelPos(destGeoCoding, new PixelPos(3, 3), new PixelPos(1, 1)); }
@Test public void testTransferGeoCodingWithSubset_Subsampling() { final ProductSubsetDef subsetDef = new ProductSubsetDef("subset"); subsetDef.setSubSampling(2, 4); final boolean transfered = srcScene.transferGeoCodingTo(destScene, subsetDef); assertTrue(transfered); final GeoCoding destGeoCoding = destScene.getGeoCoding(); assertNotNull(destGeoCoding); assertNotSame(srcGeoCoding, destGeoCoding); assertEquals(srcGeoCoding.getDatum(), destGeoCoding.getDatum()); assertEquals(srcGeoCoding.getMapCRS(), destGeoCoding.getMapCRS()); assertEquals(srcGeoCoding.getGeoCRS(), destGeoCoding.getGeoCRS()); comparePixelPos(destGeoCoding, new PixelPos(0, 0), new PixelPos(0, 0)); comparePixelPos(destGeoCoding, new PixelPos(8, 0), new PixelPos(4, 0)); comparePixelPos(destGeoCoding, new PixelPos(8, 16), new PixelPos(4, 4)); comparePixelPos(destGeoCoding, new PixelPos(0, 16), new PixelPos(0, 4)); }
@Test public void testTransferGeoCodingWithSubset_SubsamplingAndRegion() { final ProductSubsetDef subsetDef = new ProductSubsetDef("subset"); subsetDef.setRegion(2, 2, 8, 8); subsetDef.setSubSampling(2, 2); final boolean transfered = srcScene.transferGeoCodingTo(destScene, subsetDef); assertTrue(transfered); final GeoCoding destGeoCoding = destScene.getGeoCoding(); assertNotNull(destGeoCoding); assertNotSame(srcGeoCoding, destGeoCoding); assertEquals(srcGeoCoding.getDatum(), destGeoCoding.getDatum()); assertEquals(srcGeoCoding.getMapCRS(), destGeoCoding.getMapCRS()); assertEquals(srcGeoCoding.getGeoCRS(), destGeoCoding.getGeoCRS()); comparePixelPos(destGeoCoding, new PixelPos(2, 2), new PixelPos(0, 0)); comparePixelPos(destGeoCoding, new PixelPos(10, 2), new PixelPos(4, 0)); comparePixelPos(destGeoCoding, new PixelPos(10, 10), new PixelPos(4, 4)); comparePixelPos(destGeoCoding, new PixelPos(2, 10), new PixelPos(0, 4)); }
@Test public void testCustomSpheroidDatum() throws TransformException, FactoryException { String wkt = "PROJCS[\"MODIS_Sinusoidal\", \n" + " GEOGCS[\"Unknown datum based upon the custom spheroid\", \n" + " DATUM[\"Not specified (based on custom spheroid)\", \n" + " SPHEROID[\"Custom spheroid\", 6371007.181, 0.0]], \n" + " PRIMEM[\"Greenwich\", 0.0], \n" + " UNIT[\"degree\", 0.017453292519943295], \n" + " AXIS[\"Longitude\", EAST], \n" + " AXIS[\"Latitude\", NORTH]], \n" + " PROJECTION[\"Sinusoidal\"], \n" + " PARAMETER[\"central_meridian\", 0.0], \n" + " PARAMETER[\"scale_factor\", 1.0], \n" + " PARAMETER[\"false_easting\", 0.0], \n" + " PARAMETER[\"false_northing\", 0.0], \n" + " UNIT[\"m\", 1.0], \n" + " AXIS[\"x\", EAST], \n" + " AXIS[\"y\", NORTH]]"; CoordinateReferenceSystem crs = CRS.parseWKT(wkt); CrsGeoCoding geoCoding = new CrsGeoCoding(crs, new Rectangle(10, 10, 10, 10), new AffineTransform()); DefaultGeographicCRS defaultCrs = (DefaultGeographicCRS) geoCoding.getGeoCRS(); Ellipsoid wgs84Spheroid = DefaultGeographicCRS.WGS84.getDatum().getEllipsoid(); Ellipsoid customSpheroid = defaultCrs.getDatum().getEllipsoid(); assertNotSame(DefaultGeographicCRS.WGS84, defaultCrs); assertTrue(wgs84Spheroid.getSemiMinorAxis() != customSpheroid.getSemiMinorAxis()); assertTrue(wgs84Spheroid.getSemiMajorAxis() != customSpheroid.getSemiMajorAxis()); assertSame(DefaultEllipsoidalCS.GEODETIC_2D, defaultCrs.getCoordinateSystem()); }
@Test public void testWgs84() throws TransformException, FactoryException { String testedWkt = "GEOGCS[\"WGS 84\",\n" + " DATUM[\"WGS_1984\",\n" + " SPHEROID[\"WGS 84\",6378137,298.257223563,\n" + " AUTHORITY[\"EPSG\",\"7030\"]],\n" + " AUTHORITY[\"EPSG\",\"6326\"]],\n" + " PRIMEM[\"Greenwich\",0,\n" + " AUTHORITY[\"EPSG\",\"8901\"]],\n" + " UNIT[\"degree\",0.01745329251994328,\n" + " AUTHORITY[\"EPSG\",\"9122\"]],\n" + " AUTHORITY[\"EPSG\",\"4326\"]]"; CoordinateReferenceSystem testedCrs = CRS.parseWKT(testedWkt); GeoCoding geoCoding = new CrsGeoCoding(testedCrs, new Rectangle(10, 10, 10, 10), new AffineTransform()); DefaultGeographicCRS testedDefaultCrs = (DefaultGeographicCRS) geoCoding.getGeoCRS(); Ellipsoid testedSpheroid = testedDefaultCrs.getDatum().getEllipsoid(); Ellipsoid wgs84Spheroid = DefaultGeographicCRS.WGS84.getDatum().getEllipsoid(); assertTrue(wgs84Spheroid.getSemiMinorAxis() == testedSpheroid.getSemiMinorAxis()); assertTrue(wgs84Spheroid.getSemiMajorAxis() == testedSpheroid.getSemiMajorAxis()); assertSame(DefaultGeographicCRS.WGS84.getCoordinateSystem(), testedDefaultCrs.getCoordinateSystem()); }