Package org.geotools.data.ows

Examples of org.geotools.data.ows.WMSCapabilities


        Schema schema = WMSSchema.getInstance();
        SchemaFactory.getInstance(WMSSchema.NAMESPACE);

        assertTrue("Capabilities failed to parse", object instanceof WMSCapabilities);

        WMSCapabilities capabilities = (WMSCapabilities) object;

        // Get first test layer
        Layer layer = (Layer) capabilities.getLayerList().get(0);
        assertNotNull(layer);
        assertEquals(3,layer.getDimensions().size());
        assertEquals("ISO8601",layer.getDimension("time").getUnits());

        // Get next test layer, it's nested 3 deep
        List<Layer> allLayers = capabilities.getLayerList();
       
        layer = (Layer) allLayers.get(2);
        assertNotNull(layer);
        assertNotNull(layer.getParent());
        assertEquals(3,layer.getDimensions().size());

        // Should be false by default since not specified in layer or ancestors
        assertFalse(layer.isQueryable());
        assertEquals(layer.getTitle(), "Coastlines");

        // Should be 5 total after accumulating all ancestors
        assertEquals(5,layer.getSrs().size());
        assertTrue(layer.getSrs().contains("EPSG:26906"));
        assertTrue(layer.getSrs().contains("EPSG:26905"));
        assertTrue(layer.getSrs().contains("EPSG:4326"));
        assertTrue(layer.getSrs().contains("AUTO:42003"));
        assertTrue(layer.getSrs().contains("AUTO:42005"));

        // 2 total, this layer plus top most layer
        assertEquals(layer.getStyles().size(), 2);
        assertTrue(layer.getStyles().contains(new StyleImpl("TestStyle")));
        assertTrue(layer.getStyles().contains(new StyleImpl("default")));

        // Next test layer, nested 3 deep but different path
        layer = (Layer) capabilities.getLayerList().get(4);
        assertNotNull(layer);
        assertNotNull(layer.getParent());
        assertEquals(3, layer.getDimensions().size());
        assertEquals(1, layer.getExtents().size());
        assertEquals(layer.getExtent("time").getName(), "time");
View Full Code Here


        checkGetFeatureInfo( wms, water_bodies, CRS.decode("urn:x-ogc:def:crs:EPSG::4326") );
    }

    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",
View Full Code Here

     *      java.util.Map)
     */
    public Object getValue(Element element, ElementValue[] value,
        Attributes attrs, Map hints) throws SAXException,
        OperationNotSupportedException {
      WMSCapabilities capabilities = new WMSCapabilities();

      for (int i = 0; i < value.length; i++) {
        if (sameName(elems[0], value[i])) {
          capabilities.setRequest((WMSRequest) value[i].getValue());
        }

         if (sameName(elems[1], value[i])) {
             capabilities.setExceptions((String[]) value[i].getValue());
         }

        // if (sameName(elems[2], value[i])) {
        // TODO ExtendedCapabilities ignored
        // }
        // if (sameName(elems[3], value[i])) {
        // TODO VendorSpecificCapabilities ignored
        // }
        // if (sameName(elems[4], value[i])) {
        // TODO UserDefinedSymbolization ignored
        // }

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

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

          capabilities.setLayer(layer);
        }
      }

      return capabilities;
    }
View Full Code Here

     */
    public Object getValue(Element element, ElementValue[] value,
        Attributes attrs, Map hints) throws SAXException,
        OperationNotSupportedException {

      WMSCapabilities capabilities = null;
      Service service = null;

      for (int i = 0; i < value.length; i++) {
        if (sameName(elems[0], value[i])) {
          service = ((Service) value[i].getValue());
        }

        if (sameName(elems[1], value[i])) {
          capabilities = (WMSCapabilities) value[i].getValue();
        }
      }

      capabilities.setVersion(attrs.getValue("", "version")); //$NON-NLS-1$//$NON-NLS-2$
      capabilities.setUpdateSequence(attrs.getValue("", "updateSequence")); //$NON-NLS-1$//$NON-NLS-2$

      capabilities.setService(service);

      return capabilities;
    }
View Full Code Here

     */
    public Object getValue(Element element, ElementValue[] value,
        Attributes attrs, Map hints) throws SAXException,
        OperationNotSupportedException {

      WMSCapabilities capabilities = null;
      Service service = null;

      for (int i = 0; i < value.length; i++) {
        if (sameName(elems[0], value[i])) {
          service = ((Service) value[i].getValue());
        }

        if (sameName(elems[1], value[i])) {
          capabilities = (WMSCapabilities) value[i].getValue();
        }
      }

      capabilities.setVersion(attrs.getValue("", "version")); //$NON-NLS-1$//$NON-NLS-2$
      capabilities.setUpdateSequence(attrs.getValue("", "updateSequence")); //$NON-NLS-1$//$NON-NLS-2$

      capabilities.setService(service);

      return capabilities;
    }
View Full Code Here

        String name = info.getName();
        if (info.getNativeName() != null) {
            name = info.getNativeName();
        }

        WMSCapabilities caps = info.getStore().getWebMapServer(null).getCapabilities();
        for (Layer layer : caps.getLayerList()) {
            if (name.equals(layer.getName())) {
                return layer;
            }
        }
View Full Code Here

        String name = info.getName();
        if (info.getNativeName() != null) {
            name = info.getNativeName();
        }

        WMSCapabilities caps = info.getStore().getWebMapServer(null).getCapabilities();
        for (Layer layer : caps.getLayerList()) {
            if (name.equals(layer.getName())) {
                return layer;
            }
        }
View Full Code Here

                WMSLayerInfo info = (WMSLayerInfo) layer.getResource();
                Layer wl = info.getWMSLayer(null);
                if (!wl.isQueryable()) {
                    return false;
                }
                WMSCapabilities caps = info.getStore().getWebMapServer(null).getCapabilities();
                OperationType featureInfo = caps.getRequest().getGetFeatureInfo();
                if (featureInfo == null || !featureInfo.getFormats()
                        .contains("application/vnd.ogc.gml")) {
                    return false;
                }
            }
View Full Code Here

                WMSLayerInfo info = (WMSLayerInfo) layer.getResource();
                Layer wl = info.getWMSLayer(null);
                if (!wl.isQueryable()) {
                    return false;
                }
                WMSCapabilities caps = info.getStore().getWebMapServer(null).getCapabilities();
                if (!caps.getRequest().getGetFeatureInfo().getFormats()
                        .contains("application/vnd.ogc.gml")) {
                    return false;
                }
            }
View Full Code Here

    private List<TileLayer> getLayers(WebMapServer wms, String wmsUrl, String urlVersion)
            throws GeoWebCacheException {
        List<TileLayer> layers = new LinkedList<TileLayer>();

        WMSCapabilities capabilities = wms.getCapabilities();
        if (capabilities == null) {
            throw new ConfigurationException("Unable to get capabitilies from " + wmsUrl);
        }

        WMSHttpHelper sourceHelper = new WMSHttpHelper();

        List<Layer> layerList = capabilities.getLayerList();
        Iterator<Layer> layerIter = layerList.iterator();

        while (layerIter.hasNext()) {
            Layer layer = layerIter.next();
            String name = layer.getName();
            String stylesStr = "";

            String title = layer.getTitle();

            String description = layer.get_abstract();

            LayerMetaInformation layerMetaInfo = null;
            if (title != null || description != null) {
                layerMetaInfo = new LayerMetaInformation(title, description, null, null);
            }
            boolean queryable = layer.isQueryable();

            if (name != null) {
                List<StyleImpl> styles = layer.getStyles();

                StringBuffer buf = new StringBuffer();
                if (styles != null) {
                    Iterator<StyleImpl> iter = styles.iterator();
                    boolean hasOne = false;
                    while (iter.hasNext()) {
                        if (hasOne) {
                            buf.append(",");
                        }
                        buf.append(iter.next().getName());
                        hasOne = true;
                    }
                    stylesStr = buf.toString();
                }

                double minX = layer.getLatLonBoundingBox().getMinX();
                double minY = layer.getLatLonBoundingBox().getMinY();
                double maxX = layer.getLatLonBoundingBox().getMaxX();
                double maxY = layer.getLatLonBoundingBox().getMaxY();

                BoundingBox bounds4326 = new BoundingBox(minX, minY, maxX, maxY);

                log.info("Found layer: " + layer.getName() + " with LatLon bbox "
                        + bounds4326.toString());

                BoundingBox bounds3785 = new BoundingBox(longToSphericalMercatorX(minX),
                        latToSphericalMercatorY(minY), longToSphericalMercatorX(maxX),
                        latToSphericalMercatorY(maxY));

                String[] wmsUrls = { wmsUrl };

                LinkedList<ParameterFilter> paramFilters = new LinkedList<ParameterFilter>();
                for (Dimension dimension : layer.getDimensions().values()) {
                    Extent dimExtent = layer.getExtent(dimension.getName());
                    paramFilters.add(new NaiveWMSDimensionFilter(dimension, dimExtent));
                }

                WMSLayer wmsLayer = null;
                try {
                    wmsLayer = getLayer(name, wmsUrls, bounds4326, bounds3785, stylesStr,
                            queryable, layer.getBoundingBoxes(), paramFilters);
                } catch (GeoWebCacheException gwc) {
                    log.error("Error creating " + layer.getName() + ": " + gwc.getMessage());
                }

                if (wmsLayer != null) {

                    // Finalize with some defaults
                    wmsLayer.setCacheBypassAllowed(allowCacheBypass);
                    wmsLayer.setBackendTimeout(backendTimeout);

                    wmsLayer.setMetaInformation(layerMetaInfo);

                    if (urlVersion != null) {
                        wmsLayer.setVersion(urlVersion);
                    } else {
                        String wmsVersion = capabilities.getVersion();
                        if (wmsVersion != null && wmsVersion.length() > 0) {
                            wmsLayer.setVersion(wmsVersion);
                        }
                    }
                    wmsLayer.setSourceHelper(sourceHelper);
View Full Code Here

TOP

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

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.