Package org.geotools.data.ows

Examples of org.geotools.data.ows.WMSCapabilities


        }
       
        checkProperties(properties);
        try{
            WebMapServer wms = new WebMapServer(server);
            WMSCapabilities capabilities = wms.getCapabilities();
           
            assertNotNull(capabilities);
        } catch(java.net.ConnectException ce){
            if(ce.getMessage().indexOf("timed out")>0){
                System.err.println("Unable to test - timed out: "+ce);
View Full Code Here


        assertEquals(properties.getProperty("REQUEST"), "capabilities");
        assertEquals(properties.getProperty("WMTVER"), "1.0.0");
    }
   
    public void testCreateParser() throws Exception {
        WMSCapabilities capabilities = createCapabilities(
                "1.0.0Capabilities.xml");
        try{
            assertEquals(capabilities.getVersion(), "1.0.0");
            assertEquals(capabilities.getService().getName(), "GetMap");
            assertEquals(capabilities.getService().getTitle(), "World Map");
           
            for (int i = 0; i < capabilities.getService().getKeywordList().length;
            i++) {
                assertEquals(capabilities.getService().getKeywordList()[i],
                        "OpenGIS WMS Web Map Server".split(" ")[i]);
            }
           
            assertEquals(capabilities.getService().getOnlineResource(),
                    new URL("http://www2.demis.nl"));
            assertEquals(capabilities.getRequest().getGetCapabilities()
            .getFormats().get(0),
                    "application/vnd.ogc.wms_xml");
            assertEquals(capabilities.getRequest().getGetFeatureInfo().getGet(),
                    new URL("http://www2.demis.nl/wms/wms.asp?wms=WorldMap&"));
            assertEquals(capabilities.getRequest().getGetMap().getFormats().size(),
                    4);
           
            assertEquals(capabilities.getLayerList().size(), 21);
           
            Layer[] layers = (Layer[]) capabilities.getLayerList().toArray(new Layer[capabilities.getLayerList().size()]);
            assertEquals(layers[0].getTitle(), "World Map");
            assertEquals(layers[0].getParent(), null);
            assertTrue(layers[0].getSrs().contains("EPSG:4326")); //  case should not matter
            assertTrue(layers[0].getSrs().contains("EPSG:4327"));
            assertEquals(layers[1].getTitle(), "Bathymetry");
View Full Code Here

    }
   
    public void testCreateGetMapRequest() throws Exception {
        try{
            CustomWMS wms = new CustomWMS(server);
            WMSCapabilities caps = wms.getCapabilities();
            GetMapRequest request = wms.createGetMapRequest();
            request.setFormat("image/jpeg");
            System.out.println(request.getFinalURL().toExternalForm());
           
            assertTrue(request.getFinalURL().toExternalForm().indexOf("jpeg") >= 0);
View Full Code Here

            Schema schema = WMSSchema.getInstance();
            SchemaFactory.getInstance(WMSSchema.NAMESPACE);
           
            assertTrue("Capabilities failed to parse", object instanceof WMSCapabilities);
           
            WMSCapabilities capabilities = (WMSCapabilities) object;
            return capabilities;
        } catch(java.net.ConnectException ce){
            if(ce.getMessage().indexOf("timed out")>0){
                System.err.println("Unable to test - timed out: "+ce);
                return null;
View Full Code Here

    }

    public void testIssueGetMapRequest() throws Exception {
        WebMapServer wms = new WebMapServer(serverURL);

        WMSCapabilities capabilities = wms.getCapabilities();

        GetMapRequest request = wms.createGetMapRequest();

        //request.setVersion("1.1.1");
View Full Code Here

    }
       
    public void testGetEnvelope() throws Exception {
        WebMapServer wms = new WebMapServer(featureURL);
       
        WMSCapabilities caps = wms.getCapabilities();
       
        Layer layer = (Layer) caps.getLayerList().get(0);
        CoordinateReferenceSystem crs = CRS.decode("EPSG:4326");
       
        GeneralEnvelope envelope = wms.getEnvelope(layer, crs);
       
//        minx="-172.367" miny="35.6673" maxx="-11.5624" maxy="83.8293" />
        assertEquals(envelope.getMinimum(0), -172.367, 0.0);
        assertEquals(envelope.getMinimum(1), 35.6673, 0.0);
        assertEquals(envelope.getMaximum(0), -11.5624, 0.0);
        assertEquals(envelope.getMaximum(1), 83.8293, 0.0);

        crs = CRS.decode("EPSG:42304");
        envelope = wms.getEnvelope(layer, crs);
       
//        minx="-2.2e+06" miny="-712631" maxx="3.0728e+06" maxy="3.84e+06" />
        assertEquals(envelope.getMinimum(0), -2.2e+06, 0.0);
        assertEquals(envelope.getMinimum(1), -712631, 0.0);
        assertEquals(envelope.getMaximum(0), 3.0728e+06, 0.0);
        assertEquals(envelope.getMaximum(1), 3.84e+06, 0.0);
       
        layer = (Layer) caps.getLayerList().get(2);
        crs = CRS.decode("EPSG:4326");
       
        envelope = wms.getEnvelope(layer, crs);
       
//        minx="-178.838" miny="31.8844" maxx="179.94" maxy="89.8254" />
View Full Code Here

        Schema schema = WMSSchema.getInstance();
    SchemaFactory.getInstance(WMSSchema.NAMESPACE);
       
    assertTrue("Capabilities failed to parse", object instanceof WMSCapabilities);
   
    WMSCapabilities capabilities = (WMSCapabilities) object;
   
    assertEquals(capabilities.getVersion(), "1.3.0");
    assertEquals(capabilities.getService().getName(), "WMS");
    assertEquals(capabilities.getService().getTitle(), "World Map");
    assertEquals(capabilities.getService().get_abstract(), "None");
    assertEquals(capabilities.getService().getOnlineResource(), new URL("http://www2.demis.nl"));
   
    assertEquals(capabilities.getService().getLayerLimit(), 40);
    assertEquals(capabilities.getService().getMaxWidth(), 2000);
    assertEquals(capabilities.getService().getMaxHeight(), 2000);
   
    assertEquals(capabilities.getRequest().getGetCapabilities().getFormats().get(0), "text/xml");
    assertEquals(capabilities.getRequest().getGetCapabilities().getGet(), new URL("http://www2.demis.nl/wms/wms.asp?wms=WorldMap&"));
    assertEquals(capabilities.getRequest().getGetCapabilities().getPost(), new URL("http://www2.demis.nl/wms/wms.asp?wms=WorldMap&"));
   
    assertEquals(capabilities.getRequest().getGetMap().getFormats().size(), 5);
    assertEquals(capabilities.getRequest().getGetMap().getFormats().get(0), "image/gif");
    assertEquals(capabilities.getRequest().getGetMap().getFormats().get(1), "image/png");
    assertEquals(capabilities.getRequest().getGetMap().getFormats().get(2), "image/jpeg");
    assertEquals(capabilities.getRequest().getGetMap().getFormats().get(3), "image/bmp");
    assertEquals(capabilities.getRequest().getGetMap().getFormats().get(4), "image/swf");
    assertEquals(capabilities.getRequest().getGetMap().getGet(), new URL("http://www2.demis.nl/wms/wms.asp?wms=WorldMap&"));
   
    assertEquals(capabilities.getRequest().getGetFeatureInfo().getFormats().size(), 4);
    assertEquals(capabilities.getRequest().getGetFeatureInfo().getFormats().get(0), "text/xml");
    assertEquals(capabilities.getRequest().getGetFeatureInfo().getFormats().get(1), "text/plain");
    assertEquals(capabilities.getRequest().getGetFeatureInfo().getFormats().get(2), "text/html");
    assertEquals(capabilities.getRequest().getGetFeatureInfo().getFormats().get(3), "text/swf");
    assertEquals(capabilities.getRequest().getGetFeatureInfo().getGet(), new URL("http://www2.demis.nl/wms/wms.asp?wms=WorldMap&"));
   
    Layer topLayer = (Layer) capabilities.getLayerList().get(0);
    assertNotNull(topLayer);
    assertNull(topLayer.getParent());
    assertFalse(topLayer.isQueryable());
    assertEquals(topLayer.getTitle(), "World Map");
    assertEquals(topLayer.getSrs().size(), 1);
    assertTrue(topLayer.getSrs().contains("CRS:84"));
   
    CRSEnvelope llbbox = topLayer.getLatLonBoundingBox();
    assertNotNull(llbbox);
    assertEquals(llbbox.getMinX(), -180, 0.0);
    assertEquals(llbbox.getMaxX(), 180, 0.0);
    assertEquals(llbbox.getMinY(), -90, 0.0);
    assertEquals(llbbox.getMaxY(), 90, 0.0);
   
    assertEquals(topLayer.getBoundingBoxes().size(), 1);
   
    CRSEnvelope bbox = (CRSEnvelope) topLayer.getBoundingBoxes().get("CRS:84");
    assertNotNull(bbox);
    assertEquals(bbox.getEPSGCode(), "CRS:84");
    assertEquals(bbox.getMinX(), -184, 0.0);
    assertEquals(bbox.getMaxX(), 180, 0.0);
    assertEquals(bbox.getMinY(), -90.0000000017335, 0.0);
    assertEquals(bbox.getMaxY(), 90, 0.0);
   
    Layer layer = (Layer) capabilities.getLayerList().get(1);
    assertEquals(layer.getParent(), topLayer);
    assertTrue(layer.isQueryable());
    assertEquals(layer.getName(), "Bathymetry");
    assertEquals(layer.getTitle(), "Bathymetry");
    assertEquals(layer.getMetadataURL().get(0).getUrl().toString(), "http://www.example.com/?");
    assertEquals(layer.getMetadataURL().get(0).getFormat(), "text/html");
    assertEquals(layer.getMetadataURL().get(0).getType(), "FGDC");
    assertEquals(layer.getStyles().get(0).getLegendURLs().get(0), "http://www.osgeo.org/sites/all/themes/osgeo/logo.png");
   
    // Added test to verify inheritance, should be same as previous llbbox
    llbbox = layer.getLatLonBoundingBox();
    assertNotNull(llbbox);
    assertEquals(llbbox.getMinX(), -180, 0.0);
    assertEquals(llbbox.getMaxX(), 180, 0.0);
    assertEquals(llbbox.getMinY(), -90, 0.0);
    assertEquals(llbbox.getMaxY(), 90, 0.0);
   
    bbox = (CRSEnvelope) layer.getBoundingBoxes().get("CRS:84");
    assertNotNull(bbox);
    assertEquals(bbox.getEPSGCode(), "CRS:84");
    assertEquals(bbox.getMinX(), -180, 0.0);
    assertEquals(bbox.getMaxX(), 180, 0.0);
    assertEquals(bbox.getMinY(), -90, 0.0);
    assertEquals(bbox.getMaxY(), 90, 0.0);
   
    assertEquals(capabilities.getLayerList().size(), 21);
   
    layer = (Layer) capabilities.getLayerList().get(20);
    assertEquals(layer.getParent(), topLayer);
    assertTrue(layer.isQueryable());
    assertEquals(layer.getName(), "Ocean features");
    assertEquals(layer.getTitle(), "Ocean features");
   
View Full Code Here

        Schema schema = WMSSchema.getInstance();
    SchemaFactory.getInstance(WMSSchema.NAMESPACE);
       
    assertTrue("Capabilities failed to parse", object instanceof WMSCapabilities);
   
    WMSCapabilities capabilities = (WMSCapabilities) object;
   
    Layer Layer_with_Abstract_in_Style = (Layer) capabilities.getLayerList().get(1);
    assertEquals(Layer_with_Abstract_in_Style.getName(), "Layer_with_Abstract_in_Style");
    assertEquals(Layer_with_Abstract_in_Style.getTitle(), "Layer with Abstract in Style");
    assertEquals("http://www.osgeo.org/sites/all/themes/osgeo/logo.png", Layer_with_Abstract_in_Style.getStyles().get(0).getLegendURLs().get(0));
   
    Layer Layer_with_empty_Abstract_in_Style = (Layer) capabilities.getLayerList().get(2);
    assertEquals(Layer_with_empty_Abstract_in_Style.getName(), "Layer_with_empty_Abstract_in_Style");
    assertEquals(Layer_with_empty_Abstract_in_Style.getTitle(), "Layer with empty Abstract in Style");
    assertEquals("http://www.osgeo.org/sites/all/themes/osgeo/logo.png", Layer_with_empty_Abstract_in_Style.getStyles().get(0).getLegendURLs().get(0));
   
  }
View Full Code Here

            out.println("SAXException: "+e.getMessage());
            e.printStackTrace(out);
            return passed;
        }

        WMSCapabilities caps = wms.getCapabilities();
        assertNotNull(caps);

        out.println("Validating layer LatLonBoundingBoxes...");
        Iterator iter = caps.getLayerList().iterator();
        while (iter.hasNext()) {
            Layer layer = (Layer) iter.next();
            if (layer.getLatLonBoundingBox() == null) {
                if (layer.getName() != null) {
                    out.println("WARNING: Layer '"+layer.getName()+"' contains no LatLonBoundingBox.");
                    passed = false;
                }
            }
        }

        Layer layer = null;
        out.print("Looking for a named layer...");
        iter = caps.getLayerList().iterator();
        while (iter.hasNext()) {
            Layer tempLayer = (Layer) iter.next();
            if (tempLayer.getName() != null) {
                layer = tempLayer;
                out.println("found one. Using layer '"+layer.getName()+"'");
                break;
            }
        }
        String format = null;
        if (layer == null) {
            out.println("server contains no named layers. Cannot perform GetMap requests on it");
            passed = false;
        } else {
            out.print("Checking for GetMap operation...");
            if (caps.getRequest().getGetMap() == null) {
                out.println("NOT FOUND. Will attempt a request using 'image/gif' anyway.");
                passed = false;
                format = "image/gif";
            } else {
                out.println("found.");
                out.print("Searching for a suitable format...");
                List formats = caps.getRequest().getGetMap().getFormats();
                if (formats.contains("image/png")) {
                    format = "image/png";
                    out.println("using 'image/png'.");
                }
View Full Code Here

        assertEquals(spec.getVersion(), "1.1.1");
    }

    public void testCreateParser() throws Exception {
        try{
            WMSCapabilities capabilities = createCapabilities("1.1.1Capabilities.xml");
           
            assertEquals(capabilities.getVersion(), "1.1.1");
            assertEquals(capabilities.getService().getName(), "OGC:WMS");
            assertEquals(capabilities.getService().getTitle(), "Microsoft TerraServer Map Server");
            assertEquals(capabilities.getService().get_abstract(), "WMT Map Server maintained by Microsoft Corporation.  Data returned provided by US Geological Survey.  Contact: tbarclay@microsoft.com or gylee@usgs.gov.");
            assertEquals(capabilities.getService().getOnlineResource(), new URL("http://terraservice.net/"));
           
            String[] keywords = { "USGS", "DOQ", "DRG", "Topographic", "UrbanArea", "Urban Areas" };
           
            for (int i = 0; i < capabilities.getService().getKeywordList().length; i++) {
                assertEquals(capabilities.getService().getKeywordList()[i],
                        keywords[i]);
            }
                       
            assertEquals(capabilities.getService().getContactInformation().getIndividualName(), "Some guy");
            assertEquals(capabilities.getService().getContactInformation().getOrganisationName().toString(), "Some company");
            assertEquals(capabilities.getService().getContactInformation().getPositionName().toString(), "Researcher");
            assertEquals(capabilities.getService().getContactInformation().getContactInfo().getPhone().getVoices().iterator().next(), "+1 555 555 5555");
            assertEquals(capabilities.getService().getContactInformation().getContactInfo().getPhone().getFacsimiles().iterator().next(), "+1 555 555 5556");
            assertEquals(capabilities.getService().getContactInformation().getContactInfo().getAddress().getPostalCode(), "11111");
            assertEquals(capabilities.getService().getContactInformation().getContactInfo().getAddress().getAdministrativeArea().toString(), "CA");
            assertEquals(capabilities.getService().getContactInformation().getContactInfo().getAddress().getCity().toString(), "San Francisco");
            assertEquals(capabilities.getService().getContactInformation().getContactInfo().getAddress().getCountry().toString(), "USA");
            assertEquals(capabilities.getService().getContactInformation().getContactInfo().getAddress().getDeliveryPoints().iterator().next(), "555 Street St.");
            assertEquals(capabilities.getService().getContactInformation().getContactInfo().getAddress().getElectronicMailAddresses().iterator().next(), "email@domain.com");
           
            assertEquals(capabilities.getRequest().getGetCapabilities().getFormats().get(0), "application/vnd.ogc.wms_xml");
            assertEquals(capabilities.getRequest().getGetCapabilities().getGet(), new URL("http://terraservice.net/ogccapabilities.ashx"));
            assertEquals(capabilities.getRequest().getGetCapabilities().getPost(), new URL("http://terraservice.net/ogccapabilities.ashx"));
           
            assertEquals(capabilities.getRequest().getGetMap().getFormats().get(0), "image/jpeg");
            assertEquals(capabilities.getRequest().getGetMap().getGet(), new URL("http://terraservice.net/ogcmap.ashx"));
           
            assertNull(capabilities.getRequest().getGetFeatureInfo());
           
            assertEquals(capabilities.getLayerList().size(), 4);
           
            Layer layer = (Layer) capabilities.getLayerList().get(0);
            assertNotNull(layer);
            assertNull(layer.getName());
            assertEquals(layer.getTitle(), "Microsoft TerraServer Map Server");
            assertEquals(layer.getSrs().size(), 1);
            assertTrue(layer.getSrs().contains("EPSG:4326" ));
           
            validateBoundingBox(layer.getLatLonBoundingBox(),
                    -168.67, 17.84, -65.15, 71.55);
           
            assertNull(layer.getParent());
            assertEquals(layer.getBoundingBoxes().size(), 0);
            assertEquals(layer.getStyles().size(), 0);
           
            layer = (Layer) capabilities.getLayerList().get(1);
            assertEquals(layer.getName(), "DOQ");
            assertEquals(layer.getTitle(), "USGS Digital Ortho-Quadrangles");
            // changed expected to 14 to account for inherited srs
            assertEquals(layer.getSrs().size(), 14);
            // Added additional check to test for inherited srs
            assertTrue(layer.getSrs().contains("EPSG:4326"));
            assertTrue(layer.getSrs().contains("EPSG:26905"));
            assertTrue(layer.getSrs().contains("EPSG:26920"));
            assertEquals(layer.getBoundingBoxes().size(), 13);
            CRSEnvelope bbox = (CRSEnvelope) layer.getBoundingBoxes().get("EPSG:26905");
            assertNotNull(bbox);
            assertEquals(bbox.getEPSGCode(), "EPSG:26905");
            assertEquals(bbox.getMinX(), 552600.0, 0.0);
            assertEquals(bbox.getMinY(), 6540200.0, 0.0);
            assertEquals(bbox.getMaxX(), 670200.0, 0.0);
            assertEquals(bbox.getMaxY(), 6794800.0, 0.0);
            assertEquals(10, layer.getScaleHintMin(), 0);
            assertEquals(10000, layer.getScaleHintMax(), 0);
           
            bbox = (CRSEnvelope) layer.getBoundingBoxes().get("EPSG:26920");
            assertNotNull(bbox);
            assertEquals(bbox.getEPSGCode(), "EPSG:26920");
            assertEquals(bbox.getMinX(), 181800.0, 0.0);
            assertEquals(bbox.getMinY(), 1985200.0, 0.0);
            assertEquals(bbox.getMaxX(), 269400.0, 0.0);
            assertEquals(bbox.getMaxY(), 2048600.0, 0.0);
           
            // Changed expected value, no duplicates allowed by spec
            assertEquals(layer.getStyles().size(), 18);
            assertTrue(layer.getStyles().contains(new StyleImpl("UTMGrid")));
            assertTrue(layer.getStyles().contains(new StyleImpl("GeoGrid_Cyan")));
            assertTrue(layer.getStyles().contains(new StyleImpl("GeoGrid_Black")));
            assertTrue(layer.getStyles().contains(new StyleImpl("GeoGrid_Gray")));
            assertTrue(layer.getStyles().contains(new StyleImpl("GeoGrid_White")));
           
            StyleImpl utmGrid = (StyleImpl) layer.getStyles().get(0);
            assertEquals(utmGrid.getName(), "UTMGrid");
            assertEquals(utmGrid.getAbstract().toString(), "Display grid lines in Goldenrod on the DOQ image");
            assertEquals(utmGrid.getTitle().toString(), "Goldedrod Grid Lines on UTM coordinates");
           
            assertFalse(layer.isQueryable());
           
            // Added test to verify inheritance, should be same as previous llbbox
            validateBoundingBox(layer.getLatLonBoundingBox(),
                    -168.67, 17.84, -65.15, 71.55);
           
           
           
            layer = (Layer) capabilities.getLayerList().get(2);
            assertNotNull(layer);
            assertEquals(layer.getName(), "DRG");
            assertEquals(layer.getTitle(), "USGS Raster Graphics (Topo Maps)");
            // Added test to verify inheritance, should be same as previous llbbox
            validateBoundingBox(layer.getLatLonBoundingBox(),
                    -168.67, 17.84, -65.15, 71.55);
           
            assertEquals(50, layer.getScaleHintMin(), 0);
           
            layer = (Layer) capabilities.getLayerList().get(3);
            assertNotNull(layer);
            assertEquals(layer.getName(), "UrbanArea");
            assertEquals(layer.getTitle(), "USGS Urban Areas Ortho-Imagery");
            // Added test to verify inheritance, should be same as previous llbbox
            validateBoundingBox(layer.getLatLonBoundingBox(),
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.