/** 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); } }
iterator = c1.getIdentifiers().iterator(); if (!iterator.hasNext()) { return titleMatches(c1, c2); if (identifierMatches(c1, id)) { return true;
final Citation authority = Citations.fromName(auth); properties = new HashMap<String, Object>(4); properties.put(IdentifiedObject.NAME_KEY, new NamedIdentifier(authority, name));
/** Returns {@code true} if the specified factory is built by the vendor. */ @Override public boolean test(final Factory factory) { return Citations.titleMatches(factory.getVendor(), vendor); } }
/** Returns the authority names of every factories given at construction time. */ public Set<String> getAuthorityNames() { final Set<String> names = new HashSet<String>(); final Collection<AuthorityFactory> factories = getFactories(); if (factories != null) { for (final AuthorityFactory factory : factories) { names.add(Citations.getIdentifier(factory.getAuthority())); } } return names; }
/** * Returns a citation of the given name. If the given name matches a {@linkplain * Citation#getTitle title} or an {@linkplain Citation#getAlternateTitles alternate titles} of * one of the pre-defined constants ({@link #EPSG}, {@link #GEOTIFF}, <cite>etc.</cite>), then * this constant is returned. Otherwise, a new citation is created with the specified name as * the title. * * @param title The citation title (or alternate title). * @return A citation using the specified name */ public static Citation fromName(final String title) { for (int i = 0; i < AUTHORITIES.length; i++) { final Citation citation = AUTHORITIES[i]; if (titleMatches(citation, title)) { return citation; } } return new CitationImpl(title); }
/** * Creates an exception for a missing factory. We actually returns an instance of {@link * NoSuchAuthorityCodeException} because this kind of exception is treated especially by {@link * FallbackAuthorityFactory}. */ private FactoryException missingFactory(final Class category, final String code) { return new NoSuchAuthorityCodeException( Errors.format(ErrorKeys.FACTORY_NOT_FOUND_$1, category), Citations.getIdentifier(getAuthority()), trimAuthority(code)); }
/** * 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; }
iterator = c1.getIdentifiers().iterator(); if (!iterator.hasNext()) { return titleMatches(c1, c2); if (identifierMatches(c1, id)) { return true;
/** * Returns {@code true} if any {@linkplain Citation#getIdentifiers identifiers} in the given * citation matches the given string. The comparaison is case-insensitive and ignores leading * and trailing spaces. If (and <em>only</em> if) the citation do not contains any identifier, * then this method fallback on titles comparaison using the {@link #titleMatches(Citation, * String) titleMatches} method. This fallback exists for compatibility with client codes using * citation {@linkplain Citation#getTitle titles} without identifiers. * * @param citation The citation to check for. * @param identifier The identifier to compare. * @return {@code true} if the title or alternate title matches the given string. */ public static boolean identifierMatches(final Citation citation, String identifier) { identifier = identifier.trim(); final Collection<? extends Identifier> identifiers = citation.getIdentifiers(); for (final Identifier id : identifiers) { final String code = id.getCode().trim(); if (identifier.equalsIgnoreCase(code)) { return true; } } if (identifiers.isEmpty()) { return titleMatches(citation, identifier); } else { return false; } }
value = Citations.fromName(value.toString());
final Citation authority = factory.getAuthority(); if (authority != null) { authorityNames.add(Citations.getIdentifier(authority)); for (final Identifier id : authority.getIdentifiers()) { authorityNames.add(id.getCode());
for (authorityIndex = 0; authorityIndex < authorityCount; authorityIndex++) { final Citation candidate = authorities[authorityIndex]; if (Citations.identifierMatches(candidate, authority)) { authority = candidate; break;
iterator = c1.getIdentifiers().iterator(); if (!iterator.hasNext()) { return titleMatches(c1, c2); if (identifierMatches(c1, id)) { return true;
if (titleMatches(c1, asString)) { return true; if (asLocalized != asString && titleMatches(c1, asLocalized)) { return true;
final Parser parser = new Parser(); if (authority != null) { parser.setAuthority(Citations.fromName(authority));
/** 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")); }
/** * Returns a citation of the given name. If the given name matches a {@linkplain * Citation#getTitle title} or an {@linkplain Citation#getAlternateTitles alternate titles} * of one of the pre-defined constants ({@link #EPSG}, {@link #GEOTIFF}, <cite>etc.</cite>), * then this constant is returned. Otherwise, a new citation is created with the specified * name as the title. * * @param title The citation title (or alternate title). * @return A citation using the specified name */ public static Citation fromName(final String title) { for (int i=0; i<AUTHORITIES.length; i++) { final Citation citation = AUTHORITIES[i]; if (titleMatches(citation, title)) { return citation; } } return new CitationImpl(title); }
void registerAdditionalCRS() throws KlabException { URL epsg = null; File epp = new File(KLAB.CONFIG.getDataPath() + File.separator + "epsg.properties"); if (epp.exists()) { try { epsg = epp.toURI().toURL(); } catch (MalformedURLException e) { throw new KlabIOException(e); } } if (epsg != null) { Hints hints = new Hints(Hints.CRS_AUTHORITY_FACTORY, PropertyAuthorityFactory.class); ReferencingFactoryContainer referencingFactoryContainer = ReferencingFactoryContainer .instance(hints); PropertyAuthorityFactory factory; try { factory = new PropertyAuthorityFactory(referencingFactoryContainer, Citations .fromName("EPSG"), epsg); ReferencingFactoryFinder.addAuthorityFactory(factory); } catch (IOException e) { throw new KlabIOException(e); } } }
/** 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")); }