Search in sources :

Example 31 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class Types method create.

/**
 * Adds internationalized designation and definition information for all properties in the given type.
 * Then, returns the result of {@link FeatureTypeBuilder#build()}.
 *
 * @param  builder   the feature type builder for which to add designations and definitions.
 * @param  previous  previously created international strings as array of length 2.
 *                   The first element is the designation and the second element is the definition.
 */
private static DefaultFeatureType create(final FeatureTypeBuilder builder, final Map<String, InternationalString[]> previous) {
    for (final PropertyTypeBuilder p : builder.properties()) {
        final GenericName name = p.getName();
        if (!AttributeConvention.contains(name)) {
            final InternationalString[] resources = previous.computeIfAbsent(name.toString(), (key) -> new InternationalString[] { new ResourceInternationalString("org.apache.sis.internal.storage.gpx.Designations", key), new ResourceInternationalString("org.apache.sis.internal.storage.gpx.Definitions", key) });
            p.setDefinition(resources[1]);
            p.setDesignation(resources[0]);
        }
    }
    return builder.build();
}
Also used : PropertyTypeBuilder(org.apache.sis.feature.builder.PropertyTypeBuilder) GenericName(org.opengis.util.GenericName) ResourceInternationalString(org.apache.sis.util.iso.ResourceInternationalString) InternationalString(org.opengis.util.InternationalString) ResourceInternationalString(org.apache.sis.util.iso.ResourceInternationalString)

Example 32 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class Formatter method appendOnNewLine.

/**
 * Appends an international text in an element having the given keyword. Since this method
 * is typically invoked for long descriptions, the element will be written on its own line.
 *
 * <div class="note"><b>Example:</b>
 *   <ul>
 *     <li>{@code Scope["Large scale topographic mapping and cadastre."]}</li>
 *     <li>{@code Area["Netherlands offshore."]}</li>
 *   </ul>
 * </div>
 *
 * @param  keyword  the {@linkplain KeywordCase#CAMEL_CASE camel-case} keyword.
 *                  Example: {@code "Scope"}, {@code "Area"} or {@code "Remarks"}.
 * @param  text     the text, or {@code null} if none.
 * @param  type     the key of the colors to apply if syntax coloring is enabled.
 */
private void appendOnNewLine(final String keyword, final InternationalString text, final ElementKind type) {
    ArgumentChecks.ensureNonNull("keyword", keyword);
    if (text != null) {
        final String localized = CharSequences.trimWhitespaces(text.toString(locale));
        if (localized != null && !localized.isEmpty()) {
            openElement(true, keyword);
            quote(localized, type);
            closeElement(true);
        }
    }
}
Also used : InternationalString(org.opengis.util.InternationalString)

Example 33 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class EPSGDataAccess method createProperties.

/**
 * Returns the name and aliases for the {@link IdentifiedObject} to construct.
 *
 * @param  table       the table on which a query has been executed.
 * @param  name        the name for the {@link IdentifiedObject} to construct.
 * @param  code        the EPSG code of the object to construct.
 * @param  remarks     remarks as a {@link String} or {@link InternationalString}, or {@code null} if none.
 * @param  deprecated  {@code true} if the object to create is deprecated.
 * @return the name together with a set of properties.
 */
@SuppressWarnings("ReturnOfCollectionOrArrayField")
private Map<String, Object> createProperties(final String table, String name, final Integer code, CharSequence remarks, final boolean deprecated) throws SQLException, FactoryDataException {
    /*
         * Search for aliases. Note that searching for the object code is not sufficient. We also need to check if the
         * record is really from the table we are looking for since different tables may have objects with the same ID.
         *
         * Some aliases are identical to the name except that some letters are replaced by their accented letters.
         * For example "Reseau Geodesique Francais" → "Réseau Géodésique Français". If we find such alias, replace
         * the name by the alias so we have proper display in user interface. Notes:
         *
         *   - WKT formatting will still be compliant with ISO 19162 because the WKT formatter replaces accented
         *     letters by ASCII ones.
         *   - We do not perform this replacement directly in our EPSG database because ASCII letters are more
         *     convenient for implementing accent-insensitive searches.
         */
    final List<GenericName> aliases = new ArrayList<>();
    try (ResultSet result = executeQuery("Alias", "SELECT OBJECT_TABLE_NAME, NAMING_SYSTEM_NAME, ALIAS" + " FROM [Alias] INNER JOIN [Naming System]" + " ON [Alias].NAMING_SYSTEM_CODE =" + " [Naming System].NAMING_SYSTEM_CODE" + " WHERE OBJECT_CODE = ?", code)) {
        while (result.next()) {
            if (tableMatches(table, result.getString(1))) {
                final String naming = getOptionalString(result, 2);
                final String alias = getString(code, result, 3);
                NameSpace ns = null;
                if (naming != null) {
                    ns = namingSystems.get(naming);
                    if (ns == null) {
                        ns = owner.nameFactory.createNameSpace(owner.nameFactory.createLocalName(null, naming), null);
                        namingSystems.put(naming, ns);
                    }
                }
                if (CharSequences.toASCII(alias).toString().equals(name)) {
                    name = alias;
                } else {
                    aliases.add(owner.nameFactory.createLocalName(ns, alias));
                }
            }
        }
    }
    /*
         * At this point we can fill the properties map.
         */
    properties.clear();
    GenericName gn = null;
    final Locale locale = getLocale();
    final Citation authority = owner.getAuthority();
    final InternationalString edition = authority.getEdition();
    final String version = (edition != null) ? edition.toString() : null;
    if (name != null) {
        gn = owner.nameFactory.createGenericName(namespace, Constants.EPSG, name);
        properties.put("name", gn);
        properties.put(NamedIdentifier.CODE_KEY, name);
        properties.put(NamedIdentifier.VERSION_KEY, version);
        properties.put(NamedIdentifier.AUTHORITY_KEY, authority);
        properties.put(AbstractIdentifiedObject.LOCALE_KEY, locale);
        final NamedIdentifier id = new NamedIdentifier(properties);
        properties.clear();
        properties.put(IdentifiedObject.NAME_KEY, id);
    }
    if (!aliases.isEmpty()) {
        properties.put(IdentifiedObject.ALIAS_KEY, aliases.toArray(new GenericName[aliases.size()]));
    }
    if (code != null) {
        final String codeString = code.toString();
        final ImmutableIdentifier identifier;
        if (deprecated) {
            final String replacedBy = getSupersession(table, code, locale);
            identifier = new DeprecatedCode(authority, Constants.EPSG, codeString, version, Character.isDigit(replacedBy.charAt(0)) ? replacedBy : null, Vocabulary.formatInternational(Vocabulary.Keys.SupersededBy_1, replacedBy));
            properties.put(AbstractIdentifiedObject.DEPRECATED_KEY, Boolean.TRUE);
        } else {
            identifier = new ImmutableIdentifier(authority, Constants.EPSG, codeString, version, (gn != null) ? gn.toInternationalString() : null);
        }
        properties.put(IdentifiedObject.IDENTIFIERS_KEY, identifier);
    }
    properties.put(IdentifiedObject.REMARKS_KEY, remarks);
    properties.put(AbstractIdentifiedObject.LOCALE_KEY, locale);
    properties.put(ReferencingServices.MT_FACTORY, owner.mtFactory);
    return properties;
}
Also used : Locale(java.util.Locale) GenericName(org.opengis.util.GenericName) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) NamedIdentifier(org.apache.sis.referencing.NamedIdentifier) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) NameSpace(org.opengis.util.NameSpace) DefaultNameSpace(org.apache.sis.util.iso.DefaultNameSpace) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Citation(org.opengis.metadata.citation.Citation) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) DeprecatedCode(org.apache.sis.internal.referencing.DeprecatedCode) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier)

Example 34 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class DefaultFormula method formatTo.

/**
 * Formats this formula as a pseudo-<cite>Well Known Text</cite> element.
 *
 * <div class="note"><b>Compatibility note:</b>
 * ISO 19162 does not define a WKT representation for {@code Formula} objects.
 * The text formatted by this method is SIS-specific and causes the text to be
 * flagged as {@linkplain Formatter#setInvalidWKT(Class, Exception) invalid WKT}.
 * The WKT content of this element may change in any future SIS version.</div>
 *
 * @return {@code "Formula"}.
 */
@Override
protected String formatTo(final Formatter formatter) {
    InternationalString text = null;
    // Gives to users a chance to override properties.
    final Citation citation = getCitation();
    if (citation != null) {
        text = citation.getTitle();
    }
    if (text == null) {
        text = getFormula();
    }
    if (text != null) {
        formatter.append(text.toString(formatter.getLocale()), ElementKind.REMARKS);
    }
    formatter.setInvalidWKT(Formula.class, null);
    return WKTKeywords.Formula;
}
Also used : InternationalString(org.opengis.util.InternationalString) Citation(org.opengis.metadata.citation.Citation)

Example 35 with InternationalString

use of org.opengis.util.InternationalString in project tika by apache.

the class GeographicInformationParser method getMetaDataIdentificationInfo.

private void getMetaDataIdentificationInfo(Metadata metadata, DefaultMetadata defaultMetaData) {
    ArrayList<Identification> identifications = (ArrayList<Identification>) defaultMetaData.getIdentificationInfo();
    for (Identification i : identifications) {
        DefaultDataIdentification defaultDataIdentification = (DefaultDataIdentification) i;
        if (i.getCitation() != null && i.getCitation().getTitle() != null)
            metadata.add("IdentificationInfoCitationTitle ", i.getCitation().getTitle().toString());
        ArrayList<CitationDate> dateArrayList = (ArrayList<CitationDate>) i.getCitation().getDates();
        for (CitationDate d : dateArrayList) {
            if (d.getDateType() != null)
                metadata.add("CitationDate ", d.getDateType().name() + "-->" + d.getDate());
        }
        ArrayList<ResponsibleParty> responsiblePartyArrayList = (ArrayList<ResponsibleParty>) i.getCitation().getCitedResponsibleParties();
        for (ResponsibleParty r : responsiblePartyArrayList) {
            if (r.getRole() != null)
                metadata.add("CitedResponsiblePartyRole ", r.getRole().toString());
            if (r.getIndividualName() != null)
                metadata.add("CitedResponsiblePartyName ", r.getIndividualName().toString());
            if (r.getOrganisationName() != null)
                metadata.add("CitedResponsiblePartyOrganizationName ", r.getOrganisationName().toString());
            if (r.getPositionName() != null)
                metadata.add("CitedResponsiblePartyPositionName ", r.getPositionName().toString());
            if (r.getContactInfo() != null) {
                for (String s : r.getContactInfo().getAddress().getElectronicMailAddresses()) {
                    metadata.add("CitedResponsiblePartyEMail ", s.toString());
                }
            }
        }
        if (i.getAbstract() != null)
            metadata.add("IdentificationInfoAbstract ", i.getAbstract().toString());
        for (Progress p : i.getStatus()) {
            metadata.add("IdentificationInfoStatus ", p.name());
        }
        ArrayList<Format> formatArrayList = (ArrayList<Format>) i.getResourceFormats();
        for (Format f : formatArrayList) {
            if (f.getName() != null)
                metadata.add("ResourceFormatSpecificationAlternativeTitle ", f.getName().toString());
        }
        CheckedHashSet<Locale> localeCheckedHashSet = (CheckedHashSet<Locale>) defaultDataIdentification.getLanguages();
        for (Locale l : localeCheckedHashSet) {
            metadata.add("IdentificationInfoLanguage-->", l.getDisplayLanguage(Locale.ENGLISH));
        }
        CodeListSet<TopicCategory> categoryList = (CodeListSet<TopicCategory>) defaultDataIdentification.getTopicCategories();
        for (TopicCategory t : categoryList) {
            metadata.add("IdentificationInfoTopicCategory-->", t.name());
        }
        ArrayList<Keywords> keywordList = (ArrayList<Keywords>) i.getDescriptiveKeywords();
        int j = 1;
        for (Keywords k : keywordList) {
            j++;
            ArrayList<InternationalString> stringList = (ArrayList<InternationalString>) k.getKeywords();
            for (InternationalString s : stringList) {
                metadata.add("Keywords " + j, s.toString());
            }
            if (k.getType() != null)
                metadata.add("KeywordsType " + j, k.getType().name());
            if (k.getThesaurusName() != null && k.getThesaurusName().getTitle() != null)
                metadata.add("ThesaurusNameTitle " + j, k.getThesaurusName().getTitle().toString());
            if (k.getThesaurusName() != null && k.getThesaurusName().getAlternateTitles() != null)
                metadata.add("ThesaurusNameAlternativeTitle " + j, k.getThesaurusName().getAlternateTitles().toString());
            ArrayList<CitationDate> citationDates = (ArrayList<CitationDate>) k.getThesaurusName().getDates();
            for (CitationDate cd : citationDates) {
                if (cd.getDateType() != null)
                    metadata.add("ThesaurusNameDate ", cd.getDateType().name() + "-->" + cd.getDate());
            }
        }
        ArrayList<DefaultLegalConstraints> constraintList = (ArrayList<DefaultLegalConstraints>) i.getResourceConstraints();
        for (DefaultLegalConstraints c : constraintList) {
            for (Restriction r : c.getAccessConstraints()) {
                metadata.add("AccessContraints ", r.name());
            }
            for (InternationalString s : c.getOtherConstraints()) {
                metadata.add("OtherConstraints ", s.toString());
            }
            for (Restriction r : c.getUseConstraints()) {
                metadata.add("UserConstraints ", r.name());
            }
        }
        Collection<Extent> extentList = ((DefaultDataIdentification) i).getExtents();
        for (Extent e : extentList) {
            ArrayList<GeographicExtent> geoElements = (ArrayList<GeographicExtent>) e.getGeographicElements();
            for (GeographicExtent g : geoElements) {
                if (g instanceof DefaultGeographicDescription) {
                    if (((DefaultGeographicDescription) g).getGeographicIdentifier() != null && ((DefaultGeographicDescription) g).getGeographicIdentifier().getCode() != null)
                        metadata.add("GeographicIdentifierCode ", ((DefaultGeographicDescription) g).getGeographicIdentifier().getCode().toString());
                    if (((DefaultGeographicDescription) g).getGeographicIdentifier() != null && ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority() != null && ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority().getTitle() != null)
                        metadata.add("GeographicIdentifierAuthorityTitle ", ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority().getTitle().toString());
                    for (InternationalString s : ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority().getAlternateTitles()) {
                        metadata.add("GeographicIdentifierAuthorityAlternativeTitle ", s.toString());
                    }
                    for (CitationDate cd : ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority().getDates()) {
                        if (cd.getDateType() != null && cd.getDate() != null)
                            metadata.add("GeographicIdentifierAuthorityDate ", cd.getDateType().name() + " " + cd.getDate().toString());
                    }
                }
            }
        }
    }
}
Also used : Locale(java.util.Locale) CodeListSet(org.apache.sis.util.collection.CodeListSet) Keywords(org.opengis.metadata.identification.Keywords) GeographicExtent(org.opengis.metadata.extent.GeographicExtent) Extent(org.opengis.metadata.extent.Extent) CheckedArrayList(org.apache.sis.internal.util.CheckedArrayList) ArrayList(java.util.ArrayList) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) Identification(org.opengis.metadata.identification.Identification) InternationalString(org.opengis.util.InternationalString) Format(org.opengis.metadata.distribution.Format) DefaultLegalConstraints(org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) CitationDate(org.opengis.metadata.citation.CitationDate) Progress(org.opengis.metadata.identification.Progress) TopicCategory(org.opengis.metadata.identification.TopicCategory) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) CheckedHashSet(org.apache.sis.internal.util.CheckedHashSet) GeographicExtent(org.opengis.metadata.extent.GeographicExtent) DefaultGeographicDescription(org.apache.sis.metadata.iso.extent.DefaultGeographicDescription) Restriction(org.opengis.metadata.constraint.Restriction) InternationalString(org.opengis.util.InternationalString)

Aggregations

InternationalString (org.opengis.util.InternationalString)86 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)20 Test (org.junit.Test)17 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)13 IdentifiedObject (org.opengis.referencing.IdentifiedObject)10 ArrayList (java.util.ArrayList)7 Locale (java.util.Locale)6 GenericName (org.opengis.util.GenericName)6 Extent (org.opengis.metadata.extent.Extent)5 DefaultDataIdentification (org.apache.sis.metadata.iso.identification.DefaultDataIdentification)4 DependsOnMethod (org.apache.sis.test.DependsOnMethod)4 Vocabulary (org.apache.sis.util.resources.Vocabulary)4 Citation (org.opengis.metadata.citation.Citation)4 IllegalArgumentException (com.sun.star.lang.IllegalArgumentException)3 ResultSet (java.sql.ResultSet)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 TableAppender (org.apache.sis.io.TableAppender)3 AbstractIdentifiedObject (org.apache.sis.referencing.AbstractIdentifiedObject)3 DataStoreException (org.apache.sis.storage.DataStoreException)3