Package org.geotools.data.ows

Examples of org.geotools.data.ows.Layer


    String axisName(CoordinateReferenceSystem crs, int dimension) {
        return crs.getCoordinateSystem().getAxis(dimension).getName().getCode();
    }

    public void testImgSample130() throws Exception {
        Layer water_bodies = find("topp:tasmania_water_bodies");
        assertNotNull("Img_Sample layer found", water_bodies);
        CRSEnvelope latLon = water_bodies.getLatLonBoundingBox();
        assertEquals("LatLonBoundingBox axis 0 name", "Geodetic longitude",
                axisName(latLon.getCoordinateReferenceSystem(), 0));
        assertEquals("LatLonBoundingBox axis 0 name", "Geodetic latitude",
                axisName(latLon.getCoordinateReferenceSystem(), 1));

        boolean globalXY = Boolean.getBoolean("org.geotools.referencing.forceXY");
       
        CRSEnvelope bounds = water_bodies.getBoundingBoxes().get("EPSG:4326");
        CoordinateReferenceSystem boundsCRS = bounds.getCoordinateReferenceSystem();
        if( globalXY ){
            // ensure WMS CRSEnvelope returned according to application globalXY setting
            assertEquals( "EPSG:4326", AxisOrder.EAST_NORTH, CRS.getAxisOrder(boundsCRS) );
        }
View Full Code Here


    public void testImageSample111() throws Exception {
        WebMapServer wms111 = new WebMapServer(new URL(serverURL + "&VERSION=1.1.1"));
        WMSCapabilities caps = wms111.getCapabilities();
        assertEquals("1.1.1", caps.getVersion());
   
        Layer water_bodies = find("topp:tasmania_water_bodies", caps);
        assertNotNull("Img_Sample layer found", water_bodies);
        CRSEnvelope latLon = water_bodies.getLatLonBoundingBox();
        assertEquals("LatLonBoundingBox axis 0 name", "Geodetic longitude",
                axisName(latLon.getCoordinateReferenceSystem(), 0));
        assertEquals("LatLonBoundingBox axis 1 name", "Geodetic latitude",
                axisName(latLon.getCoordinateReferenceSystem(), 1));
   
        CRSEnvelope bounds = water_bodies.getBoundingBoxes().get("EPSG:4326");
        CoordinateReferenceSystem boundsCRS = bounds.getCoordinateReferenceSystem();
        assertEquals( "EPSG:4326", AxisOrder.EAST_NORTH, CRS.getAxisOrder(boundsCRS) );;
   
        assertEquals("axis order 0 min", latLon.getMinimum(0), bounds.getMinimum(0));
        assertEquals("axis order 1 min", latLon.getMinimum(1), bounds.getMinimum(1));
View Full Code Here

        // TODO UserDefinedSymbolization ignored
        // }

        if (sameName(elems[5], value[i])) {

          Layer layer = (Layer) value[i].getValue();

          capabilities.setLayer(layer);
        }
      }
View Full Code Here

        Set layers = new TreeSet();
   
        Layer[] namedLayers = getNamedLayers(capabilities);
   
        for( int i = 0; i < namedLayers.length; i++ ) {
            Layer layer = namedLayers[i];
   
            if (layer.isQueryable()) {
                layers.add(layer);
            }
        }
   
        return layers;
View Full Code Here

     * @return a Set of type String, containin EPSG codes, or empty if none found
     */
    public static Set findCommonEPSGs(List layers) {
      TreeSet set = new TreeSet();
     
      Layer first = (Layer) layers.get(0);
     
      set.addAll(first.getSrs());
     
      for (int i = 1; i < layers.size(); i++ ) {
        Layer layer = (Layer) layers.get(i);
        set.retainAll(layer.getSrs());
      }
     
      return set;
    }
View Full Code Here

        Iterator iter = queryLayers.iterator();
        String initialQueryLayerString = properties.getProperty(QUERY_LAYERS) == null ? "" : properties.getProperty(QUERY_LAYERS); //$NON-NLS-1$
        String queryLayerString = properties.getProperty(QUERY_LAYERS) == null ? "" : properties.getProperty(QUERY_LAYERS); //$NON-NLS-1$

        while( iter.hasNext() ) {
            Layer layer = (Layer) iter.next();
            try {
                queryLayerString = queryLayerString + URLEncoder.encode(layer.getName(), "UTF-8"); //$NON-NLS-1$
            } catch (UnsupportedEncodingException e) {
                queryLayerString = queryLayerString + layer.getName();
            }

            if (iter.hasNext()) {
                queryLayerString = queryLayerString + ","; //$NON-NLS-1$
            }
View Full Code Here

        if (namespace == null) {
            namespace = catalog.getDefaultNamespace();
        }
        wli.setNamespace(namespace);

        Layer layer = wli.getWMSLayer(null);

        // try to get the native SRS -> we use the bounding boxes, GeoServer will publish all of the
        // supported SRS in the root, if we use getSRS() we'll get them all
        for (String srs : layer.getBoundingBoxes().keySet()) {
            try {
                CoordinateReferenceSystem crs = CRS.decode(srs);
                wli.setSRS(srs);
                wli.setNativeCRS(crs);
            } catch (Exception e) {
                LOGGER.log(Level.INFO, "Skipping " + srs
                        + " definition, it was not recognized by the referencing subsystem");
            }
        }
        // fall back on WGS84 if necessary
        if (wli.getSRS() == null) {
            wli.setSRS("EPSG:4326");
            wli.setNativeCRS(DefaultGeographicCRS.WGS84);
        }
        wli.setProjectionPolicy(ProjectionPolicy.FORCE_DECLARED);

        // try to grab the envelope
        GeneralEnvelope envelope = layer.getEnvelope(wli.getNativeCRS());
        if (envelope != null) {
            ReferencedEnvelope re = new ReferencedEnvelope(envelope.getMinimum(0), envelope
                    .getMaximum(0), envelope.getMinimum(1), envelope.getMaximum(1), wli
                    .getNativeCRS());
            // are we in crazy wms 1.3 land?
            if(wli.getNativeCRS() instanceof GeographicCRS) {
                WebMapServer mapServer = wms.getWebMapServer(null);
                Version version = new Version(mapServer.getCapabilities().getVersion());
                if(version.compareTo(new Version("1.3.0")) >= 0) {
                    // flip axis, the wms code won't actually use the crs
                    double minx = re.getMinX();
                    double miny = re.getMinY();
                    double maxx = re.getMaxX();
                    double maxy = re.getMaxY();
                    re = new ReferencedEnvelope(miny, maxy, minx, maxx, wli.getNativeCRS());
                }
            }
            wli.setNativeBoundingBox(re);
        }
        CRSEnvelope llbbox = layer.getLatLonBoundingBox();
        if (llbbox != null) {
            ReferencedEnvelope re = new ReferencedEnvelope(llbbox.getMinX(), llbbox.getMaxX(),
                    llbbox.getMinY(), llbbox.getMaxY(), DefaultGeographicCRS.WGS84);
            wli.setLatLonBoundingBox(re);
        } else if (wli.getNativeBoundingBox() != null) {
            try {
                wli.setLatLonBoundingBox(wli.getNativeBoundingBox().transform(
                        DefaultGeographicCRS.WGS84, true));
            } catch (Exception e) {
                LOGGER.log(Level.INFO, "Could not transform native bbox into a lat/lon one", e);
            }
        }

        // reflect all the metadata that we can grab
        wli.setAbstract(layer.get_abstract());
        wli.setDescription(layer.get_abstract());
        wli.setTitle(layer.getTitle());
        if (layer.getKeywords() != null) {
            wli.getKeywords().addAll(Arrays.asList(layer.getKeywords()));
        }

        // strip off the prefix if we're cascading from a server that does add them
        String published = wli.getName();
        if (published.contains(":")) {
View Full Code Here

                            .append(mapLayerInfo.toString()).toString());
                }
            } else if (layerType == MapLayerInfo.TYPE_WMS) {
                WMSLayerInfo wmsLayer = (WMSLayerInfo) mapLayerInfo.getResource();
                WebMapServer wms = wmsLayer.getStore().getWebMapServer(null);
                Layer gt2Layer = wmsLayer.getWMSLayer(null);

                // see if we can merge this layer with the previous one
                boolean merged = false;
                if (mapContext.getLayerCount() > 0) {
                    MapLayer lastLayer = mapContext.getLayer(mapContext.getLayerCount() - 1);
View Full Code Here

        this.policy = policy;
    }
   
    @Override
    public Layer getWMSLayer(ProgressListener listener) throws IOException {
        Layer layer = super.getWMSLayer(listener);
        if(layer == null) {
            return layer;
        } else {
            return new SecuredWMSLayer(layer, policy);
        }
View Full Code Here

    }
   
    public URL getFinalURL() {
        // scan and check the layers
        for(int i = 0; i < queryLayers.size(); i++) {
            Layer layer = queryLayers.get(i);
            if(layer instanceof SecuredWMSLayer) {
                SecuredWMSLayer secured = (SecuredWMSLayer) layer;
                final WrapperPolicy policy = secured.getPolicy();
                // check if we can cascade GetFeatureInfo
                if(policy.getLimits() instanceof WMSAccessLimits) {
                    WMSAccessLimits limits = (WMSAccessLimits) policy.getLimits();
                    if(!limits.isAllowFeatureInfo()) {
                        if(policy.getResponse() == org.geoserver.security.Response.CHALLENGE) {
                            SecureCatalogImpl.unauthorizedAccess(layer.getName());
                        } else {
                            throw new IllegalArgumentException("Layer " + layer.getName() + " is not queriable");
                        }
                    }
                }
               
                // add into the request
View Full Code Here

TOP

Related Classes of org.geotools.data.ows.Layer

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.