Search in sources :

Example 61 with DefaultCitation

use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.

the class ServicesForUtility method createCitation.

/**
 * Returns the build-in citation for the given primary key, or {@code null}.
 *
 * @param  key  the primary key of the desired citation.
 * @return the requested citation, or {@code null} if unknown.
 *
 * @todo The content is hard-coded for now. But the plan for a future version is to fetch richer information
 *       from a database, including for example the responsible party and the URL. However that method would
 *       need to make sure that the given key is present in the alternate titles, since we rely on that when
 *       checking for code spaces.
 */
public static Citation createCitation(final String key) {
    CharSequence title;
    CharSequence alternateTitle = null;
    CharSequence edition = null;
    String code = null;
    String codeSpace = null;
    String version = null;
    Identifier[] alternateIdentifiers = null;
    CharSequence citedResponsibleParty = null;
    PresentationForm presentationForm = null;
    // Copy citedResponsibleParty from those citations.
    Citation[] copyFrom = null;
    switch(key) {
        case "ISO 19115-1":
            {
                title = "Geographic Information — Metadata Part 1: Fundamentals";
                edition = "ISO 19115-1:2014(E)";
                code = "19115-1";
                codeSpace = "ISO";
                version = "2014(E)";
                citedResponsibleParty = "International Organization for Standardization";
                presentationForm = PresentationForm.DOCUMENT_DIGITAL;
                break;
            }
        case "ISO 19115-2":
            {
                title = "Geographic Information — Metadata Part 2: Extensions for imagery and gridded data";
                edition = "ISO 19115-2:2009(E)";
                code = "19115-2";
                codeSpace = "ISO";
                version = "2009(E)";
                copyFrom = new Citation[] { Citations.ISO_19115.get(0) };
                presentationForm = PresentationForm.DOCUMENT_DIGITAL;
                break;
            }
        case "WMS":
            {
                // OGC title
                title = "Web Map Server";
                // ISO title
                alternateTitle = "Geographic Information — Web map server interface";
                alternateIdentifiers = new Identifier[] { new ImmutableIdentifier(null, "OGC", "06-042", null, null), new ImmutableIdentifier(null, "ISO", "19128", "2005", null) };
                edition = "1.3";
                code = "WMS";
                codeSpace = "OGC";
                copyFrom = new Citation[] { Citations.OGC, Citations.ISO_19115.get(0) };
                presentationForm = PresentationForm.DOCUMENT_DIGITAL;
                break;
            }
        case Constants.OGC:
            {
                title = "Identifiers in OGC namespace";
                code = Constants.OGC;
                citedResponsibleParty = "Open Geospatial Consortium";
                presentationForm = PresentationForm.DOCUMENT_DIGITAL;
                break;
            }
        case Constants.IOGP:
            {
                // Not in public API (see Citations.IOGP javadoc)
                // Geomatics Guidance Note number 7, part 1
                title = "Using the EPSG Geodetic Parameter Dataset";
                code = Constants.IOGP;
                copyFrom = new Citation[] { Citations.EPSG };
                presentationForm = PresentationForm.DOCUMENT_DIGITAL;
                break;
            }
        case Constants.EPSG:
            {
                title = "EPSG Geodetic Parameter Dataset";
                code = Constants.EPSG;
                codeSpace = Constants.IOGP;
                citedResponsibleParty = "International Association of Oil & Gas producers";
                presentationForm = PresentationForm.TABLE_DIGITAL;
                /*
                 * More complete information is provided as an ISO 19115 structure
                 * in EPSG Surveying and Positioning Guidance Note Number 7, part 1.
                 * EPSGDataAccess.getAuthority() also add more information.
                 * After we moved the content of this citation in a database,
                 * EPSGDataAccess.getAuthority() should use this citation as a template.
                 */
                break;
            }
        case Constants.SIS:
            {
                title = "Apache Spatial Information System";
                code = key;
                break;
            }
        case "ISBN":
            {
                title = "International Standard Book Number";
                alternateTitle = key;
                break;
            }
        case "ISSN":
            {
                title = "International Standard Serial Number";
                alternateTitle = key;
                break;
            }
        case Constants.PROJ4:
            {
                title = "Proj.4";
                break;
            }
        case "S57":
            {
                title = "S-57";
                break;
            }
        default:
            return null;
    }
    /*
         * Do not use the 'c.getFoo().add(foo)' pattern below. Use the 'c.setFoo(singleton(foo))' pattern instead.
         * This is because this method may be invoked during XML serialization, in which case some getter methods
         * may return null (for preventing JAXB to marshal some empty elements).
         */
    final DefaultCitation c = new DefaultCitation(title);
    if (alternateTitle != null)
        c.setAlternateTitles(singleton(Types.toInternationalString(alternateTitle)));
    if (edition != null)
        c.setEdition(Types.toInternationalString(edition));
    if (code != null)
        c.setIdentifiers(singleton(new ImmutableIdentifier(null, codeSpace, code, version, null)));
    if (presentationForm != null)
        c.setPresentationForms(singleton(presentationForm));
    if (citedResponsibleParty != null) {
        final DefaultResponsibleParty r = new DefaultResponsibleParty(Role.PRINCIPAL_INVESTIGATOR);
        r.setParties(singleton(new DefaultOrganisation(citedResponsibleParty, null, null, null)));
        c.setCitedResponsibleParties(singleton(r));
    }
    if (copyFrom != null) {
        for (final Citation other : copyFrom) {
            final Collection<? extends ResponsibleParty> parties = other.getCitedResponsibleParties();
            final Collection<ResponsibleParty> current = c.getCitedResponsibleParties();
            if (current != null) {
                current.addAll(parties);
            } else {
                c.setCitedResponsibleParties(parties);
            }
        }
    }
    if (alternateIdentifiers != null) {
        // getIdentifiers() should not return null at this point.
        c.getIdentifiers().addAll(Arrays.asList(alternateIdentifiers));
    }
    c.freeze();
    return c;
}
Also used : DefaultOrganisation(org.apache.sis.metadata.iso.citation.DefaultOrganisation) DefaultResponsibleParty(org.apache.sis.metadata.iso.citation.DefaultResponsibleParty) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) DefaultResponsibleParty(org.apache.sis.metadata.iso.citation.DefaultResponsibleParty) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier) Identifier(org.opengis.metadata.Identifier) PresentationForm(org.opengis.metadata.citation.PresentationForm) Citation(org.opengis.metadata.citation.Citation) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier)

Example 62 with DefaultCitation

use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.

the class CodeTest method testLegacyCodeSpace.

/**
 * Tests {@link Code#forIdentifiedObject(Class, Iterable)} with the legacy "OGP" codespace
 * (instead of "IOGP").
 */
@Test
@DependsOnMethod("testForIdentifiedObject")
public void testLegacyCodeSpace() {
    final DefaultCitation authority = new DefaultCitation("EPSG");
    authority.getIdentifiers().add(new ImmutableIdentifier(null, "OGP", "EPSG"));
    final ReferenceIdentifier id = new ImmutableIdentifier(authority, "EPSG", "4326", "8.2", null);
    final Code value = Code.forIdentifiedObject(GeographicCRS.class, Collections.singleton(id));
    assertNotNull(value);
    assertEquals("codeSpace", "OGP", value.codeSpace);
    assertEquals("code", "urn:ogc:def:crs:EPSG:8.2:4326", value.code);
}
Also used : ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 63 with DefaultCitation

use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.

the class DefaultAggregateInformation method setAggregateDataSetIdentifier.

/**
 * Sets the identification information about aggregate dataset.
 *
 * @param  newValue  the new identifier.
 *
 * @deprecated As of ISO 19115:2014, replaced by an identifier of {@link #getAggregateDataSetName()}.
 */
@Deprecated
public void setAggregateDataSetIdentifier(final Identifier newValue) {
    checkWritePermission();
    Citation name = getAggregateDataSetName();
    if (newValue != null) {
        if (!(name instanceof DefaultCitation)) {
            name = new DefaultCitation(name);
            setAggregateDataSetName(name);
        }
        /*
             * If there is more than one value, replace only the first one and keep all other ones unchanged.
             * The intent is to be consistent with the getter method, which returns the first element.
             */
        final ArrayList<Identifier> identifiers = new ArrayList<>(name.getIdentifiers());
        if (identifiers.isEmpty()) {
            identifiers.add(newValue);
        } else {
            identifiers.set(0, newValue);
        }
        ((DefaultCitation) name).setIdentifiers(identifiers);
    } else if (name != null) {
        final Iterator<? extends Identifier> it = name.getIdentifiers().iterator();
        if (it.hasNext()) {
            it.next();
            it.remove();
        }
    }
}
Also used : Identifier(org.opengis.metadata.Identifier) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Citation(org.opengis.metadata.citation.Citation) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation)

Example 64 with DefaultCitation

use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.

the class Proj4Factory method getAuthority.

/**
 * Returns the project that defines the codes recognized by this factory.
 * The authority determines the {@linkplain #getCodeSpaces() code space}.
 *
 * @return {@link Citations#PROJ4}.
 */
@Override
public Citation getAuthority() {
    Citation c = authority;
    if (c == null) {
        c = Citations.PROJ4;
        final String release = Proj4.version();
        if (release != null) {
            final DefaultCitation df = new DefaultCitation(c);
            df.setEdition(new SimpleInternationalString(release));
            df.freeze();
            c = df;
        }
        authority = c;
    }
    return c;
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Citation(org.opengis.metadata.citation.Citation) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString)

Example 65 with DefaultCitation

use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.

the class DirectReferenceSystemTest method createMetadata.

/**
 * Creates the metadata object to be tested.
 *
 * @param  legacy  {@code true} for using the legacy {@code ResponsibleParty} instead of {@code Responsibility}.
 *                 This is sometime needed for comparison purpose with unmarshalled metadata.
 */
@SuppressWarnings("deprecation")
private static DefaultMetadata createMetadata(final boolean legacy) {
    final DefaultMetadata metadata = new DefaultMetadata();
    final DefaultCitation citation = new DefaultCitation("EPSG Geodetic Parameter Dataset");
    Collection<ResponsibleParty> r = HardCodedCitations.EPSG.getCitedResponsibleParties();
    if (legacy) {
        r = singleton(new DefaultResponsibleParty(TestUtilities.getSingleton(r)));
    }
    citation.setCitedResponsibleParties(r);
    final DirectReferenceSystem refSys = new DirectReferenceSystem(new ImmutableIdentifier(citation, null, "4326"));
    metadata.setReferenceSystemInfo(singleton(refSys));
    return metadata;
}
Also used : DefaultResponsibleParty(org.apache.sis.metadata.iso.citation.DefaultResponsibleParty) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) DefaultMetadata(org.apache.sis.metadata.iso.DefaultMetadata) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) DefaultResponsibleParty(org.apache.sis.metadata.iso.citation.DefaultResponsibleParty) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier)

Aggregations

DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)65 Test (org.junit.Test)35 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)32 DependsOnMethod (org.apache.sis.test.DependsOnMethod)21 InternationalString (org.opengis.util.InternationalString)14 Citation (org.opengis.metadata.citation.Citation)10 IdentifiedObject (org.opengis.referencing.IdentifiedObject)9 ImmutableIdentifier (org.apache.sis.metadata.iso.ImmutableIdentifier)5 DefaultResponsibleParty (org.apache.sis.metadata.iso.citation.DefaultResponsibleParty)5 URI (java.net.URI)3 DefaultIdentifier (org.apache.sis.metadata.iso.DefaultIdentifier)3 DefaultMetadata (org.apache.sis.metadata.iso.DefaultMetadata)3 DefaultCitationTest (org.apache.sis.metadata.iso.citation.DefaultCitationTest)3 DefaultOnlineResource (org.apache.sis.metadata.iso.citation.DefaultOnlineResource)3 ArrayList (java.util.ArrayList)2 CI_Citation (org.apache.sis.internal.jaxb.metadata.CI_Citation)2 SimpleIdentifiedObject (org.apache.sis.internal.simple.SimpleIdentifiedObject)2 SimpleIdentifier (org.apache.sis.internal.simple.SimpleIdentifier)2 DefaultCitationDate (org.apache.sis.metadata.iso.citation.DefaultCitationDate)2 DefaultIndividual (org.apache.sis.metadata.iso.citation.DefaultIndividual)2