Search in sources :

Example 1 with DefaultVerticalCRS

use of org.apache.sis.referencing.crs.DefaultVerticalCRS in project sis by apache.

the class StandardDefinitions method createVerticalCRS.

/**
 * Creates a vertical CRS from hard-coded values for the given code.
 *
 * @param  code   the EPSG code.
 * @param  datum  the vertical datum.
 * @return the vertical CRS for the given code.
 */
static VerticalCRS createVerticalCRS(final short code, final VerticalDatum datum) {
    // Default coordinate system
    String cs = "Vertical CS. Axis: height (H).";
    // EPSG code of above coordinate system.
    short c = 6499;
    // Axis of above coordinate system.
    short axis = 114;
    String wms = null;
    final String name, alias;
    switch(code) {
        case 5703:
            wms = "88";
            name = "NAVD88 height";
            alias = "North American Vertical Datum of 1988 height (m)";
            break;
        case 5714:
            name = "MSL height";
            alias = "mean sea level height";
            break;
        case 5715:
            name = "MSL depth";
            alias = "mean sea level depth";
            cs = "Vertical CS. Axis: depth (D).";
            c = 6498;
            axis = 113;
            break;
        default:
            throw new AssertionError(code);
    }
    final Map<String, Object> properties = properties(code, name, alias, true);
    if (wms != null) {
        addWMS(properties, wms);
    }
    return new DefaultVerticalCRS(properties, datum, new DefaultVerticalCS(properties(c, cs, null, false), createAxis(axis)));
}
Also used : DefaultVerticalCRS(org.apache.sis.referencing.crs.DefaultVerticalCRS) DefaultVerticalCS(org.apache.sis.referencing.cs.DefaultVerticalCS)

Example 2 with DefaultVerticalCRS

use of org.apache.sis.referencing.crs.DefaultVerticalCRS in project sis by apache.

the class MetadataTest method createHardCoded.

/**
 * Programmatically creates the metadata to marshall, or to compare against the unmarshalled metadata.
 *
 * @return the hard-coded representation of {@code "Metadata.xml"} content.
 */
private DefaultMetadata createHardCoded() {
    final DefaultMetadata metadata = new DefaultMetadata();
    metadata.setMetadataIdentifier(new DefaultIdentifier("Apache SIS/Metadata test"));
    metadata.setLanguages(singleton(Locale.ENGLISH));
    metadata.setCharacterSets(singleton(StandardCharsets.UTF_8));
    metadata.setMetadataScopes(singleton(new DefaultMetadataScope(ScopeCode.DATASET, "Common Data Index record")));
    metadata.setDateInfo(singleton(new DefaultCitationDate(TestUtilities.date("2009-01-01 04:00:00"), DateType.CREATION)));
    /*
         * Contact information for the author. The same party will be used for custodian and distributor,
         * with only the role changed. Note that we need to create an instance of the deprecated class,
         * because this is what will be unmarshalled from the XML document.
         */
    @SuppressWarnings("deprecation") final DefaultResponsibleParty author = new DefaultResponsibleParty(Role.AUTHOR);
    // Non-public SIS class.
    final Anchor country = new Anchor(URI.create("SDN:C320:2:FR"), "France");
    {
        final DefaultOnlineResource online = new DefaultOnlineResource(URI.create("http://www.ifremer.fr/sismer/"));
        online.setProtocol("http");
        final DefaultContact contact = new DefaultContact(online);
        contact.getIdentifierMap().putSpecialized(IdentifierSpace.ID, "IFREMER");
        contact.setPhones(Arrays.asList(telephone("+33 (0)2 xx.xx.xx.x6", "VOICE"), telephone("+33 (0)2 xx.xx.xx.x4", "FACSIMILE")));
        final DefaultAddress address = new DefaultAddress();
        address.setDeliveryPoints(singleton("Brest institute"));
        address.setCity(new SimpleInternationalString("Plouzane"));
        address.setPostalCode("29280");
        address.setCountry(country);
        address.setElectronicMailAddresses(singleton("xx@xx.fr"));
        contact.setAddresses(singleton(address));
        author.setParties(singleton(new DefaultOrganisation("Marine institutes", null, null, contact)));
        metadata.setContacts(singleton(author));
    }
    /*
         * Data indentification.
         */
    {
        final DefaultCitation citation = new DefaultCitation("90008411.ctd");
        citation.setAlternateTitles(singleton(new SimpleInternationalString("42292_5p_19900609195600")));
        citation.setDates(Arrays.asList(new DefaultCitationDate(TestUtilities.date("1990-06-04 22:00:00"), DateType.REVISION), new DefaultCitationDate(TestUtilities.date("1979-08-02 22:00:00"), DateType.CREATION)));
        {
            @SuppressWarnings("deprecation") final DefaultResponsibleParty originator = new DefaultResponsibleParty(Role.ORIGINATOR);
            final DefaultOnlineResource online = new DefaultOnlineResource(URI.create("http://www.com.univ-mrs.fr/LOB/"));
            online.setProtocol("http");
            final DefaultContact contact = new DefaultContact(online);
            contact.setPhones(Arrays.asList(telephone("+33 (0)4 xx.xx.xx.x5", "VOICE"), telephone("+33 (0)4 xx.xx.xx.x8", "FACSIMILE")));
            final DefaultAddress address = new DefaultAddress();
            address.setDeliveryPoints(singleton("Oceanology institute"));
            address.setCity(new SimpleInternationalString("Marseille"));
            address.setPostalCode("13288");
            address.setCountry(country);
            contact.setAddresses(singleton(address));
            originator.setParties(singleton(new DefaultOrganisation("Oceanology laboratory", null, null, contact)));
            citation.setCitedResponsibleParties(singleton(originator));
        }
        final DefaultDataIdentification identification = new DefaultDataIdentification(// Citation
        citation, // Abstract
        "CTD NEDIPROD VI 120", // Language,
        Locale.ENGLISH, // Topic category
        TopicCategory.OCEANS);
        {
            @SuppressWarnings("deprecation") final DefaultResponsibleParty custodian = new DefaultResponsibleParty((DefaultResponsibility) author);
            custodian.setRole(Role.CUSTODIAN);
            identification.setPointOfContacts(singleton(custodian));
        }
        /*
             * Data indentification / Keywords.
             */
        {
            final DefaultKeywords keyword = new DefaultKeywords(new Anchor(URI.create("SDN:P021:35:ATTN"), "Transmittance and attenuance of the water column"));
            keyword.setType(KeywordType.THEME);
            final DefaultCitation thesaurus = new DefaultCitation("BODC Parameter Discovery Vocabulary");
            thesaurus.setAlternateTitles(singleton(new SimpleInternationalString("P021")));
            thesaurus.setDates(singleton(new DefaultCitationDate(TestUtilities.date("2008-11-25 23:00:00"), DateType.REVISION)));
            thesaurus.setEdition(new Anchor(URI.create("SDN:C371:1:35"), "35"));
            thesaurus.setIdentifiers(singleton(new ImmutableIdentifier(null, null, "http://www.seadatanet.org/urnurl/")));
            keyword.setThesaurusName(thesaurus);
            identification.setDescriptiveKeywords(singleton(keyword));
        }
        /*
             * Data indentification / Browse graphic.
             */
        {
            final DefaultBrowseGraphic g = new DefaultBrowseGraphic(URI.create("file:///thumbnail.png"));
            g.setFileDescription(new SimpleInternationalString("Arbitrary thumbnail for this test only."));
            identification.setGraphicOverviews(singleton(g));
        }
        /*
             * Data indentification / Resource constraint.
             */
        {
            final DefaultLegalConstraints constraint = new DefaultLegalConstraints();
            constraint.setAccessConstraints(singleton(Restriction.LICENSE));
            identification.setResourceConstraints(singleton(constraint));
        }
        /*
             * Data indentification / Aggregate information.
             */
        {
            @SuppressWarnings("deprecation") final DefaultAggregateInformation aggregateInfo = new DefaultAggregateInformation();
            final DefaultCitation name = new DefaultCitation("MEDIPROD VI");
            name.setAlternateTitles(singleton(new SimpleInternationalString("90008411")));
            name.setDates(singleton(new DefaultCitationDate(TestUtilities.date("1990-06-04 22:00:00"), DateType.REVISION)));
            aggregateInfo.setName(name);
            aggregateInfo.setInitiativeType(InitiativeType.CAMPAIGN);
            // There is a typo ("WORD" → "WORK"), but we have to use the wrong spelling for this branch.
            aggregateInfo.setAssociationType(AssociationType.LARGER_WORD_CITATION);
            identification.setAggregationInfo(singleton(aggregateInfo));
        }
        /*
             * Data indentification / Extent.
             */
        {
            final DefaultCoordinateSystemAxis axis = new DefaultCoordinateSystemAxis(singletonMap(DefaultCoordinateSystemAxis.NAME_KEY, new NamedIdentifier(null, "Depth")), "d", AxisDirection.DOWN, Units.METRE);
            final DefaultVerticalCS cs = new DefaultVerticalCS(singletonMap(DefaultVerticalCS.NAME_KEY, new NamedIdentifier(null, "Depth")), axis);
            final DefaultVerticalDatum datum = new DefaultVerticalDatum(singletonMap(DefaultVerticalDatum.NAME_KEY, new NamedIdentifier(null, "D28")), VerticalDatumType.OTHER_SURFACE);
            final DefaultVerticalCRS vcrs = new DefaultVerticalCRS(singletonMap(DefaultVerticalCRS.NAME_KEY, new NamedIdentifier(null, "Depth below D28")), datum, cs);
            final DefaultTemporalExtent temporal = new DefaultTemporalExtent();
            setTemporalBounds(temporal, "1990-06-05", "1990-07-02");
            identification.setExtents(singleton(new DefaultExtent(null, new DefaultGeographicBoundingBox(1.1667, 1.1667, 36.6, 36.6), new DefaultVerticalExtent(Double.NaN, Double.NaN, vcrs), temporal)));
        }
        /*
             * Data identification / Environmental description and Supplemental information.
             */
        {
            identification.setEnvironmentDescription(new SimpleInternationalString("Possibly cloudy."));
            identification.setSupplementalInformation(new SimpleInternationalString("This metadata has been modified with dummy values."));
        }
        metadata.setIdentificationInfo(singleton(identification));
    }
    /*
         * Information about spatial representation.
         */
    {
        final DefaultVectorSpatialRepresentation rep = new DefaultVectorSpatialRepresentation();
        final DefaultGeometricObjects geoObj = new DefaultGeometricObjects(GeometricObjectType.POINT);
        rep.setGeometricObjects(singleton(geoObj));
        metadata.setSpatialRepresentationInfo(singleton(rep));
    }
    /*
         * Information about Coordinate Reference System.
         */
    {
        final DefaultCitation citation = new DefaultCitation("A geographic coordinate reference frames");
        citation.setAlternateTitles(singleton(new SimpleInternationalString("L101")));
        citation.setIdentifiers(singleton(new ImmutableIdentifier(null, null, "http://www.seadatanet.org/urnurl/")));
        citation.setEdition(new Anchor(URI.create("SDN:C371:1:2"), "2"));
        metadata.setReferenceSystemInfo(singleton(new ReferenceSystemMetadata(new ImmutableIdentifier(citation, "L101", "EPSG:4326"))));
    }
    /*
         * Information about content.
         */
    {
        final DefaultImageDescription contentInfo = new DefaultImageDescription();
        contentInfo.setCloudCoverPercentage(50.0);
        metadata.setContentInfo(singleton(contentInfo));
    }
    /*
         * Extension to metadata.
         */
    {
        final DefaultMetadataExtensionInformation extensionInfo = new DefaultMetadataExtensionInformation();
        extensionInfo.setExtendedElementInformation(singleton(new DefaultExtendedElementInformation(// Name
        "SDN:EDMO::", // Definition
        "http://www.seadatanet.org/urnurl/", // Condition
        null, // Data type
        Datatype.CODE_LIST, // Parent entity
        "SeaDataNet", // Rule
        null, // Source
        null)));
        metadata.setMetadataExtensionInfo(singleton(extensionInfo));
    }
    /*
         * Distribution information.
         */
    {
        @SuppressWarnings("deprecation") final DefaultResponsibleParty distributor = new DefaultResponsibleParty((DefaultResponsibility) author);
        final DefaultDistribution distributionInfo = new DefaultDistribution();
        distributor.setRole(Role.DISTRIBUTOR);
        distributionInfo.setDistributors(singleton(new DefaultDistributor(distributor)));
        final DefaultFormat format = new DefaultFormat();
        final DefaultCitation specification = new DefaultCitation();
        specification.setAlternateTitles(singleton(new Anchor(URI.create("SDN:L241:1:MEDATLAS"), "MEDATLAS ASCII")));
        specification.setEdition(new SimpleInternationalString("1.0"));
        format.setFormatSpecificationCitation(specification);
        distributionInfo.setDistributionFormats(singleton(format));
        final DefaultDigitalTransferOptions transfer = new DefaultDigitalTransferOptions();
        transfer.setTransferSize(2.431640625);
        final DefaultOnlineResource onlines = new DefaultOnlineResource(URI.create("http://www.ifremer.fr/data/something"));
        onlines.setDescription(new SimpleInternationalString("CTDF02"));
        onlines.setFunction(OnLineFunction.DOWNLOAD);
        onlines.setProtocol("http");
        transfer.setOnLines(singleton(onlines));
        distributionInfo.setTransferOptions(singleton(transfer));
        metadata.setDistributionInfo(distributionInfo);
    }
    return metadata;
}
Also used : DefaultVerticalCS(org.apache.sis.referencing.cs.DefaultVerticalCS) NamedIdentifier(org.apache.sis.referencing.NamedIdentifier) DefaultCoordinateSystemAxis(org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis) Anchor(org.apache.sis.internal.jaxb.gcx.Anchor) DefaultVerticalCRS(org.apache.sis.referencing.crs.DefaultVerticalCRS) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) ReferenceSystemMetadata(org.apache.sis.internal.jaxb.metadata.replace.ReferenceSystemMetadata) DefaultVerticalDatum(org.apache.sis.referencing.datum.DefaultVerticalDatum)

Example 3 with DefaultVerticalCRS

use of org.apache.sis.referencing.crs.DefaultVerticalCRS in project sis by apache.

the class CRS method getVerticalComponent.

/**
 * Returns the first vertical coordinate reference system found in the given CRS, or {@code null} if there is none.
 * If the given CRS is already an instance of {@code VerticalCRS}, then this method returns it as-is.
 * Otherwise if the given CRS is compound, then this method searches for the first vertical component
 * in the order of the {@linkplain #getSingleComponents(CoordinateReferenceSystem) single components list}.
 *
 * <div class="section">Height in a three-dimensional geographic CRS</div>
 * In ISO 19111 model, ellipsoidal heights are indissociable from geographic CRS because such heights
 * without their (<var>latitude</var>, <var>longitude</var>) locations make little sense. Consequently
 * a standard-conformant library should return {@code null} when asked for the {@code VerticalCRS}
 * component of a geographic CRS. This is what {@code getVerticalComponent(…)} does when the
 * {@code allowCreateEllipsoidal} argument is {@code false}.
 *
 * <p>However in some exceptional cases, handling ellipsoidal heights like any other kind of heights
 * may simplify the task. For example when computing <em>difference</em> between heights above the
 * same datum, the impact of ignoring locations may be smaller (but not necessarily canceled).
 * Orphan {@code VerticalCRS} may also be useful for information purpose like labeling a plot axis.
 * If the caller feels confident that ellipsoidal heights are safe for his task, he can set the
 * {@code allowCreateEllipsoidal} argument to {@code true}. In such case, this {@code getVerticalComponent(…)}
 * method will create a temporary {@code VerticalCRS} from the first three-dimensional {@code GeographicCRS}
 * <em>in last resort</em>, only if it can not find an existing {@code VerticalCRS} instance.
 * <strong>Note that this is not a valid CRS according ISO 19111</strong> — use with care.</p>
 *
 * @param  crs  the coordinate reference system, or {@code null}.
 * @param  allowCreateEllipsoidal {@code true} for allowing the creation of orphan CRS for ellipsoidal heights.
 *         The recommended value is {@code false}.
 * @return the first vertical CRS, or {@code null} if none.
 *
 * @see #compound(CoordinateReferenceSystem...)
 *
 * @category information
 */
public static VerticalCRS getVerticalComponent(final CoordinateReferenceSystem crs, final boolean allowCreateEllipsoidal) {
    if (crs instanceof VerticalCRS) {
        return (VerticalCRS) crs;
    }
    if (crs instanceof CompoundCRS) {
        final CompoundCRS cp = (CompoundCRS) crs;
        boolean a = false;
        do {
            // Executed at most twice.
            for (final CoordinateReferenceSystem c : cp.getComponents()) {
                final VerticalCRS candidate = getVerticalComponent(c, a);
                if (candidate != null) {
                    return candidate;
                }
            }
        } while ((a = !a) == allowCreateEllipsoidal);
    }
    if (allowCreateEllipsoidal && horizontalCode(crs) == 3) {
        final CoordinateSystem cs = crs.getCoordinateSystem();
        final int i = AxisDirections.indexOfColinear(cs, AxisDirection.UP);
        if (i >= 0) {
            final CoordinateSystemAxis axis = cs.getAxis(i);
            VerticalCRS c = CommonCRS.Vertical.ELLIPSOIDAL.crs();
            if (!c.getCoordinateSystem().getAxis(0).equals(axis)) {
                final Map<String, ?> properties = IdentifiedObjects.getProperties(c);
                c = new DefaultVerticalCRS(properties, c.getDatum(), new DefaultVerticalCS(properties, axis));
            }
            return c;
        }
    }
    return null;
}
Also used : DefaultVerticalCRS(org.apache.sis.referencing.crs.DefaultVerticalCRS) CoordinateSystem(org.opengis.referencing.cs.CoordinateSystem) DefaultVerticalCRS(org.apache.sis.referencing.crs.DefaultVerticalCRS) VerticalCRS(org.opengis.referencing.crs.VerticalCRS) CompoundCRS(org.opengis.referencing.crs.CompoundCRS) DefaultCompoundCRS(org.apache.sis.referencing.crs.DefaultCompoundCRS) CoordinateSystemAxis(org.opengis.referencing.cs.CoordinateSystemAxis) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) DefaultVerticalCS(org.apache.sis.referencing.cs.DefaultVerticalCS)

Aggregations

DefaultVerticalCRS (org.apache.sis.referencing.crs.DefaultVerticalCRS)3 DefaultVerticalCS (org.apache.sis.referencing.cs.DefaultVerticalCS)3 Anchor (org.apache.sis.internal.jaxb.gcx.Anchor)1 ReferenceSystemMetadata (org.apache.sis.internal.jaxb.metadata.replace.ReferenceSystemMetadata)1 NamedIdentifier (org.apache.sis.referencing.NamedIdentifier)1 DefaultCompoundCRS (org.apache.sis.referencing.crs.DefaultCompoundCRS)1 DefaultCoordinateSystemAxis (org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis)1 DefaultVerticalDatum (org.apache.sis.referencing.datum.DefaultVerticalDatum)1 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)1 CompoundCRS (org.opengis.referencing.crs.CompoundCRS)1 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)1 VerticalCRS (org.opengis.referencing.crs.VerticalCRS)1 CoordinateSystem (org.opengis.referencing.cs.CoordinateSystem)1 CoordinateSystemAxis (org.opengis.referencing.cs.CoordinateSystemAxis)1