/** * Checks if the specified authority can be recognized as the expected authority. This * implementation do not requires an exact matches. A matching title is enough. */ private boolean authorityMatches(final Citation citation) { if (authority == citation) { return true; } // The "null" locale argument is required for getting the unlocalized version. return (citation != null) && authority .getTitle() .toString(null) .equalsIgnoreCase(citation.getTitle().toString(null)); }
/** Logs a warning when an object can't be created from the specified factory. */ private static void log( final Exception exception, final AuthorityFactory factory, Level level) { final LogRecord record = Loggings.format( level, LoggingKeys.CANT_CREATE_COORDINATE_OPERATION_$1, factory.getAuthority().getTitle()); record.setSourceClassName(AuthorityBackedFactory.class.getName()); record.setSourceMethodName("createFromDatabase"); record.setThrown(exception); record.setLoggerName(LOGGER.getName()); LOGGER.log(record); }
public static String epsgCode(CoordinateReferenceSystem crs) { if (crs == null) { return null; } for (Iterator i = crs.getIdentifiers().iterator(); i.hasNext(); ) { Identifier id = (Identifier) i.next(); // return "EPSG:" + id.getCode(); if ((id.getAuthority() != null) && id.getAuthority().getTitle().equals(Citations.EPSG.getTitle())) { return id.getCode(); } } return null; }
/** Formats a name for the specified factory. */ private static String format(final Factory factory) { String name = Classes.getShortClassName(factory); if (factory instanceof AuthorityFactory) { name = name + "[\"" + ((AuthorityFactory) factory).getAuthority().getTitle() + "\"]"; } return name; }
/** * Returns the shortest identifier for the specified citation, or the title if there is no * identifier. This method is useful for extracting the namespace from an authority, for example * {@code "EPSG"}. * * @param citation The citation for which to get the identifier. * @return The shortest identifier of the given citation. * @since 2.4 */ public static String getIdentifier(final Citation citation) { String identifier = null; for (final Identifier id : citation.getIdentifiers()) { final String candidate = id.getCode().trim(); final int length = candidate.length(); if (length != 0) { if (identifier == null || length < identifier.length()) { identifier = candidate; } } } if (identifier == null) { identifier = String.valueOf(citation.getTitle()); } return identifier; } }
/** * Quickly review provided crs checking for an "EPSG:SRID" reference identifier. * * <p> * * @see CRS#lookupEpsgCode(CoordinateReferenceSystem, boolean) for full search * @param crs * @return srid or -1 if not found */ private static int toSRID(CoordinateReferenceSystem crs) { if (crs == null || crs.getIdentifiers() == null) { return -1; // not found } for (Iterator<ReferenceIdentifier> it = crs.getIdentifiers().iterator(); it.hasNext(); ) { ReferenceIdentifier id = it.next(); Citation authority = id.getAuthority(); if (authority != null && authority.getTitle().equals(Citations.EPSG.getTitle())) { try { return Integer.parseInt(id.getCode()); } catch (NumberFormatException nanException) { continue; } } } return -1; }
InternationalString candidate = citation.getTitle(); Iterator<? extends InternationalString> iterator = null; do {
private void getMetaDataStandard(Metadata metadata, DefaultMetadata defaultMetaData){ ArrayList<Citation> citationList= (ArrayList<Citation>) defaultMetaData.getMetadataStandards(); for(Citation c:citationList){ if(c.getTitle()!=null) metadata.add("MetaDataStandardTitle ",c.getTitle().toString()); if(c.getEdition()!=null) metadata.add("MetaDataStandardEdition ",c.getEdition().toString()); } } }
/** Returns the shortest title inferred from the specified authority. */ private static InternationalString getShortestTitle(final Citation authority) { InternationalString title = authority.getTitle(); int length = title.length(); final Collection<? extends InternationalString> alt = authority.getAlternateTitles(); if (alt != null) { for (final InternationalString candidate : alt) { final int candidateLength = candidate.length(); if (candidateLength > 0 && candidateLength < length) { title = candidate; length = candidateLength; } } } return title; }
InternationalString title = citation.getTitle(); if (titles != null) { for (final InternationalString candidate : titles) {
InternationalString candidate = c2.getTitle(); Iterator<? extends InternationalString> iterator = null; do {
/** * Creates an exception for an unknow authority code. This convenience method is provided for * implementation of {@code createXXX} methods. * * @param type The GeoAPI interface that was to be created (e.g. {@code * CoordinateReferenceSystem.class}). * @param code The unknow authority code. * @return An exception initialized with an error message built from the specified informations. */ protected final NoSuchAuthorityCodeException noSuchAuthorityCode( final Class type, final String code) { final InternationalString authority = getAuthority().getTitle(); return new NoSuchAuthorityCodeException( Errors.format(ErrorKeys.NO_SUCH_AUTHORITY_CODE_$3, code, authority, type), authority.toString(), code); } }
/** Returns a string representation of the specified object, for debugging purpose only. */ final String toString(final Class owner) { final AuthorityFactory factory = getAuthorityFactory(); return Classes.getShortName(owner) + '[' + Classes.getShortName(getType()) + " in " + Classes.getShortClassName(factory) + "(\"" + factory.getAuthority().getTitle() + "\")]"; }
/** Tests the vendor. */ @Test public void testVendor() { final Citation vendor = factory.getVendor(); assertNotNull(vendor); assertEquals("Geotools", vendor.getTitle().toString()); }
/** 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")); }
final String title = authority.getTitle().toString(null); for (final GenericName alias : aliases) { final GenericName scope = alias.scope().name();
/** 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")); }