Java Code Examples for org.opengis.referencing.crs.CRSAuthorityFactory#getAuthorityCodes()

The following examples show how to use org.opengis.referencing.crs.CRSAuthorityFactory#getAuthorityCodes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CrsInfo.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private static void retrieveCodes(Set<String> codes, Class<? extends CoordinateReferenceSystem> crsType,
                                  CRSAuthorityFactory factory) {
    Set<String> localCodes;
    try {
        localCodes = factory.getAuthorityCodes(crsType);
    } catch (FactoryException ignore) {
        return;
    }
    codes.addAll(localCodes);
}
 
Example 2
Source File: CRSTable.java    From sis with Apache License 2.0 5 votes vote down vote up
private List<Code> getCodes() throws FactoryException{
    final CRSAuthorityFactory factory = org.apache.sis.referencing.CRS.getAuthorityFactory(null);
    final Set<String> strs = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
    final List<Code> codes = new ArrayList<>();
    for (String str : strs) {
        codes.add(new Code(factory, str));
    }
    return codes;
}
 
Example 3
Source File: AuthorityFactoriesTest.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the {@code getAuthorityCodes(…)} method.
 *
 * @throws FactoryException if an error occurred while fetching the codes.
 */
@Test
public void testGetAuthorityCodes() throws FactoryException {
    final CRSAuthorityFactory factory = AuthorityFactories.ALL;
    final Collection<String> codes = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
    assertFalse(codes.isEmpty());
    assertTrue(codes.contains("CRS:84"));
    assertTrue(codes.contains("AUTO:42001") || codes.contains("AUTO2:42001"));
}
 
Example 4
Source File: CoordinateOperationMethods.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * For each {@link OperationMethod} (identified by their name), computes the union of the domain of validity
 * of all CRS using that operation method. The result is a map where keys are {@link OperationMethod} names,
 * and values are the union of the domain of validity of all CRS using that {@code OperationMethod}.
 *
 * <p>This is a costly operation.</p>
 *
 * @todo This method is not yet used. This is pending the implementation of {@code CRSAuthorityFactory} is SIS.
 *
 * @param  factory  the factory to use for getting CRS.
 * @return the union of domain of validity of all map projections using a method of the given name.
 * @throws FactoryException if an error occurred while fetching the list of CRS.
 */
public static Map<String, DefaultGeographicBoundingBox> computeUnionOfAllDomainOfValidity(
        final CRSAuthorityFactory factory) throws FactoryException
{
    final Map<String, DefaultGeographicBoundingBox> domainOfValidity = new HashMap<>();
    for (final String code : factory.getAuthorityCodes(GeneralDerivedCRS.class)) {
        final CoordinateReferenceSystem crs;
        try {
            crs = factory.createCoordinateReferenceSystem(code);
        } catch (FactoryException e) {
            continue;                                                   // Ignore and inspect the next element.
        }
        if (crs instanceof GeneralDerivedCRS) {
            final GeographicBoundingBox candidate = CRS.getGeographicBoundingBox(crs);
            if (candidate != null) {
                final String name = ((GeneralDerivedCRS) crs).getConversionFromBase().getMethod().getName().getCode();
                DefaultGeographicBoundingBox validity = domainOfValidity.get(name);
                if (validity == null) {
                    validity = new DefaultGeographicBoundingBox(candidate);
                    domainOfValidity.put(name, validity);
                } else {
                    validity.add(candidate);
                }
            }
        }
    }
    return domainOfValidity;
}