Search in sources :

Example 1 with DefaultGeographicBoundingBox

use of org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox 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 DefaultGeographicBoundingBox

use of org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox in project sis by apache.

the class DefaultGeodeticDatumTest method testGetPositionVectorTransformation.

/**
 * Tests {@link DefaultGeodeticDatum#getPositionVectorTransformation(GeodeticDatum, Extent)}.
 */
@Test
@DependsOnMethod("testCreateAndSerialize")
public void testGetPositionVectorTransformation() {
    final Map<String, Object> properties = new HashMap<>();
    assertNull(properties.put(DefaultGeodeticDatum.NAME_KEY, "Invalid dummy datum"));
    /*
         * Associate two BursaWolfParameters, one valid only in a local area and the other one
         * valid globaly.  Note that we are building an invalid set of parameters, because the
         * source datum are not the same in both case. But for this test we are not interrested
         * in datum consistency - we only want any Bursa-Wolf parameters having different area
         * of validity.
         */
    // Local area (North Sea)
    final BursaWolfParameters local = BursaWolfParametersTest.createED87_to_WGS84();
    // Global area (World)
    final BursaWolfParameters global = BursaWolfParametersTest.createWGS72_to_WGS84();
    assertNull(properties.put(DefaultGeodeticDatum.BURSA_WOLF_KEY, new BursaWolfParameters[] { local, global }));
    /*
         * Build the datum using WGS 72 ellipsoid (so at least one of the BursaWolfParameters is real).
         */
    final DefaultGeodeticDatum datum = new DefaultGeodeticDatum(properties, GeodeticDatumMock.WGS72.getEllipsoid(), GeodeticDatumMock.WGS72.getPrimeMeridian());
    /*
         * Search for BursaWolfParameters around the North Sea area.
         */
    final DefaultGeographicBoundingBox areaOfInterest = new DefaultGeographicBoundingBox(-2, 8, 55, 60);
    final DefaultExtent extent = new DefaultExtent("Around the North Sea", areaOfInterest, null, null);
    Matrix matrix = datum.getPositionVectorTransformation(GeodeticDatumMock.NAD83, extent);
    assertNull("No BursaWolfParameters for NAD83", matrix);
    matrix = datum.getPositionVectorTransformation(GeodeticDatumMock.WGS84, extent);
    assertNotNull("BursaWolfParameters for WGS84", matrix);
    checkTransformationSignature(local, matrix, 0);
    /*
         * Expand the area of interest to something greater than North Sea, and test again.
         */
    areaOfInterest.setWestBoundLongitude(-8);
    matrix = datum.getPositionVectorTransformation(GeodeticDatumMock.WGS84, extent);
    assertNotNull("BursaWolfParameters for WGS84", matrix);
    checkTransformationSignature(global, matrix, 0);
    /*
         * Search in the reverse direction.
         */
    final DefaultGeodeticDatum targetDatum = new DefaultGeodeticDatum(GeodeticDatumMock.WGS84);
    matrix = targetDatum.getPositionVectorTransformation(datum, extent);
    // Expected result is the inverse.
    global.invert();
    checkTransformationSignature(global, matrix, 1E-6);
}
Also used : DefaultGeographicBoundingBox(org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox) Matrix(org.opengis.referencing.operation.Matrix) DefaultExtent(org.apache.sis.metadata.iso.extent.DefaultExtent) HashMap(java.util.HashMap) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 3 with DefaultGeographicBoundingBox

use of org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox 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;
}
Also used : DefaultGeographicBoundingBox(org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FactoryException(org.opengis.util.FactoryException) GeneralDerivedCRS(org.opengis.referencing.crs.GeneralDerivedCRS) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) GeographicBoundingBox(org.opengis.metadata.extent.GeographicBoundingBox) DefaultGeographicBoundingBox(org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox)

Example 4 with DefaultGeographicBoundingBox

use of org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox in project sis by apache.

the class CoordinateOperationMethods method writeIdentification.

/**
 * Writes identification info about the given method.
 * This method writes the following information:
 *
 * <ul>
 *   <li>EPSG codes</li>
 *   <li>Aliases</li>
 *   <li>Domain of validity</li>
 * </ul>
 */
private void writeIdentification(final OperationMethod method) throws IOException {
    final int table = openTag("table class=\"info\"");
    /*
         * ────────────────    EPSG IDENTIFIERS    ────────────────────────────────────
         */
    final StringBuilder buffer = new StringBuilder();
    for (final ReferenceIdentifier id : method.getIdentifiers()) {
        if (Constants.EPSG.equalsIgnoreCase(id.getCodeSpace())) {
            if (buffer.length() != 0) {
                buffer.append(", ");
            }
            final boolean isDeprecated = isDeprecated(id);
            if (isDeprecated) {
                buffer.append("<del>");
            }
            buffer.append(id.getCode());
            if (isDeprecated) {
                buffer.append("</del>");
            }
        }
    }
    if (buffer.length() != 0) {
        final int tr = openTag("tr");
        println("th", "EPSG code:");
        println("td", buffer);
        closeTags(tr);
    }
    /*
         * ────────────────    ALIASES    ─────────────────────────────────────────────
         */
    buffer.setLength(0);
    for (final GenericName alias : method.getAlias()) {
        if (buffer.length() != 0) {
            buffer.append(", ");
        }
        final GenericName head = alias.head();
        if (head == alias || Constants.EPSG.equalsIgnoreCase(head.toString())) {
            buffer.append(alias.tip());
        } else {
            buffer.append("<span class=\"non-epsg\">").append(head).append(":</span>").append("<code>").append(alias.tip()).append("</code>");
        }
    }
    if (buffer.length() != 0) {
        final int tr = openTag("tr");
        println("th", "Aliases:");
        println("td", buffer);
        closeTags(tr);
    }
    /*
         * ────────────────    DOMAIN OF VALIDITY    ──────────────────────────────────
         */
    buffer.setLength(0);
    final DefaultGeographicBoundingBox domain = getDomainOfValidity(method);
    if (domain != null) {
        openTag("tr");
        println("th", "Domain of validity:");
        println("td", buffer.append(new Latitude(domain.getSouthBoundLatitude())).append(" to ").append(new Latitude(domain.getNorthBoundLatitude())).append(" and ").append(new Longitude(domain.getWestBoundLongitude())).append(" to ").append(new Longitude(domain.getEastBoundLongitude())));
    }
    closeTags(table);
}
Also used : GenericName(org.opengis.util.GenericName) ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) DefaultGeographicBoundingBox(org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox) Latitude(org.apache.sis.measure.Latitude) Longitude(org.apache.sis.measure.Longitude)

Example 5 with DefaultGeographicBoundingBox

use of org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox 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);
    }
}
Also used : SingleCRS(org.opengis.referencing.crs.SingleCRS) DefaultTemporalCRS(org.apache.sis.referencing.crs.DefaultTemporalCRS) TemporalCRS(org.opengis.referencing.crs.TemporalCRS) DefaultGeographicBoundingBox(org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox) DefaultVerticalExtent(org.apache.sis.metadata.iso.extent.DefaultVerticalExtent) DefaultTemporalExtent(org.apache.sis.metadata.iso.extent.DefaultTemporalExtent) VerticalCRS(org.opengis.referencing.crs.VerticalCRS) TransformException(org.opengis.referencing.operation.TransformException) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem)

Aggregations

DefaultGeographicBoundingBox (org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox)16 DefaultExtent (org.apache.sis.metadata.iso.extent.DefaultExtent)6 Test (org.junit.Test)6 HashMap (java.util.HashMap)4 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)4 DefaultTemporalExtent (org.apache.sis.metadata.iso.extent.DefaultTemporalExtent)3 DefaultVerticalExtent (org.apache.sis.metadata.iso.extent.DefaultVerticalExtent)3 GeographicBoundingBox (org.opengis.metadata.extent.GeographicBoundingBox)3 ImmutableIdentifier (org.apache.sis.metadata.iso.ImmutableIdentifier)2 DefaultTemporalCRS (org.apache.sis.referencing.crs.DefaultTemporalCRS)2 DependsOnMethod (org.apache.sis.test.DependsOnMethod)2 Extent (org.opengis.metadata.extent.Extent)2 GeographicExtent (org.opengis.metadata.extent.GeographicExtent)2 ReferenceIdentifier (org.opengis.referencing.ReferenceIdentifier)2 GeneralDerivedCRS (org.opengis.referencing.crs.GeneralDerivedCRS)2 SingleCRS (org.opengis.referencing.crs.SingleCRS)2 TemporalCRS (org.opengis.referencing.crs.TemporalCRS)2 VerticalCRS (org.opengis.referencing.crs.VerticalCRS)2 TransformException (org.opengis.referencing.operation.TransformException)2 GenericName (org.opengis.util.GenericName)2