@Override public IdentifiedObject create(final String code) throws FactoryException { return factory.createProjectedCRS(code); } }
/** Creates an object for the specified code. */ protected IdentifiedObject createObject(final String code) throws FactoryException { if (projections != null) { final String crs = (String) projections.get(code); if (crs != null) { return ((CRSAuthorityFactory) factory) .createProjectedCRS(crs) .getConversionFromBase(); } } return ((CoordinateOperationAuthorityFactory) factory).createCoordinateOperation(code); } }
/** * Returns a {@linkplain ProjectedCRS projected coordinate reference system} from a code. * * @throws FactoryException if the object creation failed. */ @Override public ProjectedCRS createProjectedCRS(final String code) throws FactoryException { return (ProjectedCRS) replace( getCRSAuthorityFactory(code) .createProjectedCRS(toBackingFactoryCode(code))); }
public ProjectedCRS createProjectedCRS(String code) throws FactoryException { final String key = toKey(code); ProjectedCRS crs = (ProjectedCRS) cache.get(key); if (crs == null) { try { cache.writeLock(key); crs = (ProjectedCRS) cache.peek(key); if (crs == null) { crs = crsAuthority.createProjectedCRS(code); cache.put(key, crs); } } finally { cache.writeUnLock(key); } } return crs; }
public ProjectedCRS createProjectedCRS(String code) throws FactoryException { final String key = toKey(code); ProjectedCRS crs = (ProjectedCRS) cache.get(key); if (crs == null) { try { cache.writeLock(key); crs = (ProjectedCRS) cache.peek(key); if (crs == null) { crs = crsAuthority.createProjectedCRS(code); cache.put(key, crs); } } finally { cache.writeUnLock(key); } } return crs; }
@Test public void test42003() throws FactoryException { ProjectedCRS eqc = factory.createProjectedCRS("AUTO:42003,9001,0.0,0"); assertEquals("Orthographic", eqc.getConversionFromBase().getMethod().getName().getCode()); assertTrue( eqc.getConversionFromBase().getMathTransform() instanceof EquatorialOrthographic); eqc = factory.createProjectedCRS("AUTO:42003,9001,0.0,90"); assertEquals("Orthographic", eqc.getConversionFromBase().getMethod().getName().getCode()); assertTrue(eqc.getConversionFromBase().getMathTransform() instanceof PolarOrthographic); eqc = factory.createProjectedCRS("AUTO:42003,9001,0.0,45"); assertEquals("Orthographic", eqc.getConversionFromBase().getMethod().getName().getCode()); assertTrue(eqc.getConversionFromBase().getMathTransform() instanceof ObliqueOrthographic); }
@Override ProjectedCRS createFromAPI(AuthorityFactory factory, String code) throws FactoryException { return crsFactory(factory).createProjectedCRS(code); } };
@Override public ProjectedCRS createProjectedCRS(String code) throws FactoryException { return factory().createProjectedCRS(code); }
@Override ProjectedCRS createFromAPI(AuthorityFactory factory, String code) throws FactoryException { return crsFactory(factory).createProjectedCRS(code); } };
@Override public ProjectedCRS createProjectedCRS(String code) throws FactoryException { return factory().createProjectedCRS(code); }
/** Check we can parse also the unit */ @Test public void test42001Units() throws FactoryException { final ProjectedCRS utm = factory.createProjectedCRS("AUTO:42001,9001,0.0,0.0"); assertNotNull("auto-utm", utm); assertSame(utm, factory.createObject("AUTO :42001, 9001,0,0")); assertSame(utm, factory.createObject("AUTO2:42001, 9001,0,0")); assertSame(utm, factory.createObject("42001, 9001,0,0")); assertNotSame(utm, factory.createObject("AUTO :42001, 9001,30,0")); assertEquals( "Transverse_Mercator", utm.getConversionFromBase().getMethod().getName().getCode()); }
@Test public void test42004() throws FactoryException { final ProjectedCRS eqc = factory.createProjectedCRS("AUTO:42004,9001,0.0,35"); assertEquals( "Equidistant_Cylindrical", eqc.getConversionFromBase().getMethod().getName().getCode()); String stdParallel1Code = EquidistantCylindrical.Provider.STANDARD_PARALLEL_1.getName().getCode(); double stdParallel1 = eqc.getConversionFromBase() .getParameterValues() .parameter(stdParallel1Code) .doubleValue(); assertEquals(35.0, stdParallel1, 1e-9); }
/** UDIG requires this to work. */ @Test public void test42001() throws FactoryException { final ProjectedCRS utm = factory.createProjectedCRS("AUTO:42001,0.0,0.0"); assertNotNull("auto-utm", utm); assertSame(utm, factory.createObject("AUTO :42001 ,0,0")); assertSame(utm, factory.createObject("AUTO2:42001 ,0,0")); assertSame(utm, factory.createObject("42001 ,0,0")); assertNotSame(utm, factory.createObject("AUTO :42001 ,30,0")); assertEquals( "Transverse_Mercator", utm.getConversionFromBase().getMethod().getName().getCode()); }
/** * Returns the projected CRS instance to be tested. When this method is invoked for the first time, it creates the * CRS to test by invoking the {@link CRSAuthorityFactory#createProjectedCRS(String)} method with the current * {@link #code} value in argument. The created object is then cached and returned in all subsequent invocations * of this method. * * @return the projected CRS instance to test. * @throws FactoryException if an error occurred while creating the projected CRS instance. */ @Override public ProjectedCRS getIdentifiedObject() throws FactoryException { if (crs == null) { assumeNotNull(crsAuthorityFactory); try { crs = crsAuthorityFactory.createProjectedCRS(String.valueOf(code)); } catch (NoSuchIdentifierException e) { /* * Relaxed the exception type from NoSuchAuthorityCodeException because CoordinateOperation creation * will typically use MathTransformFactory under the hood, which throws NoSuchIdentifierException for * non-implemented operation methods (may be identified by their name rather than EPSG code). */ unsupportedCode(ProjectedCRS.class, code); throw e; } } return crs; }
@Test public void test97001() throws FactoryException { ProjectedCRS crs = factory.createProjectedCRS("AUTO:97001,9001,-17.0,23.0"); assertEquals("Gnomonic", crs.getConversionFromBase().getMethod().getName().getCode()); assertTrue(crs.getConversionFromBase().getMathTransform() instanceof Gnomonic); String centreLatCode = Gnomonic.Provider.LATITUDE_OF_CENTRE.getName().getCode(); double centreLat = crs.getConversionFromBase() .getParameterValues() .parameter(centreLatCode) .doubleValue(); assertEquals(23.0, centreLat, 1e-9); String centreLongCode = Gnomonic.Provider.LONGITUDE_OF_CENTRE.getName().getCode(); double centreLong = crs.getConversionFromBase() .getParameterValues() .parameter(centreLongCode) .doubleValue(); assertEquals(-17.0, centreLong, 1e-9); }
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(); } }
if ("North".equalsIgnoreCase(hemisphere)) { final int WGS84_UTM_zone_N_BASE = 32600; crs = factory.createProjectedCRS("EPSG:" + (WGS84_UTM_zone_N_BASE + zone)); } else { final int WGS84_UTM_zone_S_BASE = 32700; crs = factory.createProjectedCRS("EPSG:" + (WGS84_UTM_zone_S_BASE + zone));
@Test public void test97002() throws FactoryException { ProjectedCRS crs = factory.createProjectedCRS("AUTO:97002,9001,-17.0,23.0"); assertEquals("Stereographic", crs.getConversionFromBase().getMethod().getName().getCode()); assertTrue(crs.getConversionFromBase().getMathTransform() instanceof Stereographic);
final ProjectedCRS crs = getCRSAuthorityFactory().createProjectedCRS(String.valueOf(epsg)); verify(crs); return crs;
if (Datum.WGS_72.equals(datum)) { final int WGS72_UTM_zone_N_BASE = 32200; result = factory.createProjectedCRS("EPSG:" + (WGS72_UTM_zone_N_BASE + zone)); } else if (Datum.WGS_84.equals(datum)) { final int WGS84_UTM_zone_N_BASE = 32600; result = factory.createProjectedCRS("EPSG:" + (WGS84_UTM_zone_N_BASE + zone)); result = factory.createProjectedCRS("EPSG:" + (WGS72_UTM_zone_S_BASE + zone)); } else if (Datum.WGS_84.equals(datum)) { final int WGS84_UTM_zone_S_BASE = 32700; result = factory.createProjectedCRS("EPSG:" + (WGS84_UTM_zone_S_BASE + zone));