Search in sources :

Example 1 with VerticalCS

use of org.opengis.referencing.cs.VerticalCS in project sis by apache.

the class MetadataTest method testMetadataWithVerticalCRS.

/**
 * Tests the (un)marshalling of a metadata with a vertical CRS.
 *
 * @throws JAXBException if the (un)marshalling process fails.
 */
@Test
public void testMetadataWithVerticalCRS() throws JAXBException {
    final Metadata metadata = unmarshalFile(Metadata.class, VERTICAL_CRS_XML);
    if (REGRESSION) {
        ((DefaultMetadata) metadata).setCharacterSet(CharacterSet.UTF_8);
    }
    assertEquals("fileIdentifier", "20090901", metadata.getFileIdentifier());
    assertEquals("language", Locale.ENGLISH, metadata.getLanguage());
    assertEquals("characterSet", CharacterSet.UTF_8, metadata.getCharacterSet());
    assertEquals("dateStamp", xmlDate("2014-01-04 00:00:00"), metadata.getDateStamp());
    /*
         * <gmd:contact>
         *   <gmd:CI_ResponsibleParty>
         *     …
         *   </gmd:CI_ResponsibleParty>
         * </gmd:contact>
         */
    final ResponsibleParty contact = getSingleton(metadata.getContacts());
    final OnlineResource onlineResource = contact.getContactInfo().getOnlineResource();
    assertNotNull("onlineResource", onlineResource);
    assertEquals("organisationName", "Apache SIS", contact.getOrganisationName().toString());
    assertEquals("linkage", URI.create("http://sis.apache.org"), onlineResource.getLinkage());
    assertEquals("function", OnLineFunction.INFORMATION, onlineResource.getFunction());
    assertEquals("role", Role.PRINCIPAL_INVESTIGATOR, contact.getRole());
    /*
         * <gmd:spatialRepresentationInfo>
         *   <gmd:MD_VectorSpatialRepresentation>
         *     …
         *   </gmd:MD_VectorSpatialRepresentation>
         * </gmd:spatialRepresentationInfo>
         */
    final SpatialRepresentation spatial = getSingleton(metadata.getSpatialRepresentationInfo());
    assertInstanceOf("spatialRepresentationInfo", VectorSpatialRepresentation.class, spatial);
    assertEquals("geometricObjectType", GeometricObjectType.POINT, getSingleton(((VectorSpatialRepresentation) spatial).getGeometricObjects()).getGeometricObjectType());
    /*
         * <gmd:referenceSystemInfo>
         *   <gmd:MD_ReferenceSystem>
         *     …
         *   </gmd:MD_ReferenceSystem>
         * </gmd:referenceSystemInfo>
         */
    assertIdentifierEquals("referenceSystemInfo", null, "EPSG", null, "World Geodetic System 84", getSingleton(metadata.getReferenceSystemInfo()).getName());
    /*
         * <gmd:identificationInfo>
         *   <gmd:MD_DataIdentification>
         *     …
         */
    final DataIdentification identification = (DataIdentification) getSingleton(metadata.getIdentificationInfo());
    final Citation citation = identification.getCitation();
    assertInstanceOf("citation", NilObject.class, citation);
    assertEquals("nilReason", NilReason.MISSING, ((NilObject) citation).getNilReason());
    assertEquals("abstract", "SIS test", identification.getAbstract().toString());
    assertEquals("language", Locale.ENGLISH, getSingleton(identification.getLanguages()));
    /*
         * <gmd:geographicElement>
         *   <gmd:EX_GeographicBoundingBox>
         *     …
         *   </gmd:EX_GeographicBoundingBox>
         * </gmd:geographicElement>
         */
    final Extent extent = getSingleton(identification.getExtents());
    final GeographicBoundingBox bbox = (GeographicBoundingBox) getSingleton(extent.getGeographicElements());
    assertEquals("extentTypeCode", Boolean.TRUE, bbox.getInclusion());
    assertEquals("westBoundLongitude", 4.55, bbox.getWestBoundLongitude(), STRICT);
    assertEquals("eastBoundLongitude", 4.55, bbox.getEastBoundLongitude(), STRICT);
    assertEquals("southBoundLatitude", 44.22, bbox.getSouthBoundLatitude(), STRICT);
    assertEquals("northBoundLatitude", 44.22, bbox.getNorthBoundLatitude(), STRICT);
    /*
         * <gmd:verticalElement>
         *   <gmd:EX_VerticalExtent>
         *     …
         *   </gmd:EX_VerticalExtent>
         * </gmd:verticalElement>
         */
    final VerticalExtent ve = getSingleton(extent.getVerticalElements());
    assertEquals("minimumValue", 0.1, ve.getMinimumValue(), STRICT);
    assertEquals("maximumValue", 10000, ve.getMaximumValue(), STRICT);
    final VerticalCRS crs = ve.getVerticalCRS();
    verifyIdentifiers("test1", crs);
    assertEquals("scope", "World", crs.getScope().toString());
    final VerticalDatum datum = crs.getDatum();
    verifyIdentifiers("test2", datum);
    assertEquals("scope", "World", datum.getScope().toString());
    // Inferred from the name.
    assertEquals("vertDatumType", VerticalDatumType.DEPTH, datum.getVerticalDatumType());
    final VerticalCS cs = crs.getCoordinateSystem();
    verifyIdentifiers("test3", cs);
    final CoordinateSystemAxis axis = cs.getAxis(0);
    verifyIdentifiers("test4", axis);
    assertEquals("axisAbbrev", "d", axis.getAbbreviation());
    assertEquals("axisDirection", AxisDirection.DOWN, axis.getDirection());
    /*
         *     …
         *   </gmd:MD_DataIdentification>
         * </gmd:identificationInfo>
         *
         * Now marshal the object and compare with the original file.
         */
    assertMarshalEqualsFile(VERTICAL_CRS_XML, metadata, VERSION_2007, "xmlns:*", "xsi:schemaLocation");
}
Also used : DataIdentification(org.opengis.metadata.identification.DataIdentification) VerticalExtent(org.opengis.metadata.extent.VerticalExtent) Extent(org.opengis.metadata.extent.Extent) SpatialRepresentation(org.opengis.metadata.spatial.SpatialRepresentation) VectorSpatialRepresentation(org.opengis.metadata.spatial.VectorSpatialRepresentation) ReferenceSystemMetadata(org.apache.sis.internal.jaxb.metadata.replace.ReferenceSystemMetadata) VerticalExtent(org.opengis.metadata.extent.VerticalExtent) CoordinateSystemAxis(org.opengis.referencing.cs.CoordinateSystemAxis) DefaultCoordinateSystemAxis(org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis) VerticalDatum(org.opengis.referencing.datum.VerticalDatum) DefaultVerticalDatum(org.apache.sis.referencing.datum.DefaultVerticalDatum) GeographicBoundingBox(org.opengis.metadata.extent.GeographicBoundingBox) VerticalCS(org.opengis.referencing.cs.VerticalCS) DefaultVerticalCS(org.apache.sis.referencing.cs.DefaultVerticalCS) DefaultVerticalCRS(org.apache.sis.referencing.crs.DefaultVerticalCRS) VerticalCRS(org.opengis.referencing.crs.VerticalCRS) Test(org.junit.Test)

Example 2 with VerticalCS

use of org.opengis.referencing.cs.VerticalCS in project sis by apache.

the class VerticalInfo method complete.

/**
 * Completes the extent with a new CRS using the units specified at construction time.
 * The CRS created by this method is implementation-dependent. The only guarantees are:
 *
 * <ul>
 *   <li>datum type is {@link VerticalDatumType#GEOIDAL},</li>
 *   <li>increasing height values are up, and</li>
 *   <li>axis unit of measurement is the given linear unit.</li>
 * </ul>
 *
 * If this method can not propose a suitable CRS, then it returns {@code this}.
 */
final VerticalInfo complete(final CRSFactory crsFactory, final CSFactory csFactory) throws FactoryException {
    if (next != null) {
        next = next.complete(crsFactory, csFactory);
    }
    if (compatibleCRS == null) {
        return this;
    }
    final Object name;
    final String abbreviation;
    CoordinateSystemAxis axis = compatibleCRS.getCoordinateSystem().getAxis(0);
    final boolean isUP = AxisDirection.UP.equals(axis.getDirection());
    if (isUP) {
        name = axis.getName();
        abbreviation = axis.getAbbreviation();
    } else {
        name = AxisNames.GRAVITY_RELATED_HEIGHT;
        abbreviation = "H";
    }
    axis = csFactory.createCoordinateSystemAxis(properties(name), abbreviation, AxisDirection.UP, unit);
    /*
         * Naming policy (based on usage of names in the EPSG database):
         *
         *   - We can reuse the old axis name if (and only if) the direction is the same, because the axis
         *     names are constrained by the ISO 19111 specification in a way that do not include the units
         *     of measurement. Examples: "Gravity-related height", "Depth".
         *
         *   - We can not reuse the previous Coordinate System name, because it often contains the axis
         *     abbreviation and unit. Examples: "Vertical CS. Axis: height (H). Orientation: up. UoM: m.".
         *     Since we are lazy, we will reuse the axis name instead, which is more neutral.
         *
         *   - We generally can reuse the CRS name because those names tend to refer to the datum (which is
         *     unchanged) rather than the coordinate system. Examples: "Low Water depth", "NGF Lallemand height",
         *     "JGD2011 (vertical) height". However we make an exception if the direction is down, because in such
         *     cases the previous name may contain terms like "depth", which are not appropriate for our new CRS.
         */
    final VerticalCS cs = csFactory.createVerticalCS(properties(axis.getName()), axis);
    extent.setVerticalCRS(crsFactory.createVerticalCRS(properties((isUP ? compatibleCRS : axis).getName()), compatibleCRS.getDatum(), cs));
    return next;
}
Also used : VerticalCS(org.opengis.referencing.cs.VerticalCS) CoordinateSystemAxis(org.opengis.referencing.cs.CoordinateSystemAxis) IdentifiedObject(org.opengis.referencing.IdentifiedObject)

Example 3 with VerticalCS

use of org.opengis.referencing.cs.VerticalCS in project sis by apache.

the class CoordinateSystemsTest method testReplaceAxesWithTypeChange.

/**
 * Tests {@link CoordinateSystems#replaceAxes(CoordinateSystem, AxisFilter)}
 * with a change of coordinate system type.
 */
@Test
@DependsOnMethod("testReplaceAxes")
public void testReplaceAxesWithTypeChange() {
    final EllipsoidalCS sourceCS = HardCodedCS.GEODETIC_3D;
    // What we want to get.
    final VerticalCS targetCS = HardCodedCS.ELLIPSOIDAL_HEIGHT;
    final CoordinateSystem actualCS = CoordinateSystems.replaceAxes(sourceCS, new AxisFilter() {

        @Override
        public boolean accept(final CoordinateSystemAxis axis) {
            return Units.isLinear(axis.getUnit());
        }
    });
    assertEqualsIgnoreMetadata(targetCS, actualCS);
}
Also used : VerticalCS(org.opengis.referencing.cs.VerticalCS) CoordinateSystem(org.opengis.referencing.cs.CoordinateSystem) CoordinateSystemAxis(org.opengis.referencing.cs.CoordinateSystemAxis) EllipsoidalCS(org.opengis.referencing.cs.EllipsoidalCS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Aggregations

CoordinateSystemAxis (org.opengis.referencing.cs.CoordinateSystemAxis)3 VerticalCS (org.opengis.referencing.cs.VerticalCS)3 Test (org.junit.Test)2 ReferenceSystemMetadata (org.apache.sis.internal.jaxb.metadata.replace.ReferenceSystemMetadata)1 DefaultVerticalCRS (org.apache.sis.referencing.crs.DefaultVerticalCRS)1 DefaultCoordinateSystemAxis (org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis)1 DefaultVerticalCS (org.apache.sis.referencing.cs.DefaultVerticalCS)1 DefaultVerticalDatum (org.apache.sis.referencing.datum.DefaultVerticalDatum)1 DependsOnMethod (org.apache.sis.test.DependsOnMethod)1 Extent (org.opengis.metadata.extent.Extent)1 GeographicBoundingBox (org.opengis.metadata.extent.GeographicBoundingBox)1 VerticalExtent (org.opengis.metadata.extent.VerticalExtent)1 DataIdentification (org.opengis.metadata.identification.DataIdentification)1 SpatialRepresentation (org.opengis.metadata.spatial.SpatialRepresentation)1 VectorSpatialRepresentation (org.opengis.metadata.spatial.VectorSpatialRepresentation)1 IdentifiedObject (org.opengis.referencing.IdentifiedObject)1 VerticalCRS (org.opengis.referencing.crs.VerticalCRS)1 CoordinateSystem (org.opengis.referencing.cs.CoordinateSystem)1 EllipsoidalCS (org.opengis.referencing.cs.EllipsoidalCS)1 VerticalDatum (org.opengis.referencing.datum.VerticalDatum)1