use of org.opengis.metadata.extent.Extent in project tika by apache.
the class GeographicInformationParser method extractContent.
private void extractContent(XHTMLContentHandler xhtmlContentHandler, DefaultMetadata defaultMetadata) throws SAXException {
xhtmlContentHandler.startDocument();
xhtmlContentHandler.newline();
xhtmlContentHandler.newline();
ArrayList<Identification> identifications = (ArrayList<Identification>) defaultMetadata.getIdentificationInfo();
for (Identification i : identifications) {
xhtmlContentHandler.startElement("h1");
xhtmlContentHandler.characters(i.getCitation().getTitle().toString());
xhtmlContentHandler.endElement("h1");
xhtmlContentHandler.newline();
ArrayList<ResponsibleParty> responsiblePartyArrayList = (ArrayList<ResponsibleParty>) i.getCitation().getCitedResponsibleParties();
for (ResponsibleParty r : responsiblePartyArrayList) {
xhtmlContentHandler.startElement("h3");
xhtmlContentHandler.newline();
xhtmlContentHandler.characters("CitedResponsiblePartyRole " + r.getRole().toString());
xhtmlContentHandler.characters("CitedResponsiblePartyName " + r.getIndividualName().toString());
xhtmlContentHandler.endElement("h3");
xhtmlContentHandler.newline();
}
xhtmlContentHandler.startElement("p");
xhtmlContentHandler.newline();
xhtmlContentHandler.characters("IdentificationInfoAbstract " + i.getAbstract().toString());
xhtmlContentHandler.endElement("p");
xhtmlContentHandler.newline();
Collection<Extent> extentList = ((DefaultDataIdentification) i).getExtents();
for (Extent e : extentList) {
ArrayList<GeographicExtent> geoElements = (ArrayList<GeographicExtent>) e.getGeographicElements();
for (GeographicExtent g : geoElements) {
if (g instanceof DefaultGeographicBoundingBox) {
xhtmlContentHandler.startElement("tr");
xhtmlContentHandler.startElement("td");
xhtmlContentHandler.characters("GeographicElementWestBoundLatitude");
xhtmlContentHandler.endElement("td");
xhtmlContentHandler.startElement("td");
xhtmlContentHandler.characters(String.valueOf(((DefaultGeographicBoundingBox) g).getWestBoundLongitude()));
xhtmlContentHandler.endElement("td");
xhtmlContentHandler.endElement("tr");
xhtmlContentHandler.startElement("tr");
xhtmlContentHandler.startElement("td");
xhtmlContentHandler.characters("GeographicElementEastBoundLatitude");
xhtmlContentHandler.endElement("td");
xhtmlContentHandler.startElement("td");
xhtmlContentHandler.characters(String.valueOf(((DefaultGeographicBoundingBox) g).getEastBoundLongitude()));
xhtmlContentHandler.endElement("td");
xhtmlContentHandler.endElement("tr");
xhtmlContentHandler.startElement("tr");
xhtmlContentHandler.startElement("td");
xhtmlContentHandler.characters("GeographicElementNorthBoundLatitude");
xhtmlContentHandler.endElement("td");
xhtmlContentHandler.startElement("td");
xhtmlContentHandler.characters(String.valueOf(((DefaultGeographicBoundingBox) g).getNorthBoundLatitude()));
xhtmlContentHandler.endElement("td");
xhtmlContentHandler.endElement("tr");
xhtmlContentHandler.startElement("tr");
xhtmlContentHandler.startElement("td");
xhtmlContentHandler.characters("GeographicElementSouthBoundLatitude");
xhtmlContentHandler.endElement("td");
xhtmlContentHandler.startElement("td");
xhtmlContentHandler.characters(String.valueOf(((DefaultGeographicBoundingBox) g).getSouthBoundLatitude()));
xhtmlContentHandler.endElement("td");
xhtmlContentHandler.endElement("tr");
}
}
}
}
xhtmlContentHandler.newline();
xhtmlContentHandler.endDocument();
}
use of org.opengis.metadata.extent.Extent in project sis by apache.
the class EllipsoidalHeightCombiner method properties.
/**
* Suggests properties for a compound CRS made of the given elements.
* This method builds a default CRS name and domain of validity.
*
* @param components the components for which to get a default set of properties.
* @return suggested properties in a modifiable map. Callers can modify the returned map.
*/
public static Map<String, Object> properties(final CoordinateReferenceSystem... components) {
final StringBuilder name = new StringBuilder(40);
Extent domain = null;
for (int i = 0; i < components.length; i++) {
final CoordinateReferenceSystem crs = components[i];
ArgumentChecks.ensureNonNullElement("components", i, crs);
if (i != 0)
name.append(" + ");
name.append(crs.getName().getCode());
domain = Extents.intersection(domain, crs.getDomainOfValidity());
}
final Map<String, Object> properties = new HashMap<>(2);
properties.put(CoordinateReferenceSystem.NAME_KEY, name.toString());
properties.put(CoordinateReferenceSystem.DOMAIN_OF_VALIDITY_KEY, domain);
return properties;
}
use of org.opengis.metadata.extent.Extent in project sis by apache.
the class CustomMetadataTest method testSubtypeAttributes.
/**
* Tests that the attributes defined in subtypes are also marshalled.
*
* @throws JAXBException if an error occurred during (un)marshalling.
*
* @see <a href="http://jira.geotoolkit.org/browse/GEOTK-108">GEOTK-108</a>
*/
@Test
public void testSubtypeAttributes() throws JAXBException {
final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
final DataIdentification identification = new DataIdentification() {
@Override
public InternationalString getAbstract() {
Map<Locale, String> names = new HashMap<>();
names.put(Locale.ENGLISH, "Description");
return factory.createInternationalString(names);
}
@Override
public InternationalString getEnvironmentDescription() {
Map<Locale, String> names = new HashMap<>();
names.put(Locale.ENGLISH, "Environment");
return factory.createInternationalString(names);
}
@Override
public InternationalString getSupplementalInformation() {
return null;
}
@Override
public Citation getCitation() {
return null;
}
@Override
public InternationalString getPurpose() {
return null;
}
@Override
public Collection<SpatialRepresentationType> getSpatialRepresentationTypes() {
return null;
}
@Override
public Collection<Resolution> getSpatialResolutions() {
return null;
}
@Override
public Collection<Locale> getLanguages() {
return null;
}
@Override
public Collection<CharacterSet> getCharacterSets() {
return null;
}
@Override
public Collection<TopicCategory> getTopicCategories() {
return null;
}
@Override
public Collection<Extent> getExtents() {
return null;
}
@Override
public Collection<String> getCredits() {
return null;
}
@Override
public Collection<Progress> getStatus() {
return null;
}
@Override
public Collection<ResponsibleParty> getPointOfContacts() {
return null;
}
@Override
public Collection<MaintenanceInformation> getResourceMaintenances() {
return null;
}
@Override
public Collection<BrowseGraphic> getGraphicOverviews() {
return null;
}
@Override
public Collection<Format> getResourceFormats() {
return null;
}
@Override
public Collection<Keywords> getDescriptiveKeywords() {
return null;
}
@Override
public Collection<Usage> getResourceSpecificUsages() {
return null;
}
@Override
public Collection<Constraints> getResourceConstraints() {
return null;
}
@Deprecated
@Override
public Collection<AggregateInformation> getAggregationInfo() {
return null;
}
};
final DefaultMetadata data = new DefaultMetadata();
data.setIdentificationInfo(singleton(identification));
final String xml = XML.marshal(data);
/*
* A few simple checks.
*/
assertTrue("Missing Identification attribute.", xml.contains("Description"));
assertTrue("Missing DataIdentification attribute.", xml.contains("Environment"));
}
use of org.opengis.metadata.extent.Extent in project sis by apache.
the class ExtentsTest method testExtentIntersection.
/**
* Tests {@link Extents#intersection(Extent, Extent)}.
* This test is subject to the same limitation than {@link #testVerticalIntersection()}.
*/
@Test
public void testExtentIntersection() {
final Extent e1 = new DefaultExtent(null, new DefaultGeographicBoundingBox(10, 20, 30, 40), new DefaultVerticalExtent(10, 20, null), null);
final Extent e2 = new DefaultExtent(null, new DefaultGeographicBoundingBox(15, 25, 26, 32), new DefaultVerticalExtent(15, 25, null), null);
assertEquals(new DefaultExtent(null, new DefaultGeographicBoundingBox(15, 20, 30, 32), new DefaultVerticalExtent(15, 20, null), null), Extents.intersection(e1, e2));
assertSame(e1, Extents.intersection(e1, null));
assertSame(e2, Extents.intersection(null, e2));
assertNull(Extents.intersection((Extent) null, (Extent) null));
}
use of org.opengis.metadata.extent.Extent 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