/** Returns {@code true} if the specified provider is for the authority. */ @Override public boolean test(final AuthorityFactory provider) { if (authority == null) { // If the user didn't specified an authority name, then the factory to use must // be specified explicitly through a hint (e.g. Hints.CRS_AUTHORITY_FACTORY). return false; } return Citations.identifierMatches( ((AuthorityFactory) provider).getAuthority(), authority); } }
/** * Searches for an EPSG code inside this <code>IdentifiedObject</code>. * * <p>It is important to remark that this function should be seen as an hack hence it may change * in the near future. DO not rely on it! * * @param obj An <code>IdentifiedObject</code> to look for an EPSG code into. * @return An EPSG numeric code, if one is found, -1 otherwise. */ private static int getEPSGCode(final IdentifiedObject obj) { // looking for an EPSG code final Set<? extends Identifier> identifiers = obj.getIdentifiers(); final Iterator<? extends Identifier> it = identifiers.iterator(); String code = ""; while (it.hasNext()) { final Identifier identifier = it.next(); final Citation cite = identifier.getAuthority(); if (Citations.identifierMatches(cite, "EPSG")) { code = identifier.getCode(); break; } } try { return Integer.parseInt(code); } catch (Exception e) { } // an error occurred; return -1; }
for (authorityIndex = 0; authorityIndex < authorityCount; authorityIndex++) { final Citation candidate = authorities[authorityIndex]; if (Citations.identifierMatches(candidate, authority)) { authority = candidate; break;
if (identifierMatches(c1, id)) { return true;
/** Checks the authority names. */ @Test public void testAuthority() { final Citation authority = factory.getAuthority(); assertTrue(Citations.identifierMatches(authority, "CRS")); assertFalse(Citations.identifierMatches(authority, "EPSG")); assertFalse(Citations.identifierMatches(authority, "AUTO")); assertFalse(Citations.identifierMatches(authority, "AUTO2")); }
/** Implementation of {@link #getIdentifier(Citation)}. */ private static ReferenceIdentifier getIdentifier0( final IdentifiedObject info, final Citation authority) { if (info == null) { return null; } for (final Identifier candidate : info.getIdentifiers()) { if (candidate instanceof ReferenceIdentifier) { final ReferenceIdentifier identifier = (ReferenceIdentifier) candidate; if (authority == null) { return identifier; } final Citation infoAuthority = identifier.getAuthority(); if (infoAuthority != null) { if (Citations.identifierMatches(authority, infoAuthority)) { return identifier; } } } } return (authority == null) ? info.getName() : null; }
/** Checks the authority names. */ @Test public void testAuthority() { final Citation authority = factory.getAuthority(); assertTrue(Citations.identifierMatches(authority, "AUTO")); assertTrue(Citations.identifierMatches(authority, "AUTO2")); assertFalse(Citations.identifierMatches(authority, "EPSG")); assertFalse(Citations.identifierMatches(authority, "CRS")); }
/** * 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; }
for (final AuthorityFactory factory : factories) { if (type.isAssignableFrom(factory.getClass())) { if (Citations.identifierMatches(factory.getAuthority(), authority)) { return type.cast(factory);
/** * Produce a good key based on the privided citaiton and code. You can think of the citation as * being "here" and the code being the "what". * * @param code Code * @return A good key for use with ObjectCache */ public static String toKey(Citation citation, String code) { code = code.trim(); final GenericName name = NameFactory.create(code); final GenericName scope = name.scope().name(); if (scope == null) { return code; } if (citation != null && Citations.identifierMatches(citation, scope.toString())) { return name.tip().toString().trim(); } return code; }
if (Citations.identifierMatches(authority, check)) { continue searchNews;
/** * Trims the authority scope, if present. If more than one authority were given at {@linkplain * #PropertyAuthorityFactory(ReferencingFactoryContainer, Citation[], URL) construction time}, * then any of them may appears as the scope in the supplied code. * * @param code The code to trim. * @return The code without the authority scope. */ @Override protected String trimAuthority(String code) { code = code.trim(); final GenericName name = NameFactory.create(code); final GenericName scope = name.scope().name(); if (scope == null) { return code; } final String candidate = scope.toString(); for (int i = 0; i < authorities.length; i++) { if (Citations.identifierMatches(authorities[i], candidate)) { return name.tip().toString().trim(); } } return code; }
/** * Trims the authority scope, if present. For example if this factory is an EPSG authority * factory and the specified code start with the "EPSG:" prefix, then the prefix is removed. * Otherwise, the string is returned unchanged (except for leading and trailing spaces). * * @param code The code to trim. * @return The code without the authority scope. */ protected String trimAuthority(String code) { /* * IMPLEMENTATION NOTE: This method is overridden in * PropertyAuthorityFactory. If the implementation below is modified, it * is probably worth revisiting the overridden method as well. */ code = code.trim(); final GenericName name = NameFactory.create(code); final GenericName scope = name.scope().name(); if (scope == null) { return code; } if (Citations.identifierMatches(getAuthority(), scope.toString())) { return name.tip().toString().trim(); } return code; }
/** * Trims the authority scope, if present. For example if this factory is an EPSG authority * factory and the specified code start with the "EPSG:" prefix, then the prefix is removed. * Otherwise, the string is returned unchanged (except for leading and trailing spaces). * * @param code The code to trim. * @return The code without the authority scope. */ protected String trimAuthority(String code) { /* * IMPLEMENTATION NOTE: This method is overrided in PropertyAuthorityFactory. If * implementation below is modified, it is probably worth to revisit the overrided * method as well. */ code = code.trim(); final GenericName name = NameFactory.create(code); final GenericName scope = name.scope().name(); if (scope == null) { return code; } if (Citations.identifierMatches(getAuthority(), scope.toString())) { return name.tip().toString().trim(); } return code; }
for (final Iterator it = object.getIdentifiers().iterator(); it.hasNext(); ) { final Identifier id = (Identifier) it.next(); if (!isAll && !Citations.identifierMatches(authority, id.getAuthority())) {
Citation infoAuthority = identifier.getAuthority(); if (infoAuthority != null) { if (Citations.identifierMatches(authority, infoAuthority)) { name = identifier.getCode(); } else { infoAuthority = identifier.getAuthority(); if (infoAuthority != null) { if (Citations.identifierMatches(authority, infoAuthority)) { name = identifier.getCode(); break; final GenericName scope = alias.scope().name(); if (scope != null) { if (Citations.identifierMatches(authority, scope.toString())) { name = alias.tip().toString(); break;
ReferencingFactoryFinder.getCRSAuthorityFactories( FORCE_LONGITUDE_FIRST_AXIS_ORDER)) { if (!Citations.identifierMatches(factory.getAuthority(), authority)) { continue;
/** Tests the authority code. */ @Test public void testAuthority() { final Citation authority = factory.getAuthority(); assertNotNull(authority); assertEquals("European Petroleum Survey Group", authority.getTitle().toString()); assertTrue(Citations.identifierMatches(authority, "EPSG")); assertFalse(Citations.identifierMatches(authority, "ESRI")); assertTrue(factory instanceof FactoryUsingWKT); }
/** Makes sure that the authority factory has the proper name. */ public void testAuthority() { CRSAuthorityFactory factory; Citation authority; // Tests the official factory. factory = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", null); authority = factory.getAuthority(); assertNotNull(authority); assertEquals("European Petroleum Survey Group", authority.getTitle().toString(Locale.US)); assertTrue(Citations.identifierMatches(authority, "EPSG")); // Tests the modified factory. factory = new OrderedAxisAuthorityFactory("EPSG", null, null); authority = factory.getAuthority(); assertNotNull(authority); assertTrue(Citations.identifierMatches(authority, "EPSG")); }
/** Tests the vendor name. */ public void testVendor() { CRSAuthorityFactory factory; Citation vendor; factory = new OrderedAxisAuthorityFactory("EPSG", null, null); vendor = factory.getVendor(); assertNotNull(vendor); assertEquals("Geotools", vendor.getTitle().toString(Locale.US)); assertFalse(Citations.identifierMatches(vendor, "EPSG")); }