use of org.apache.sis.metadata.iso.extent.DefaultVerticalExtent in project sis by apache.
the class AbstractReferenceSystemTest method testWKT.
/**
* Tests WKT formatting with a name that contains the quote character and optional information.
* We test that the closing quote character is doubled and the optional information properly formatted.
*/
@Test
@DependsOnMethod("testCreateFromMap")
public void testWKT() {
final Map<String, Object> properties = new HashMap<>(8);
assertNull(properties.put(NAME_KEY, "My “object”."));
assertNull(properties.put(SCOPE_KEY, "Large scale topographic mapping and cadastre."));
assertNull(properties.put(REMARKS_KEY, "注です。"));
assertNull(properties.put(IDENTIFIERS_KEY, new ImmutableIdentifier(Citations.EPSG, "EPSG", "4326", "8.2", null)));
assertNull(properties.put(DOMAIN_OF_VALIDITY_KEY, new DefaultExtent("Netherlands offshore.", new DefaultGeographicBoundingBox(2.54, 6.40, 51.43, 55.77), new DefaultVerticalExtent(10, 1000, VerticalCRSMock.DEPTH), // TODO: needs sis-temporal module for testing that one.
new DefaultTemporalExtent())));
final AbstractReferenceSystem object = new AbstractReferenceSystem(properties);
assertTrue(object.toString(Convention.WKT1).startsWith("ReferenceSystem[\"My “object”.\", AUTHORITY[\"EPSG\", \"4326\"]]"));
assertWktEquals(Convention.WKT1, "ReferenceSystem[“My \"object\".”, AUTHORITY[“EPSG”, “4326”]]", object);
assertWktEquals(Convention.WKT2, // Quotes replaced
"ReferenceSystem[“My \"object\".”,\n" + " SCOPE[“Large scale topographic mapping and cadastre.”],\n" + " AREA[“Netherlands offshore.”],\n" + " BBOX[51.43, 2.54, 55.77, 6.40],\n" + " VERTICALEXTENT[-1000, -10, LENGTHUNIT[“metre”, 1]],\n" + " ID[“EPSG”, 4326, “8.2”, URI[“urn:ogc:def:referenceSystem:EPSG:8.2:4326”]],\n" + " REMARK[“注です。”]]", object);
assertWktEquals(Convention.WKT2_SIMPLIFIED, "ReferenceSystem[“My \"object\".”,\n" + " Scope[“Large scale topographic mapping and cadastre.”],\n" + " Area[“Netherlands offshore.”],\n" + " BBox[51.43, 2.54, 55.77, 6.40],\n" + " VerticalExtent[-1000, -10],\n" + " Id[“EPSG”, 4326, “8.2”, URI[“urn:ogc:def:referenceSystem:EPSG:8.2:4326”]],\n" + " Remark[“注です。”]]", object);
assertWktEquals(Convention.INTERNAL, // Quote doubled
"ReferenceSystem[“My “object””.”,\n" + " Scope[“Large scale topographic mapping and cadastre.”],\n" + " Area[“Netherlands offshore.”],\n" + " BBox[51.43, 2.54, 55.77, 6.40],\n" + " VerticalExtent[-1000, -10],\n" + " Id[“EPSG”, 4326, “8.2”],\n" + " Remark[“注です。”]]", object);
}
use of org.apache.sis.metadata.iso.extent.DefaultVerticalExtent in project sis by apache.
the class ServicesForMetadataTest method testSetVerticalBoundsFromEllipsoid.
/**
* Tests (indirectly) {@link ServicesForMetadata#setBounds(Envelope, DefaultVerticalExtent)}
* from an ellipsoidal height
*
* @throws TransformException should never happen.
*/
@Test
public void testSetVerticalBoundsFromEllipsoid() throws TransformException {
final DefaultVerticalExtent extent = new DefaultVerticalExtent();
extent.setBounds(createEnvelope(HardCodedCRS.WGS84_3D));
verifyVerticalExtent(CommonCRS.Vertical.ELLIPSOIDAL, extent);
}
use of org.apache.sis.metadata.iso.extent.DefaultVerticalExtent in project sis by apache.
the class FormatterTest method testAppendVerticalExtent.
/**
* Tests (indirectly) formatting of a vertical extent.
*/
@Test
public void testAppendVerticalExtent() {
final DefaultVerticalExtent extent = new DefaultVerticalExtent(102, 108, VerticalCRSMock.HEIGHT_ft);
assertWktEquals(Convention.WKT2_SIMPLIFIED, "VerticalExtent[102, 108, Unit[“foot”, 0.3048]]", extent);
assertWktEquals(Convention.WKT2, "VERTICALEXTENT[102, 108, LENGTHUNIT[“foot”, 0.3048]]", extent);
extent.setMinimumValue(100.2);
extent.setMaximumValue(100.8);
assertWktEquals(Convention.WKT2, "VERTICALEXTENT[100.2, 100.8, LENGTHUNIT[“foot”, 0.3048]]", extent);
}
use of org.apache.sis.metadata.iso.extent.DefaultVerticalExtent in project sis by apache.
the class ServicesForMetadata method addElements.
/**
* Initializes a horizontal, vertical and temporal extent with the values inferred from the given envelope.
*
* @param envelope the source envelope.
* @param target the target extent where to store envelope information.
* @throws TransformException if a coordinate transformation was required and failed.
*/
@Override
public void addElements(final Envelope envelope, final DefaultExtent target) throws TransformException {
final CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem();
final SingleCRS horizontalCRS = CRS.getHorizontalComponent(crs);
final VerticalCRS verticalCRS = CRS.getVerticalComponent(crs, true);
final TemporalCRS temporalCRS = CRS.getTemporalComponent(crs);
if (horizontalCRS == null && verticalCRS == null && temporalCRS == null) {
throw new TransformException(dimensionNotFound(Resources.Keys.MissingSpatioTemporalDimension_1, crs));
}
if (horizontalCRS != null) {
final DefaultGeographicBoundingBox extent = new DefaultGeographicBoundingBox();
extent.setInclusion(Boolean.TRUE);
setBounds(envelope, extent);
target.getGeographicElements().add(extent);
}
if (verticalCRS != null) {
final DefaultVerticalExtent extent = new DefaultVerticalExtent();
setVerticalExtent(envelope, extent, crs, verticalCRS);
target.getVerticalElements().add(extent);
}
if (temporalCRS != null) {
final DefaultTemporalExtent extent = new DefaultTemporalExtent();
setTemporalExtent(envelope, extent, crs, temporalCRS);
target.getTemporalElements().add(extent);
}
}
use of org.apache.sis.metadata.iso.extent.DefaultVerticalExtent in project sis by apache.
the class ServicesForMetadata method setBounds.
/**
* Sets the geographic, vertical and temporal extents with the values inferred from the given envelope.
* If the given {@code target} has more geographic or vertical extents than needed (0 or 1), then the
* extraneous extents are removed.
*
* @param envelope the source envelope.
* @param target the target spatiotemporal extent where to store envelope information.
* @throws TransformException if no temporal component can be extracted from the given envelope.
*/
@Override
public void setBounds(final Envelope envelope, final DefaultSpatialTemporalExtent target) throws TransformException {
final CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem();
final SingleCRS horizontalCRS = CRS.getHorizontalComponent(crs);
final VerticalCRS verticalCRS = CRS.getVerticalComponent(crs, true);
final TemporalCRS temporalCRS = CRS.getTemporalComponent(crs);
if (horizontalCRS == null && verticalCRS == null && temporalCRS == null) {
throw new TransformException(dimensionNotFound(Resources.Keys.MissingSpatioTemporalDimension_1, crs));
}
/*
* Try to set the geographic bounding box first, because this operation may fail with a
* TransformException while the other operations (vertical and temporal) should not fail.
* So doing the geographic part first help us to get a "all or nothing" behavior.
*/
DefaultGeographicBoundingBox box = null;
boolean useExistingBox = (horizontalCRS != null);
final Collection<GeographicExtent> spatialExtents = target.getSpatialExtent();
final Iterator<GeographicExtent> it = spatialExtents.iterator();
while (it.hasNext()) {
final GeographicExtent extent = it.next();
if (extent instanceof GeographicBoundingBox) {
if (useExistingBox && (extent instanceof DefaultGeographicBoundingBox)) {
box = (DefaultGeographicBoundingBox) extent;
useExistingBox = false;
} else {
it.remove();
}
}
}
if (horizontalCRS != null) {
if (box == null) {
box = new DefaultGeographicBoundingBox();
spatialExtents.add(box);
}
GeographicCRS normalizedCRS = ReferencingUtilities.toNormalizedGeographicCRS(crs);
if (normalizedCRS == null) {
normalizedCRS = CommonCRS.defaultGeographic();
}
setGeographicExtent(envelope, box, crs, normalizedCRS);
}
/*
* Other dimensions (vertical and temporal).
*/
if (verticalCRS != null) {
VerticalExtent e = target.getVerticalExtent();
if (!(e instanceof DefaultVerticalExtent)) {
e = new DefaultVerticalExtent();
target.setVerticalExtent(e);
}
setVerticalExtent(envelope, (DefaultVerticalExtent) e, crs, verticalCRS);
} else {
target.setVerticalExtent(null);
}
if (temporalCRS != null) {
setTemporalExtent(envelope, target, crs, temporalCRS);
} else {
target.setExtent(null);
}
}
Aggregations