Search in sources :

Example 1 with Extent

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();
}
Also used : DefaultGeographicBoundingBox(org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox) GeographicExtent(org.opengis.metadata.extent.GeographicExtent) Extent(org.opengis.metadata.extent.Extent) CheckedArrayList(org.apache.sis.internal.util.CheckedArrayList) ArrayList(java.util.ArrayList) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) Identification(org.opengis.metadata.identification.Identification) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) GeographicExtent(org.opengis.metadata.extent.GeographicExtent)

Example 2 with Extent

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;
}
Also used : Extent(org.opengis.metadata.extent.Extent) HashMap(java.util.HashMap) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem)

Example 3 with Extent

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"));
}
Also used : Locale(java.util.Locale) HashMap(java.util.HashMap) Extent(org.opengis.metadata.extent.Extent) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) Format(org.opengis.metadata.distribution.Format) Constraints(org.opengis.metadata.constraint.Constraints) MaintenanceInformation(org.opengis.metadata.maintenance.MaintenanceInformation) NameFactory(org.opengis.util.NameFactory) SpatialRepresentationType(org.opengis.metadata.spatial.SpatialRepresentationType) Test(org.junit.Test)

Example 4 with Extent

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));
}
Also used : VerticalExtent(org.opengis.metadata.extent.VerticalExtent) Extent(org.opengis.metadata.extent.Extent) Test(org.junit.Test)

Example 5 with Extent

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");
}
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)

Aggregations

Extent (org.opengis.metadata.extent.Extent)13 InternationalString (org.opengis.util.InternationalString)6 Test (org.junit.Test)4 GeographicBoundingBox (org.opengis.metadata.extent.GeographicBoundingBox)4 Locale (java.util.Locale)3 ResponsibleParty (org.opengis.metadata.citation.ResponsibleParty)3 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)3 FactoryException (org.opengis.util.FactoryException)3 IllegalArgumentException (com.sun.star.lang.IllegalArgumentException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 CheckedArrayList (org.apache.sis.internal.util.CheckedArrayList)2 DefaultExtent (org.apache.sis.metadata.iso.extent.DefaultExtent)2 DefaultGeographicBoundingBox (org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox)2 DefaultDataIdentification (org.apache.sis.metadata.iso.identification.DefaultDataIdentification)2 AbstractIdentifiedObject (org.apache.sis.referencing.AbstractIdentifiedObject)2 DataStoreException (org.apache.sis.storage.DataStoreException)2 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)2 VerticalExtent (org.opengis.metadata.extent.VerticalExtent)2 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)2