Package org.opengis.metadata.extent

Examples of org.opengis.metadata.extent.GeographicBoundingBox


                            ymin = env.getMinimum(1);
                        if (env.getMaximum(1) > ymax)
                            ymax = env.getMaximum(1);
                    }
                } else if (ext instanceof GeographicBoundingBox) {
                    GeographicBoundingBox gbb = (GeographicBoundingBox) ext;
                    ReferencedEnvelope env = new ReferencedEnvelope(DefaultGeographicCRS.WGS84);
                    env.expandToInclude(gbb.getWestBoundLongitude(), gbb.getNorthBoundLatitude());
                    env.expandToInclude(gbb.getEastBoundLongitude(), gbb.getSouthBoundLatitude());
                    env = env.transform(crs, true);
                    if (env.getMinX() < xmin)
                        xmin = env.getMinX();
                    if (env.getMaxX() > xmax)
                        xmax = env.getMaxX();
View Full Code Here


              return null; // give up!
          }
      }
            if (extent == null || extent.isEmpty() || extent.isNull()) {
        // fall back to WGS84 bounds and transform to world CRS
                GeographicBoundingBox worldBounds = CRS.getGeographicBoundingBox(worldCRS);
                if( worldBounds != null ){
                    ReferencedEnvelope testGeo = new ReferencedEnvelope(worldBounds.getWestBoundLongitude(), worldBounds.getEastBoundLongitude(), worldBounds.getNorthBoundLatitude(), worldBounds.getSouthBoundLatitude(), DefaultGeographicCRS.WGS84);
                    try {
                        extent = testGeo.transform(worldCRS,  true );
                    } catch (TransformException e) {
                        extent = null; // off the map!
                    } catch (FactoryException e) {
View Full Code Here

            return null;
        Collection<? extends GeographicExtent> elems = extent.getGeographicElements();
        for (GeographicExtent extent2 : elems) {
            ReferencedEnvelope env = null;
            if (extent2 instanceof GeographicBoundingBox) {
                GeographicBoundingBox box = (GeographicBoundingBox) extent2;
                env = new ReferencedEnvelope(box.getWestBoundLongitude(),
                        box.getEastBoundLongitude(), box.getSouthBoundLatitude(),
                        box.getNorthBoundLatitude(), DefaultGeographicCRS.WGS84);
            } else if (extent2 instanceof BoundingPolygon) {
                BoundingPolygon boundingpoly = (BoundingPolygon) extent2;
                Collection<? extends Geometry> polygons = boundingpoly.getPolygons();
                for (Geometry geometry : polygons) {
                    Polygon poly = (Polygon) geometry;
View Full Code Here

                // GeographicBoundingBox box = CRS.getGeographicBoundingBox(crs);
                // jsBbox = "[" + box.getWestBoundLongitude() + "," + box.getSouthBoundLatitude()
                // + "," + box.getEastBoundLongitude() + "," + box.getNorthBoundLatitude()
                // + "]";

                GeographicBoundingBox box = CRS.getGeographicBoundingBox(crs);

                double westBoundLongitude = box.getWestBoundLongitude();
                double eastBoundLongitude = box.getEastBoundLongitude();
                double southBoundLatitude = box.getSouthBoundLatitude();
                double northBoundLatitude = box.getNorthBoundLatitude();

                double[] dst1;
                double[] dst2;
                try {
                    MathTransform tr = CRS.findMathTransform(CRS.decode("EPSG:4326"), crs, true);
View Full Code Here

                                        }
                                        catch( Exception ex ) {
                                            throw new WFSException( ex );
                                        }
                                       
                                        GeographicBoundingBox valid =
                                            (GeographicBoundingBox) crs.getDomainOfValidity()
                                            .getGeographicElements().iterator().next();
                                       
                                        if ( e.getMinimum(0) < valid.getWestBoundLongitude() ||
                                            e.getMinimum(0) > valid.getEastBoundLongitude() ||
                                            e.getMaximum(0) < valid.getWestBoundLongitude() ||
                                            e.getMaximum(0) > valid.getEastBoundLongitude() ||
                                            e.getMinimum(1) < valid.getSouthBoundLatitude() ||
                                            e.getMinimum(1) > valid.getNorthBoundLatitude() ||
                                            e.getMaximum(1) < valid.getSouthBoundLatitude() ||
                                            e.getMaximum(1) > valid.getNorthBoundLatitude() ) {
                                               
                                            throw new WFSException( "bounding box out of valid range of crs", "InvalidParameterValue");
                                        }
                                    }
                                   
View Full Code Here

        DataStore ds = DataStoreFinder.getDataStore(params);
        return ds.getFeatureSource(ds.getTypeNames()[0]);
    }

    private Geometry getGeographicBoundingBox(CoordinateReferenceSystem crs) {
        GeographicBoundingBox envelope = CRS.getGeographicBoundingBox(crs);
        if (envelope == null) {
            return null;
        }

        final double westBoundLongitude = envelope.getWestBoundLongitude();
        final double eastBoundLongitude = envelope.getEastBoundLongitude();
        final double southBoundLatitude = envelope.getSouthBoundLatitude();
        final double northBoundLatitude = envelope.getNorthBoundLatitude();

        final int numSteps = 80;
        Geometry geogBoundingGeom;

        if (westBoundLongitude < eastBoundLongitude) {
View Full Code Here

     * @param  extent The extent to convert to a geographic bounding box, or {@code null}.
     * @return A geographic bounding box extracted from the given extent, or {@code null}
     *         if the given extent was {@code null}.
     */
    public static GeographicBoundingBox getGeographicBoundingBox(final Extent extent) {
        GeographicBoundingBox candidate = null;
        if (extent != null) {
            DefaultGeographicBoundingBox modifiable = null;
            for (final GeographicExtent element : extent.getGeographicElements()) {
                final GeographicBoundingBox bounds;
                if (element instanceof GeographicBoundingBox) {
                    bounds = (GeographicBoundingBox) element;
                } else if (element instanceof BoundingPolygon) {
                    // TODO: iterates through all polygons and invoke Polygon.getEnvelope();
                    continue;
                } else {
                    continue;
                }
                /*
                 * A single geographic bounding box has been extracted. Now add it to previous
                 * ones (if any). All exclusion boxes before the first inclusion box are ignored.
                 */
                if (candidate == null) {
                    /*
                     * Reminder: 'inclusion' is a mandatory attribute, so it should never be
                     * null for a valid metadata object.  If the metadata object is invalid,
                     * it is better to get an exception than having a code doing silently
                     * some probably inappropriate work.
                     */
                    if (getInclusion(bounds.getInclusion())) {
                        candidate = bounds;
                    }
                } else {
                    if (modifiable == null) {
                        modifiable = new DefaultGeographicBoundingBox();
View Full Code Here

     *
     * @param  extent The extent to convert to a geographic bounding box, or {@code null}.
     * @return A geographic bounding box extracted from the given extent, or {@code null} in none.
     */
    public static GeographicBoundingBox getGeographicBoundingBox(final Extent extent) {
        GeographicBoundingBox candidate = null;
        if (extent != null) {
            DefaultGeographicBoundingBox modifiable = null;
            for (final GeographicExtent element : extent.getGeographicElements()) {
                final GeographicBoundingBox bounds;
                if (element instanceof GeographicBoundingBox) {
                    bounds = (GeographicBoundingBox) element;
                } else if (element instanceof BoundingPolygon) {
                    // TODO: iterates through all polygons and invoke Polygon.getEnvelope();
                    continue;
                } else {
                    continue;
                }
                /*
                 * A single geographic bounding box has been extracted. Now add it to previous
                 * ones (if any). All exclusion boxes before the first inclusion box are ignored.
                 */
                if (candidate == null) {
                    /*
                     * Reminder: 'inclusion' is a mandatory attribute, so it should never be
                     * null for a valid metadata object.  If the metadata object is invalid,
                     * it is better to get an exception than having a code doing silently
                     * some probably inappropriate work.
                     */
                    if (getInclusion(bounds.getInclusion())) {
                        candidate = bounds;
                    }
                } else {
                    if (modifiable == null) {
                        modifiable = new DefaultGeographicBoundingBox();
View Full Code Here

         *     …
         *   </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>
View Full Code Here

    /**
     * Tests {@link Extents#intersection(GeographicBoundingBox, GeographicBoundingBox)}.
     */
    @Test
    public void testIntersection() {
        final GeographicBoundingBox b1 = new DefaultGeographicBoundingBox(10, 20, 30, 40);
        final GeographicBoundingBox b2 = new DefaultGeographicBoundingBox(15, 25, 26, 32);
        assertEquals(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(null, null));
    }
View Full Code Here

TOP

Related Classes of org.opengis.metadata.extent.GeographicBoundingBox

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.