use of org.opengis.metadata.extent.GeographicBoundingBox in project sis by apache.
the class DefaultGeographicBoundingBoxTest method testToString.
/**
* Tests the {@code toString()} implementation of a custom geographic bounding box inside a {@link DefaultExtent}.
* In a previous Apache SIS version, those properties were not properly sorted.
*
* @since 0.8
*/
@Test
public void testToString() {
final GeographicBoundingBox bbox = new GeographicBoundingBox() {
@Override
public double getWestBoundLongitude() {
return -40;
}
@Override
public double getEastBoundLongitude() {
return 50;
}
@Override
public double getSouthBoundLatitude() {
return -20;
}
@Override
public double getNorthBoundLatitude() {
return 45;
}
@Override
public Boolean getInclusion() {
return Boolean.TRUE;
}
};
final DefaultExtent extent = new DefaultExtent(null, bbox, null, null);
assertSame(bbox, TestUtilities.getSingleton(extent.getGeographicElements()));
assertMultilinesEquals("Extent\n" + " └─Geographic element\n" + " ├─West bound longitude…… 40°W\n" + " ├─East bound longitude…… 50°E\n" + " ├─South bound latitude…… 20°S\n" + " ├─North bound latitude…… 45°N\n" + " └─Extent type code……………… true\n", extent.toString());
}
use of org.opengis.metadata.extent.GeographicBoundingBox in project sis by apache.
the class ExtentsTest method testGeographicIntersection.
/**
* Tests {@link Extents#intersection(GeographicBoundingBox, GeographicBoundingBox)}.
*/
@Test
public void testGeographicIntersection() {
final GeographicBoundingBox b1 = new DefaultGeographicBoundingBox(10, 20, 30, 40);
final GeographicBoundingBox b2 = new DefaultGeographicBoundingBox(15, 25, 26, 32);
assertEquals("intersect", new DefaultGeographicBoundingBox(15, 20, 30, 32), Extents.intersection(b1, b2));
assertSame(b1, Extents.intersection(b1, null));
assertSame(b2, Extents.intersection(null, b2));
assertNull(Extents.intersection((GeographicBoundingBox) null, (GeographicBoundingBox) null));
}
use of org.opengis.metadata.extent.GeographicBoundingBox in project sis by apache.
the class EPSGFactoryTest method testCompound.
/**
* Tests the "NTF (Paris) + NGF IGN69 height" compound CRS (EPSG:7400).
* This method tests also the domain of validity.
*
* @throws FactoryException if an error occurred while querying the factory.
*/
@Test
@DependsOnMethod({ "testGeographic2D", "testVertical" })
public void testCompound() throws FactoryException {
final EPSGFactory factory = TestFactorySource.factory;
assumeNotNull(factory);
final CompoundCRS crs = factory.createCompoundCRS("EPSG:7400");
assertEpsgNameAndIdentifierEqual("NTF (Paris) + NGF IGN69 height", 7400, crs);
final List<CoordinateReferenceSystem> components = crs.getComponents();
assertEquals("components.size()", 2, components.size());
assertEpsgNameAndIdentifierEqual("NTF (Paris)", 4807, components.get(0));
assertEpsgNameAndIdentifierEqual("NGF-IGN69 height", 5720, components.get(1));
assertAxisDirectionsEqual("(no EPSG code)", crs.getCoordinateSystem(), AxisDirection.NORTH, AxisDirection.EAST, AxisDirection.UP);
final GeographicBoundingBox bbox = CRS.getGeographicBoundingBox(crs);
assertNotNull("No bounding box. Maybe an older EPSG database is used?", bbox);
assertEquals("southBoundLatitude", 42.33, bbox.getSouthBoundLatitude(), STRICT);
assertEquals("northBoundLatitude", 51.14, bbox.getNorthBoundLatitude(), STRICT);
assertEquals("westBoundLongitude", -4.87, bbox.getWestBoundLongitude(), STRICT);
assertEquals("eastBoundLongitude", 8.23, bbox.getEastBoundLongitude(), STRICT);
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("7400"));
}
use of org.opengis.metadata.extent.GeographicBoundingBox in project sis by apache.
the class CoordinateOperationMethods method computeUnionOfAllDomainOfValidity.
/**
* For each {@link OperationMethod} (identified by their name), computes the union of the domain of validity
* of all CRS using that operation method. The result is a map where keys are {@link OperationMethod} names,
* and values are the union of the domain of validity of all CRS using that {@code OperationMethod}.
*
* <p>This is a costly operation.</p>
*
* @todo This method is not yet used. This is pending the implementation of {@code CRSAuthorityFactory} is SIS.
*
* @param factory the factory to use for getting CRS.
* @return the union of domain of validity of all map projections using a method of the given name.
* @throws FactoryException if an error occurred while fetching the list of CRS.
*/
public static Map<String, DefaultGeographicBoundingBox> computeUnionOfAllDomainOfValidity(final CRSAuthorityFactory factory) throws FactoryException {
final Map<String, DefaultGeographicBoundingBox> domainOfValidity = new HashMap<>();
for (final String code : factory.getAuthorityCodes(GeneralDerivedCRS.class)) {
final CoordinateReferenceSystem crs;
try {
crs = factory.createCoordinateReferenceSystem(code);
} catch (FactoryException e) {
// Ignore and inspect the next element.
continue;
}
if (crs instanceof GeneralDerivedCRS) {
final GeographicBoundingBox candidate = CRS.getGeographicBoundingBox(crs);
if (candidate != null) {
final String name = ((GeneralDerivedCRS) crs).getConversionFromBase().getMethod().getName().getCode();
DefaultGeographicBoundingBox validity = domainOfValidity.get(name);
if (validity == null) {
validity = new DefaultGeographicBoundingBox(candidate);
domainOfValidity.put(name, validity);
} else {
validity.add(candidate);
}
}
}
}
return domainOfValidity;
}
use of org.opengis.metadata.extent.GeographicBoundingBox 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");
}
Aggregations