Java Code Examples for org.opengis.referencing.ReferenceIdentifier#getCodeSpace()
The following examples show how to use
org.opengis.referencing.ReferenceIdentifier#getCodeSpace() .
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: Identifiers.java From sis with Apache License 2.0 | 6 votes |
/** * Determines whether a match or mismatch is found between the two given collections of identifiers. * If any of the given collections is {@code null} or empty, then this method returns {@code null}. * * <p>According ISO 19162 (<cite>Well known text representation of coordinate reference systems</cite>), * {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#getIdentifiers() identifiers} should have precedence over * {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#getName() name} for identifying {@code IdentifiedObject}s, * at least in the case of {@linkplain org.apache.sis.referencing.operation.DefaultOperationMethod operation methods} and * {@linkplain org.apache.sis.parameter.AbstractParameterDescriptor parameters}.</p> * * @param id1 the first collection of identifiers, or {@code null}. * @param id2 the second collection of identifiers, or {@code null}. * @return {@code TRUE} or {@code FALSE} on match or mismatch respectively, or {@code null} if this method * can not determine if there is a match or mismatch. */ public static Boolean hasCommonIdentifier(final Iterable<? extends ReferenceIdentifier> id1, final Iterable<? extends ReferenceIdentifier> id2) { if (id1 != null && id2 != null) { boolean hasFound = false; for (final ReferenceIdentifier identifier : id1) { final Citation authority = identifier.getAuthority(); final String codeSpace = identifier.getCodeSpace(); for (final Identifier other : id2) { if (authorityMatches(identifier, authority, codeSpace)) { if (CharSequences.equalsFiltered(identifier.getCode(), other.getCode(), Characters.Filter.UNICODE_IDENTIFIER, true)) { return Boolean.TRUE; } hasFound = true; } } } if (hasFound) { return Boolean.FALSE; } } return null; }
Example 2
Source File: SimpleIdentifiedObject.java From sis with Apache License 2.0 | 6 votes |
/** * Returns a pseudo-WKT representation for debugging purpose. */ @Override public String toString() { final String code, codespace; final Citation authority; final ReferenceIdentifier name = this.name; if (name != null) { code = name.getCode(); codespace = name.getCodeSpace(); authority = name.getAuthority(); } else { code = null; codespace = null; authority = null; } final StringBuilder buffer = new StringBuilder("IdentifiedObject[\""); if (codespace != null) { buffer.append(codespace).append(Constants.DEFAULT_SEPARATOR); } buffer.append(code).append('"'); final String identifier = Identifiers.getIdentifier(authority, true); if (identifier != null) { buffer.append(", Id[\"").append(identifier).append("\"]"); // "Id" should be consistent with WKTKeywords.Id. } return buffer.append(']').toString(); }
Example 3
Source File: CoordinateOperationMethods.java From sis with Apache License 2.0 | 6 votes |
/** * Writes the primary name and aliases. */ private void writeName(final ParameterDescriptor<?> param) throws IOException { final int td = openTag("td class=\"sep\""); openTag("details"); final ReferenceIdentifier name = param.getName(); final String codeSpace = name.getCodeSpace(); if (Constants.EPSG.equalsIgnoreCase(codeSpace)) { println("summary", escape(name.getCode())); } else { println("summary", "<span class=\"non-epsg\">" + codeSpace + ":</span>" + "<code>" + name.getCode() + "</code>"); } openTag("table class=\"aliases\""); for (final GenericName alias : param.getAlias()) { reopenTag("tr"); println("th", escape(alias.head().toString() + ':')); println("td", escape(alias.tip().toString())); } closeTags(td); }
Example 4
Source File: IdentifiedObjectFormat.java From sis with Apache License 2.0 | 6 votes |
/** * Formats the given object. */ @Override public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) { final ReferenceIdentifier identifier = ((IdentifiedObject) obj).getName(); if (identifier == null) { return toAppendTo.append(Vocabulary.getResources(locale).getString(Vocabulary.Keys.Unnamed)); } if (identifier instanceof GenericName) { // The toString() behavior is specified by the GenericName javadoc. return toAppendTo.append(((GenericName) identifier).toInternationalString().toString(locale)); } final String code = identifier.getCode(); String cs = identifier.getCodeSpace(); if (cs == null || cs.isEmpty()) { cs = MetadataServices.getInstance().getUnicodeIdentifier(identifier.getAuthority()); } if (cs != null) { toAppendTo.append(cs).append(Constants.DEFAULT_SEPARATOR); } return toAppendTo.append(code); }
Example 5
Source File: MD_Identifier.java From sis with Apache License 2.0 | 5 votes |
/** * Invoked by JAXB at marshalling time for getting the actual metadata to write * inside the {@code <mcc:MD_Identifier>} or {@code RS_Identifier} XML element. * This is the value or a copy of the value given in argument to the {@code wrap} method. * * @return the metadata to be marshalled. */ @XmlElementRef public final DefaultIdentifier getElement() { if (FilterByVersion.LEGACY_METADATA.accept() && metadata instanceof ReferenceIdentifier) { /* * In legacy specification, "code space" and "version" were not defined in <gmd:MD_Identifier> but were * defined in <gmd:RS_Identifier> subclass. In newer specification there is no longer such special case. * Note that "description" did not existed anywhere in legacy specification. */ final ReferenceIdentifier id = (ReferenceIdentifier) metadata; if (id.getCodeSpace() != null || id.getVersion() != null) { return RS_Identifier.wrap(id); } } return DefaultIdentifier.castOrCopy(metadata); }
Example 6
Source File: ImmutableIdentifier.java From sis with Apache License 2.0 | 5 votes |
/** * Creates a new identifier from the specified one. This is a copy constructor which * get the code, codespace, authority and version from the given identifier. * * @param identifier the identifier to copy. * * @see #castOrCopy(ReferenceIdentifier) */ public ImmutableIdentifier(final ReferenceIdentifier identifier) { ensureNonNull("identifier", identifier); code = identifier.getCode(); codeSpace = identifier.getCodeSpace(); authority = identifier.getAuthority(); version = identifier.getVersion(); if (identifier instanceof DefaultIdentifier) { description = ((DefaultIdentifier) identifier).getDescription(); } else { description = null; } validate(null); }
Example 7
Source File: Code.java From sis with Apache License 2.0 | 5 votes |
/** * Creates a wrapper initialized to the values of the given identifier. * Version number, if presents, will be appended after the codespace with a semicolon separator. * The {@link #getIdentifier()} method shall be able to perform the opposite operation (split the * above in separated codespace and version attributes). * * @param identifier the identifier from which to get the values. */ Code(final ReferenceIdentifier identifier) { code = identifier.getCode(); codeSpace = identifier.getCodeSpace(); String version = identifier.getVersion(); if (version != null) { final StringBuilder buffer = new StringBuilder(); if (codeSpace != null) { buffer.append(codeSpace); } codeSpace = buffer.append(DefinitionURI.SEPARATOR).append(version).toString(); } }
Example 8
Source File: WKTUtilities.java From sis with Apache License 2.0 | 3 votes |
/** * Returns {@code true} if the given parameter is defined in the EPSG code space. We handle EPSG * parameters in a special way because Apache SIS uses the EPSG geodetic dataset as the primary * source of coordinate operation definitions. * * <p>We intentionally don't define {@code isEPSG(OperationMethod)} method because the operation * method may be the inverse of an EPSG method (for example "Inverse of Mercator (variant A)") * which would not be recognized. Instead, {@code isEPSG(method.getParameters())} should work.</p> * * @param descriptor the parameter or group of parameters to inspect. * @param ifUndefined the value to return if the code space is undefined. * @return whether the given parameter is an EPSG parameter. */ public static boolean isEPSG(final GeneralParameterDescriptor descriptor, final boolean ifUndefined) { if (descriptor != null) { final ReferenceIdentifier id = descriptor.getName(); if (id != null) { final String cs = id.getCodeSpace(); if (cs != null) { return Constants.EPSG.equalsIgnoreCase(cs); } } } return ifUndefined; }