public IdentifiedObject create(final String code) throws FactoryException { return factory.createCoordinateReferenceSystem(code); } }
hints); CoordinateReferenceSystem worldCRS = factory .createCoordinateReferenceSystem("EPSG:4326");
/** Prints the math transforms between every pairs of the specified authority code. */ private void transform(final PrintWriter out, final String[] args) throws FactoryException { if (!(factory instanceof CRSAuthorityFactory)) { return; } final CRSAuthorityFactory factory = (CRSAuthorityFactory) this.factory; final CoordinateOperationFactory opFactory = ReferencingFactoryFinder.getCoordinateOperationFactory(HINTS); char[] separator = null; for (int i = 0; i < args.length; i++) { final CoordinateReferenceSystem crs1 = factory.createCoordinateReferenceSystem(args[i]); for (int j = i + 1; j < args.length; j++) { final CoordinateReferenceSystem crs2 = factory.createCoordinateReferenceSystem(args[j]); final CoordinateOperation op; try { op = opFactory.createOperation(crs1, crs2); } catch (OperationNotFoundException exception) { out.println(exception.getLocalizedMessage()); continue; } if (separator == null) { separator = getSeparator(); } else { out.println(separator); } out.println(formatter.format(op.getMathTransform())); } } }
/** * Returns an arbitrary {@linkplain CoordinateReferenceSystem coordinate reference system} from * a code. * * @throws FactoryException if the object creation failed. * @see #createGeographicCRS * @see #createProjectedCRS * @see #createVerticalCRS * @see #createTemporalCRS * @see #createCompoundCRS */ @Override public CoordinateReferenceSystem createCoordinateReferenceSystem(final String code) throws FactoryException { return replace( getCRSAuthorityFactory(code) .createCoordinateReferenceSystem(toBackingFactoryCode(code))); }
/** * Tests the number of CRS that can be created. This test will be executed only if this test * suite is run with the {@code -verbose} option provided on the command line. */ public void testSuccess() throws FactoryException { if (!verbose) { return; } final CRSAuthorityFactory factory = new OrderedAxisAuthorityFactory("EPSG", null, null); Set codes = factory.getAuthorityCodes(CoordinateReferenceSystem.class); int total = codes.size(); int count = 0; for (Iterator i = codes.iterator(); i.hasNext(); ) { CoordinateReferenceSystem crs; String code = (String) i.next(); try { crs = factory.createCoordinateReferenceSystem(code); assertNotNull(crs); count++; } catch (FactoryException e) { // System.err.println("WARNING (CRS: " + code + " ):" + e.getMessage()); } } // System.out.println("Success: " + count + "/" + total + " (" + (count * 100) / total + // "%)"); }
result = getAuthorityFactory(longitudeFirst).createCoordinateReferenceSystem(code); if (longitudeFirst) { defaultCache.put(code, result);
public CoordinateReferenceSystem createCoordinateReferenceSystem(String code) throws FactoryException { final String key = toKey(code); CoordinateReferenceSystem crs = (CoordinateReferenceSystem) cache.get(key); if (crs == null) { try { cache.writeLock(key); crs = (CoordinateReferenceSystem) cache.peek(key); if (crs == null) { crs = crsAuthority.createCoordinateReferenceSystem(code); cache.put(key, crs); } } finally { cache.writeUnLock(key); } } return crs; }
CoordinateReferenceSystem actual, expected; actual = all.createCoordinateReferenceSystem("http://www.opengis.net/gml/srs/CRS#84"); expected = crs.createCoordinateReferenceSystem("84"); assertSame(expected, actual); actual = all.createCoordinateReferenceSystem("HTTP://WWW.OPENGIS.NET/GML/SRS/crs#84"); assertSame(expected, actual); actual = all.createCoordinateReferenceSystem("http://www.opengis.net/gml/srs/CRS.xml#84"); assertSame(expected, actual); all.createCoordinateReferenceSystem("http://www.dummy.net/gml/srs/CRS#84"); fail("Expected a NoSuchAuthorityCodeException"); } catch (NoSuchAuthorityCodeException e) { all.createCoordinateReferenceSystem("http://www.opengis.net/gml/dummy/CRS#84"); fail("Expected a NoSuchAuthorityCodeException"); } catch (NoSuchAuthorityCodeException e) {
public CoordinateReferenceSystem createCoordinateReferenceSystem(String code) throws FactoryException { final String key = toKey(code); CoordinateReferenceSystem crs = (CoordinateReferenceSystem) cache.get(key); if (crs == null) { try { cache.writeLock(key); crs = (CoordinateReferenceSystem) cache.peek(key); if (crs == null) { crs = crsAuthority.createCoordinateReferenceSystem(code); cache.put(key, crs); } } finally { cache.writeUnLock(key); } } return crs; }
/** UDIG requires this to work. */ public void test4326() throws FactoryException { final CRSAuthorityFactory factory = new OrderedAxisAuthorityFactory("EPSG", null, null); final CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem("EPSG:4326"); assertNotNull(crs); assertSame(crs, factory.createObject("EPSG:4326")); }
/** A random CRS for fun. */ public void test26910() throws FactoryException { final CRSAuthorityFactory factory = new OrderedAxisAuthorityFactory("EPSG", null, null); final CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem("EPSG:26910"); assertNotNull(crs); assertSame(crs, factory.createObject("EPSG:26910")); }
CoordinateReferenceSystem actual, expected; actual = all.createCoordinateReferenceSystem("CRS:84"); expected = crs.createCoordinateReferenceSystem("84"); assertSame(expected, actual); assertSame(expected, all.createObject("CRS:84")); actual = all.createCoordinateReferenceSystem("AUTO:42001,0,0"); expected = auto.createCoordinateReferenceSystem("42001,0,0"); assertSame(expected, actual); assertSame(expected, all.createObject("AUTO:42001,0,0")); actual = all.createCoordinateReferenceSystem("CRS:27"); expected = crs.createCoordinateReferenceSystem("27"); assertSame(expected, actual); assertSame(expected, all.createObject("CRS:27")); all.createCoordinateReferenceSystem("84"); fail("Should not work without authority."); } catch (NoSuchAuthorityCodeException exception) { all.createCoordinateReferenceSystem("FOO:84"); fail("Should not work with unknown authority."); } catch (NoSuchAuthorityCodeException exception) {
/** UDIG requires this to work. */ public void test4269() throws FactoryException { final CRSAuthorityFactory factory = new OrderedAxisAuthorityFactory("EPSG", null, null); final CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem("EPSG:4269"); assertNotNull(crs); assertSame(crs, factory.createObject("EPSG:4269")); }
final CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory("CRS", null); final CoordinateReferenceSystem expected = factory.createCoordinateReferenceSystem("83"); AuthorityFactoryProxy proxy;
@Override public CoordinateReferenceSystem getCrs(GeoPos referencePos) throws FactoryException { if (referencePos == null) { referencePos = new GeoPos(0, 0); } String code = String.format("%s,%s,%s", super.crsCode, referencePos.lon, referencePos.lat); return super.factory.createCoordinateReferenceSystem(code); }
@Override CoordinateReferenceSystem createFromAPI(AuthorityFactory factory, String code) throws FactoryException { return crsFactory(factory).createCoordinateReferenceSystem(code); } };
@Test public void testTransformBBOXIsCorrect() throws Exception { Style style = RendererBaseTest.loadStyle(this, "noop_colormap.sld"); GeoTiffReader reader = new GeoTiffReader(TestData.file(this, "watertemp.tiff")); MapContent mc = new MapContent(); mc.addLayer(new GridReaderLayer(reader, style)); StreamingRenderer renderer = new StreamingRenderer(); renderer.setMapContent(mc); CRSAuthorityFactory factory = CRS.getAuthorityFactory(true); CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem("EPSG:4326"); ReferencedEnvelope reWgs84 = new ReferencedEnvelope( 9.848993475036622, 11.958867853088378, 40.74254816253662, 41.64941961090088, crs); BufferedImage image = RendererBaseTest.showRender("Transform BBOX", renderer, 4000, reWgs84); // last pixel is white when doing a transformation and the rendering transform BBOX // transforms are // incorrect, it shouldn't be assertNotEquals(Color.WHITE, getPixelColor(image, 299, 0)); assertEquals(new Color(133, 130, 188), getPixelColor(image, 299, 0)); }
/** * Tests {@link IdentifiedObjectFinder#createFromCodes}. We uses the CRS factory for testing * purpose. */ @Test public void testCreateFromCodes() throws FactoryException { final CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory("CRS", null); final IdentifiedObjectFinder proxy = new IdentifiedObjectFinder(factory, GeographicCRS.class); CoordinateReferenceSystem expected = factory.createCoordinateReferenceSystem("84"); assertNotSame(expected, DefaultGeographicCRS.WGS84); assertSame(expected, proxy.createFromCodes(expected, false)); assertSame(expected, proxy.createFromIdentifiers(expected)); assertNull(proxy.createFromNames(expected)); assertSame(expected, proxy.createFromCodes(DefaultGeographicCRS.WGS84, false)); assertNull(proxy.createFromIdentifiers(DefaultGeographicCRS.WGS84)); assertNull(proxy.createFromNames(DefaultGeographicCRS.WGS84)); expected = factory.createCoordinateReferenceSystem("83"); assertSame(expected, proxy.createFromCodes(expected, false)); assertSame(expected, proxy.createFromIdentifiers(expected)); assertNull(proxy.createFromNames(expected)); } }
@BeforeClass public static void setup() throws NoSuchAuthorityCodeException, FactoryException { Hints hints = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", hints); PROJ_EPSG4326_CRS = (AbstractReferenceSystem) factory .createCoordinateReferenceSystem(PROJ_EPSG4326); PROJ_EQUIV_EPSG4326_CRS = (AbstractReferenceSystem) CRS.parseWKT(PROJ_EQUIV_EPSG4326); }
@BeforeClass public static void setup() throws NoSuchAuthorityCodeException, FactoryException { Hints hints = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", hints); PROJ_EPSG4326_CRS = (AbstractReferenceSystem) factory .createCoordinateReferenceSystem(PROJ_EPSG4326); PROJ_EQUIV_EPSG4326_CRS = (AbstractReferenceSystem) CRS.parseWKT(PROJ_EQUIV_EPSG4326); }