Refine search
result = getAuthorityFactory(longitudeFirst).createCoordinateReferenceSystem(code); if (longitudeFirst) { defaultCache.put(code, result);
/** * Check if any custom EPSG maps the provided crs and return that one * * @throws FactoryException */ public static CoordinateReferenceSystem lookupForCustomEpsg(CoordinateReferenceSystem crs) throws FactoryException { if (!crsFactories.isEmpty()) { for (CRSAuthorityFactory crsFactory : crsFactories) { Set<String> codes = crsFactory.getAuthorityCodes(CoordinateReferenceSystem.class); for (String code : codes) { CoordinateReferenceSystem decodedCRS = CRS.decode("EPSG:" + code); if (CRS.equalsIgnoreMetadata(decodedCRS, crs)) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Found valid epsgCode for the custom CRS: " + code); } return decodedCRS; } } } } return crs; }
/** * Constructor. Populates the model with available reference systems for the specified * authority. If {@code authority} is {@code null} or empty, it defaults to {@link * JCRSChooser#DEFAULT_AUTHORITY}. * * @param authority the authority name * @param showDefaults show GeoTools default reference systems */ public CRSListModel(String authority) { try { CRSAuthorityFactory fac = ReferencingFactoryFinder.getCRSAuthorityFactory(authority, null); Set<String> codes = fac.getAuthorityCodes(CoordinateReferenceSystem.class); if (authority == null || authority.trim().length() == 0) { authority = JCRSChooser.DEFAULT_AUTHORITY; } for (String code : codes) { code = code.trim(); String desc = fac.getDescriptionText(authority + ":" + code).toString(); allItems.add(new Item(code, desc)); } filterItems.addAll(allItems); } catch (Exception ex) { throw new RuntimeException(ex); } }
/** * Implementation of {@link CRS#getSupportedCodes}. Provided here in order to reduce the amount * of class loading when using {@link CRS} for other purpose than CRS decoding. */ static Set<String> getSupportedCodes(final String authority) { final Set<String> result = new LinkedHashSet<String>(AUTHORITY_LESS); for (final CRSAuthorityFactory factory : ReferencingFactoryFinder.getCRSAuthorityFactories(null)) { if (Citations.identifierMatches(factory.getAuthority(), authority)) { final Set<String> codes; try { codes = factory.getAuthorityCodes(CoordinateReferenceSystem.class); } catch (Exception exception) { /* * Failed to fetch the codes either because of a database connection problem * (FactoryException), or because we are using a simple factory that doesn't * support this operation (UnsupportedOperationException), or any unexpected * reason. No codes from this factory will be added to the set. */ CRS.unexpectedException("getSupportedCodes", exception); continue; } if (codes != null) { result.addAll(codes); } } } return result; }
/** 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")); }
/** Tests the CRS factory. */ @Test public void testCRS() throws FactoryException { CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory("URN:OGC:DEF", null); GeographicCRS crs; try { crs = factory.createGeographicCRS("CRS:84"); fail(); } catch (NoSuchAuthorityCodeException exception) { // This is the expected exception. assertEquals("CRS:84", exception.getAuthorityCode()); } crs = factory.createGeographicCRS("urn:ogc:def:crs:CRS:WMS1.3:84"); assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:CRS:1.3:84")); assertSame(crs, factory.createGeographicCRS("URN:OGC:DEF:CRS:CRS:1.3:84")); assertSame(crs, factory.createGeographicCRS("URN:OGC:DEF:CRS:CRS:84")); assertSame(crs, factory.createGeographicCRS("urn:x-ogc:def:crs:CRS:1.3:84")); assertSame(crs, CRS.decode("urn:ogc:def:crs:CRS:1.3:84")); assertSame(crs, CRS.decode("CRS:84")); assertNotSame(crs, DefaultGeographicCRS.WGS84); assertFalse(DefaultGeographicCRS.WGS84.equals(crs)); assertTrue(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, crs)); // Test CRS:83 crs = factory.createGeographicCRS("urn:ogc:def:crs:CRS:1.3:83"); assertSame(crs, CRS.decode("CRS:83")); assertFalse(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, crs)); }
String name = ""; try { name = CRS.getAuthorityFactory(true).getDescriptionText(code).toString(getLocale()); } catch (Exception e) { CoordinateReferenceSystem crs = null; try { crs = CRS.decode(code); wkt = crs.toString(); String epsgOrderCode = WMS.toInternalSRS(code, new Version("1.3.0")); CoordinateReferenceSystem epsgCrs = CRS.decode(epsgOrderCode);
@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); }
CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", hints); CoordinateReferenceSystem worldCRS = factory .createCoordinateReferenceSystem("EPSG:4326");
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) {
/** 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())); } } }
public IdentifiedObject create(final String code) throws FactoryException { return factory.createCoordinateReferenceSystem(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 + // "%)"); }
public Set getAuthorityCodes(Class type) throws FactoryException { return crsAuthority.getAuthorityCodes(type); }
/** * Implementation of {@link CRS#getSupportedAuthorities}. Provided here in order to reduce the * amount of class loading when using {@link CRS} for other purpose than CRS decoding. */ static Set<String> getSupportedAuthorities(final boolean returnAliases) { final Set<String> result = new LinkedHashSet<String>(); for (final CRSAuthorityFactory factory : ReferencingFactoryFinder.getCRSAuthorityFactories(null)) { for (final Identifier id : factory.getAuthority().getIdentifiers()) { result.add(id.getCode()); if (!returnAliases) { break; } } } return result; }
for( Object object : ReferencingFactoryFinder.getCRSAuthorityFactories(null) ) { CRSAuthorityFactory factory = (CRSAuthorityFactory) object; try { Set<String> codes = factory.getAuthorityCodes(CoordinateReferenceSystem.class); for( Object codeObj : codes ) { String code = (String) codeObj; String description; try { description = factory.getDescriptionText(code).toString(); } catch (Exception e1) { description = "Unnamed";
@Override public IdentifiedObject create(final String code) throws FactoryException { return factory.createProjectedCRS(code); } }
@Override public IdentifiedObject create(final String code) throws FactoryException { return factory.createGeographicCRS(code); } }
final Citation authority = (factory != null) ? factory.getAuthority() : null; final String identifier = IdentifiedObjects.toString(IdentifiedObjects.getIdentifier(crs, authority)); if (identifier != null) try { authoritative = factory.createCoordinateReferenceSystem(identifier); } else { authoritative = CRS.forCode(identifier);
public InternationalString getDescriptionText(String code) throws FactoryException { return crsAuthority.getDescriptionText(code); }