use of org.opengis.metadata.identification.DataIdentification 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");
}
use of org.opengis.metadata.identification.DataIdentification in project sis by apache.
the class CharSequenceSubstitutionTest method testCodeList.
/**
* Tests substitution by a code list.
*
* @throws JAXBException if the (un)marshalling failed.
*
* @since 0.7
*/
@Test
public void testCodeList() throws JAXBException {
final String expected = "<mri:MD_DataIdentification xmlns:mri=\"" + Namespaces.MRI + "\">\n" + " <mri:purpose>\n" + " <mri:DS_InitiativeTypeCode\n" + " codeList=\"http://standards.iso.org/iso/19115/resources/Codelist/cat/codelists.xml#DS_InitiativeTypeCode\"\n" + " codeListValue=\"investigation\">Investigation</mri:DS_InitiativeTypeCode>\n" + " </mri:purpose>\n" + "</mri:MD_DataIdentification>";
final DataIdentification id = unmarshal(DataIdentification.class, expected);
assertEquals("purpose", "Investigation", String.valueOf(id.getPurpose()));
assertSame("purpose", InitiativeType.INVESTIGATION, Types.forCodeTitle(id.getPurpose()));
final String actual = marshal(id);
assertXmlEquals(expected, actual, "xmlns:*");
}
Aggregations