Package org.geoserver.wfs

Examples of org.geoserver.wfs.WFSInfo


        assertEquals("http://www.geoserver.org/inspire/one", ns.getFirstChild().getNodeValue());
    }

    @Test
    public void testChangeMediaType() throws Exception {
        WFSInfo wfs = getGeoServer().getService(WFSInfo.class);
        wfs.getMetadata().put(InspireMetadata.LANGUAGE.key, "fre");
        wfs.getMetadata().put(InspireMetadata.SERVICE_METADATA_URL.key, "http://foo.com?bar=baz");
        getGeoServer().save(wfs);

        Document dom = getAsDOM("wfs?request=getcapabilities&service=wfs&version=1.1.0");
        // print(dom);
        assertEquals(DLS_NAMESPACE, dom.getDocumentElement().getAttribute("xmlns:inspire_dls"));
        assertMetadataUrlAndMediaType(dom, "http://foo.com?bar=baz", "application/vnd.ogc.csw.GetRecordByIdResponse_xml");

        wfs.getMetadata().put(InspireMetadata.SERVICE_METADATA_TYPE.key, "application/xml");
        getGeoServer().save(wfs);

        dom = getAsDOM("wfs?request=getcapabilities&service=wfs&version=1.1.0");
        assertEquals(DLS_NAMESPACE, dom.getDocumentElement().getAttribute("xmlns:inspire_dls"));
        assertMetadataUrlAndMediaType(dom, "http://foo.com?bar=baz", "application/xml");
View Full Code Here


public class GetFeatureTest extends WFSTestSupport {
 
    @Override
    protected void setUpInternal(SystemTestData data) throws Exception {
      WFSInfo wfs = getWFS();
        wfs.setFeatureBounding(true);
      getGeoServer().save(wfs);
     
      data.addVectorLayer ( new QName( SystemTestData.SF_URI, "WithGMLProperties", SystemTestData.SF_PREFIX ),
          Collections.EMPTY_MAP, getClass(), getCatalog());
    }
View Full Code Here

    }
   
  
    @Override
    protected void setUpInternal(SystemTestData data) throws Exception {
        WFSInfo wfs = getWFS();
        wfs.setFeatureBounding(true);
        getGeoServer().save( wfs );
    }
View Full Code Here

        runTest(dom1, dom2);
    }
   
    @Test
    public void testGetFeatureWithAutoBoxGet() throws Exception {
        WFSInfo wfs = getWFS();
        boolean oldFeatureBounding = wfs.isFeatureBounding();
        wfs.setFeatureBounding(true);
        getGeoServer().save(wfs);

        try {
            String q = "wfs?request=getfeature&service=wfs&version=1.1&typeName="
                    + SystemTestData.POLYGONS.getLocalPart();
            Document dom = getAsDOM(q);
            // print(dom);
            Element envelope = getFirstElementByTagName(dom, "gml:Envelope");
            String lc = getFirstElementByTagName(envelope, "gml:lowerCorner").getFirstChild()
                    .getNodeValue();
            String uc = getFirstElementByTagName(envelope, "gml:upperCorner").getFirstChild()
                    .getNodeValue();
            double[] c = new double[] { Double.parseDouble(lc.split(" ")[0]),
                    Double.parseDouble(lc.split(" ")[1]), Double.parseDouble(uc.split(" ")[0]),
                    Double.parseDouble(uc.split(" ")[1]) };

            // use an equirectangular projection
            String targetCrsCode = "AUTO:42004,9001,0,33";
            CoordinateReferenceSystem epsgAUTO = CRS.decode(targetCrsCode);
            MathTransform txAuto = CRS.findMathTransform(epsg32615, epsgAUTO);

            System.out.println(Arrays.toString(c));

            double[] cr = new double[4];
            txAuto.transform(c, 0, cr, 0, 2);

            q += "&bbox=" + cr[0] + "," + cr[1] + "," + cr[2] + "," + cr[3] + "," + targetCrsCode;
            dom = getAsDOM(q);

            assertEquals(
                    1,
                    dom.getElementsByTagName(
                            SystemTestData.POLYGONS.getPrefix() + ":"
                                    + SystemTestData.POLYGONS.getLocalPart()).getLength());
        } finally {
            wfs.setFeatureBounding(oldFeatureBounding);
            getGeoServer().save(wfs);
        }
    }
View Full Code Here

        }
    }
   
    @Test
    public void testGetFeatureWithProjectedBoxGet() throws Exception {
        WFSInfo wfs = getWFS();
        boolean oldFeatureBounding = wfs.isFeatureBounding();
        wfs.setFeatureBounding(true);
        getGeoServer().save(wfs);
           
        try {
            String q = "wfs?request=getfeature&service=wfs&version=1.1&typeName=" +
                SystemTestData.POLYGONS.getLocalPart();
            Document dom = getAsDOM( q );
            //        print(dom);
            Element envelope = getFirstElementByTagName(dom, "gml:Envelope" );
            String lc = getFirstElementByTagName(envelope, "gml:lowerCorner" )
                .getFirstChild().getNodeValue();
            String uc = getFirstElementByTagName(envelope, "gml:upperCorner" )
                .getFirstChild().getNodeValue();
            double[] c = new double[]{
                Double.parseDouble(lc.split( " " )[0]), Double.parseDouble(lc.split( " " )[1]),
                Double.parseDouble(uc.split( " " )[0]), Double.parseDouble(uc.split( " " )[1])
            };
            double[] cr = new double[4];
            tx.transform(c, 0, cr, 0, 2);
           
            q += "&bbox=" + cr[0] + "," + cr[1] + "," + cr[2] + "," + cr[3] + "," + TARGET_CRS_CODE;
            dom = getAsDOM( q );
           
            assertEquals( 1, dom.getElementsByTagName( SystemTestData.POLYGONS.getPrefix() + ":" + SystemTestData.POLYGONS.getLocalPart()).getLength() );
        }
        finally {
            wfs.setFeatureBounding(oldFeatureBounding);
            getGeoServer().save( wfs );
        }
    }
View Full Code Here

        }
    }
   
    @Test
    public void testGetFeatureWithProjectedBoxPost() throws Exception {
        WFSInfo wfs = getWFS();
        boolean oldFeatureBounding = wfs.isFeatureBounding();
        wfs.setFeatureBounding(true);
        getGeoServer().save(wfs);
       
        try {
            String q = "wfs?request=getfeature&service=wfs&version=1.1&typeName=" +
                SystemTestData.POLYGONS.getLocalPart();
            Document dom = getAsDOM( q );
            Element envelope = getFirstElementByTagName(dom, "gml:Envelope" );
            String lc = getFirstElementByTagName(envelope, "gml:lowerCorner" )
                .getFirstChild().getNodeValue();
            String uc = getFirstElementByTagName(envelope, "gml:upperCorner" )
                .getFirstChild().getNodeValue();
            double[] c = new double[]{
                Double.parseDouble(lc.split( " " )[0]), Double.parseDouble(lc.split( " " )[1]),
                Double.parseDouble(uc.split( " " )[0]), Double.parseDouble(uc.split( " " )[1])
            };
            double[] cr = new double[4];
            tx.transform(c, 0, cr, 0, 2);
           
            String xml = "<wfs:GetFeature service=\"WFS\" version=\"1.1.0\""
                + " xmlns:" + SystemTestData.POLYGONS.getPrefix() + "=\"" + SystemTestData.POLYGONS.getNamespaceURI() + "\""
                + " xmlns:ogc=\"http://www.opengis.net/ogc\" "
                + " xmlns:gml=\"http://www.opengis.net/gml\" "
                + " xmlns:wfs=\"http://www.opengis.net/wfs\" " + "> "
                + "<wfs:Query typeName=\"" + SystemTestData.POLYGONS.getPrefix() + ":" + SystemTestData.POLYGONS.getLocalPart() + "\">"
                + "<wfs:PropertyName>cgf:polygonProperty</wfs:PropertyName> "
                + "<ogc:Filter>"
                "<ogc:BBOX>"
                +   "<ogc:PropertyName>polygonProperty</ogc:PropertyName>"
                +   "<gml:Envelope srsName=\"" + TARGET_CRS_CODE + "\">"
                +      "<gml:lowerCorner>" + cr[0] + " " + cr[1] + "</gml:lowerCorner>"
                +      "<gml:upperCorner>" + cr[2] + " " + cr[3] + "</gml:upperCorner>"
                +   "</gml:Envelope>" 
                "</ogc:BBOX>"
                + "</ogc:Filter>"
                + "</wfs:Query> " + "</wfs:GetFeature>";
           
            dom = postAsDOM( "wfs", xml );
           
            assertEquals( 1, dom.getElementsByTagName( SystemTestData.POLYGONS.getPrefix() + ":" + SystemTestData.POLYGONS.getLocalPart()).getLength() );
        }
        finally {
            wfs.setFeatureBounding(oldFeatureBounding);
            getGeoServer().save( wfs );
        }
    }
View Full Code Here

        assertEquals(2, xpath.getMatchingNodes("//wfs:FeatureType[wfs:Name='cgf:MPolygons']/wfs:MetadataURL[text() = 'http://www.geoserver.org']", doc).getLength());
    }
   
    @Test
    public void testOtherSRS() throws Exception {
        WFSInfo wfs = getGeoServer().getService(WFSInfo.class);
        wfs.getSRS().add("EPSG:4326"); // this one corresponds to the native one, should not be generated
        wfs.getSRS().add("EPSG:3857");
        wfs.getSRS().add("EPSG:3003");
        try {
            getGeoServer().save(wfs);
           
            // perform get caps
            Document doc = getAsDOM("wfs?service=WFS&version=1.1.0&request=getCapabilities");
           
            // for each enabled type, check we added the otherSRS
            final List<FeatureTypeInfo> enabledTypes = getCatalog().getFeatureTypes();
            for (Iterator<FeatureTypeInfo> it = enabledTypes.iterator(); it.hasNext();) {
                FeatureTypeInfo ft = it.next();
                if (ft.enabled()) {
                    String prefixedName = ft.prefixedName();
   
                    String base = "/wfs:WFS_Capabilities/wfs:FeatureTypeList/"
                            + "wfs:FeatureType[wfs:Name =\"" + prefixedName + "\"]";
                    XMLAssert.assertXpathExists(base, doc);
                    // we generate the other SRS only if it's not equal to native
                    boolean wgs84Native = "EPSG:4326".equals(ft.getSRS());
                    if(wgs84Native) {
                        XMLAssert.assertXpathEvaluatesTo("2", "count(" + base + "/wfs:OtherSRS)", doc);
                    } else {
                        XMLAssert.assertXpathEvaluatesTo("3", "count(" + base + "/wfs:OtherSRS)", doc);
                        XMLAssert.assertXpathExists(base + "[wfs:OtherSRS = 'urn:x-ogc:def:crs:EPSG:4326']", doc);
                    }
                    XMLAssert.assertXpathExists(base + "[wfs:OtherSRS = 'urn:x-ogc:def:crs:EPSG:3003']", doc);
                    XMLAssert.assertXpathExists(base + "[wfs:OtherSRS = 'urn:x-ogc:def:crs:EPSG:3857']", doc);
                }
            }
        } finally {
            wfs.getSRS().clear();
            getGeoServer().save(wfs);
        }
    }
View Full Code Here

        }
    }
   
    @Test
    public void testOtherSRSSingleTypeOverride() throws Exception {
        WFSInfo wfs = getGeoServer().getService(WFSInfo.class);
        wfs.getSRS().add("EPSG:4326"); // this one corresponds to the native one, should not be generated
        wfs.getSRS().add("EPSG:3857");
        wfs.getSRS().add("EPSG:3003");
        String polygonsName = getLayerId(MockData.POLYGONS);
        FeatureTypeInfo polygons = getCatalog().getFeatureTypeByName(polygonsName);
        polygons.getResponseSRS().add("EPSG:32632");
        polygons.setOverridingServiceSRS(true);
        try {
            getGeoServer().save(wfs);
            getCatalog().save(polygons);
           
            // check for this layer we have a different list
            Document doc = getAsDOM("wfs?service=WFS&version=1.1.0&request=getCapabilities");
            String base = "/wfs:WFS_Capabilities/wfs:FeatureTypeList/"
                    + "wfs:FeatureType[wfs:Name =\"" + polygonsName + "\"]";
            XMLAssert.assertXpathExists(base, doc);
            XMLAssert.assertXpathEvaluatesTo("1", "count(" + base + "/wfs:OtherSRS)", doc);
            XMLAssert.assertXpathExists(base + "[wfs:OtherSRS = 'urn:x-ogc:def:crs:EPSG:32632']", doc);
        } finally {
            wfs.getSRS().clear();
            getGeoServer().save(wfs);
            polygons.setOverridingServiceSRS(false);
            polygons.getResponseSRS().clear();
            getCatalog().save(polygons);
        }
View Full Code Here

       * or feature collections, a GeoJSON object may have a member named "bbox""
       * disable Feature bounding */
       
      GeoServer gs = getGeoServer();
       
        WFSInfo wfs = getWFS();
        boolean before = wfs.isFeatureBounding();
        wfs.setFeatureBounding(false);
        try {
            gs.save( wfs );
            
          String out = getAsString("wfs?request=GetFeature&version=1.0.0&typename=sf:AggregateGeoFeature&maxfeatures=3&outputformat="+JSONType.json);
          JSONObject rootObject = JSONObject.fromObject( out );
          
          JSONObject bbox = rootObject.getJSONObject("bbox");
          assertEquals(JSONNull.getInstance(), bbox);
        } finally {
          wfs.setFeatureBounding(before);
            gs.save( wfs );
        }
     
    }
View Full Code Here

        // make sure typeName _is_ in the default namespace
        Catalog catalog = getCatalog();
        NamespaceInfo defaultNs = catalog.getDefaultNamespace();
       
        GeoServer geoServer = getGeoServer();
        WFSInfo service = geoServer.getService(WFSInfo.class);
        try {
            // make sure typeName _is_ in the default namespace
            catalog.setDefaultNamespace(catalog.getNamespaceByURI(typeName.getNamespaceURI()));
            FeatureTypeInfo typeInfo = catalog.getFeatureTypeByName(typeName.getNamespaceURI(), typeName.getLocalPart());
            typeInfo.setEnabled(true);
            catalog.save(typeInfo);
            DataStoreInfo store = typeInfo.getStore();
            store.setEnabled(true);
            catalog.save(store);
           
            // and request typeName without prefix
            String path = "ows?service=WFS&version=2.0.0&request=DescribeFeatureType&typeName="
                + typeName.getLocalPart();
            Document doc;
       
            //first, non cite compliant mode should find the type even if namespace is not specified
            service.setCiteCompliant(false);
            geoServer.save(service);
            doc = getAsDOM(path);
            print(doc);
            assertSchema(doc, typeName);
           
   
            //then, in cite compliance more, it should not find the type name
            service.setCiteCompliant(true);
            geoServer.save(service);
            doc = getAsDOM(path);
            //print(doc);
            assertEquals("ows:ExceptionReport", doc.getDocumentElement().getNodeName());
        } finally {
            catalog.setDefaultNamespace(defaultNs);
            service.setCiteCompliant(false);
            geoServer.save(service);
        }
    }
View Full Code Here

TOP

Related Classes of org.geoserver.wfs.WFSInfo

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.