Package org.geotools.data.wfs.v1_1_0

Examples of org.geotools.data.wfs.v1_1_0.AbstractGetFeatureParserTest


    @Test
    public void testDetermineWFS1_1_0_Strategy() throws IOException {
        URL url;
        InputStream in;
        Document capabilitiesDoc;
        WFSStrategy strategy;

        url = TestData.url(this, "geoserver_capabilities_1_1_0.xml");
        in = url.openStream();
        capabilitiesDoc = WFSDataStoreFactory.parseCapabilities(in);
        strategy = WFSDataStoreFactory.determineCorrectStrategy(url, capabilitiesDoc,null);
        assertNotNull(strategy);
        assertEquals(GeoServerStrategy.class, strategy.getClass());

        // try override
        url = TestData.url(this, "geoserver_capabilities_1_1_0.xml");
        in = url.openStream();
        capabilitiesDoc = WFSDataStoreFactory.parseCapabilities(in);
        strategy = WFSDataStoreFactory.determineCorrectStrategy(url, capabilitiesDoc,"cubewerx");
        assertNotNull(strategy);
        assertEquals(CubeWerxStrategy.class, strategy.getClass());
       
        url = TestData.url(this, "cubewerx_capabilities_1_1_0.xml");
        in = url.openStream();
        capabilitiesDoc = WFSDataStoreFactory.parseCapabilities(in);
        strategy = WFSDataStoreFactory.determineCorrectStrategy(url, capabilitiesDoc,null);
        assertNotNull(strategy);
        assertEquals(CubeWerxStrategy.class, strategy.getClass());

        url = TestData.url(this, "ionic_capabilities_1_1_0.xml");
        in = url.openStream();
        capabilitiesDoc = WFSDataStoreFactory.parseCapabilities(in);
        strategy = WFSDataStoreFactory.determineCorrectStrategy(url, capabilitiesDoc,null);
        assertNotNull(strategy);
        assertEquals(IonicStrategy.class, strategy.getClass());
    }
View Full Code Here


                throw new IOException(e.toString());
            }
        } else {
            InputStream capsIn = new ByteArrayInputStream(wfsCapabilitiesRawData);

            WFSStrategy strategy = determineCorrectStrategy(getCapabilitiesRequest, capsDoc, wfsStrategy );
           
            WFS_1_1_0_Protocol wfs = new WFS_1_1_0_Protocol(capsIn, http, defaultEncoding, strategy);

            dataStore = new WFS_1_1_0_DataStore(wfs);
            dataStore.setMaxFeatures(maxFeatures);
            dataStore.setPreferPostOverGet(protocol);
            dataStore.setUseDefaultSRS(useDefaultSRS);
            ((WFS_1_1_0_DataStore) dataStore).setAxisOrder(axisOrder,
                    axisOrderFilter);
            ((WFS_1_1_0_DataStore) dataStore).setGetFeatureOutputFormat(outputFormat);
            ((WFS_1_1_0_DataStore) dataStore).setMappedURIs(strategy
                    .getNamespaceURIMappings());
        }
        dataStore.setNamespaceOverride(namespaceOverride);
       
View Full Code Here

     * @param capabilitiesDoc
     * @param override optional override provided by user
     * @return WFSStrategy to use
     */
    static WFSStrategy determineCorrectStrategy(URL getCapabilitiesRequest, Document capabilitiesDoc, String override) {
        WFSStrategy strategy = null;
        // override
        if( override != null ){
            if( override.equalsIgnoreCase("geoserver")){
                strategy = new GeoServerStrategy();
            }
            else if( override.equalsIgnoreCase("mapserver")){
                strategy = new MapServerStrategy();
            }
            else if( override.equalsIgnoreCase("arcgis")){
                strategy = new ArcGISServerStrategy();
            }
            else if( override.equalsIgnoreCase("cubewerx")){
                strategy = new CubeWerxStrategy();
            }
            else if( override.equalsIgnoreCase("ionic")){
                strategy = new IonicStrategy();
            }
            else {
                logger.warning("Could not handle wfs strategy override "+override+" proceeding with autodetection");
            }
        }
        // auto detection
        if( strategy == null ){
            // look in comments for indication of CubeWerx server       
            NodeList childNodes = capabilitiesDoc.getChildNodes();
            for (int i = 0; i < childNodes.getLength(); i++) {
                Node child = childNodes.item(i);
                if (child.getNodeType() == Node.COMMENT_NODE) {
                    String nodeValue = child.getNodeValue();
                    nodeValue = nodeValue.toLowerCase();
                    if (nodeValue.contains("cubewerx")) {
                        strategy = new CubeWerxStrategy();
                        break;
                    }
                }
            }
        }

        if (strategy == null) {
            // Ionic declares its own namespace so that's our hook
            Element root = capabilitiesDoc.getDocumentElement();
            String ionicNs = root.getAttribute("xmlns:ionic");
            if (ionicNs != null) {
                if (ionicNs.equals("http://www.ionicsoft.com/versions/4")) {
                    strategy = new IonicStrategy();
                } else if (ionicNs.startsWith("http://www.ionicsoft.com/versions")) {
                    logger
                            .warning("Found a Ionic server but the version may not match the strategy "
                                    + "we have (v.4). Ionic namespace url: " + ionicNs);
                    strategy = new IonicStrategy();
                }
            }
        }

        if (strategy == null) {
            // guess server implementation from capabilities URI
            String uri = getCapabilitiesRequest.toExternalForm();
            if (uri.contains("geoserver")) {
                strategy = new GeoServerStrategy();
            }else if (uri.contains("/ArcGIS/services/")){
                strategy = new ArcGISServerStrategy();
            }
        }

        if (strategy == null) {
            // use fallback strategy
            strategy = new DefaultWFSStrategy();
        }
        logger.info("Using WFS Strategy: " + strategy.getClass().getName());
        return strategy;
    }
View Full Code Here

            throw new UnsupportedOperationException(
                    "The server does not support GetFeature for HTTP method GET");
        }
        URL url = getOperationURL(WFSOperationType.GET_FEATURE, false);

        RequestComponents reqParts = strategy.createGetFeatureRequest(this, request);
        GetFeatureType requestType = reqParts.getServerRequest();
       
        // build the kvp taking into account eventual vendor params
        Map<String, String> getFeatureKvp = reqParts.getKvpParameters();
        if(request instanceof GetFeatureQueryAdapter) {
            GetFeatureQueryAdapter adapter = (GetFeatureQueryAdapter) request;
            if(adapter.getVendorParameter() != null) {
                getFeatureKvp.putAll(adapter.getVendorParameter());
            }
View Full Code Here

               
                postURL = new URL(url);
            }
        }

        RequestComponents reqParts = strategy.createGetFeatureRequest(this, request);
        GetFeatureType serverRequest = reqParts.getServerRequest();

        Encoder encoder = new Encoder(strategy.getWfsConfiguration());

        // If the typeName is of the form prefix:typeName we better declare the namespace since we
        // don't know how picky the server parser will be
        String typeName = reqParts.getKvpParameters().get("TYPENAME");
        QName fullName = getFeatureTypeName(typeName);
        String prefix = fullName.getPrefix();
        String namespace = fullName.getNamespaceURI();
        if (!XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
            encoder.getNamespaces().declarePrefix(prefix, namespace);
View Full Code Here

    @Test
    public void testCreateGetFeatureRequest() throws IOException {
        GetFeature query = new GetFeatureQueryAdapter(new Query(
                CUBEWERX_GOVUNITCE.FEATURETYPENAME), "GML2", "EPSG:4326", ResultType.RESULTS);
        RequestComponents getFeatureRequest = strategy.createGetFeatureRequest(wfs, query);
        GetFeatureType serverRequest = getFeatureRequest.getServerRequest();
        ResultTypeType resultType = serverRequest.getResultType();
        assertNull(resultType);
        Map<String, String> kvpParameters = getFeatureRequest.getKvpParameters();
        assertNull(kvpParameters.get("RESULTTYPE"));
    }
View Full Code Here

            WFSStrategy strategy = determineCorrectStrategy(getCapabilitiesRequest, capsDoc, wfsStrategy );
           
            WFS_1_1_0_Protocol wfs = new WFS_1_1_0_Protocol(capsIn, http, defaultEncoding, strategy);

            dataStore = new WFS_1_1_0_DataStore(wfs);
            dataStore.setMaxFeatures(maxFeatures);
            dataStore.setPreferPostOverGet(protocol);
            dataStore.setUseDefaultSRS(useDefaultSRS);
            ((WFS_1_1_0_DataStore) dataStore).setAxisOrder(axisOrder,
                    axisOrderFilter);
View Full Code Here

        } else {
            InputStream capsIn = new ByteArrayInputStream(wfsCapabilitiesRawData);

            WFSStrategy strategy = determineCorrectStrategy(getCapabilitiesRequest, capsDoc, wfsStrategy );
           
            WFS_1_1_0_Protocol wfs = new WFS_1_1_0_Protocol(capsIn, http, defaultEncoding, strategy);

            dataStore = new WFS_1_1_0_DataStore(wfs);
            dataStore.setMaxFeatures(maxFeatures);
            dataStore.setPreferPostOverGet(protocol);
            dataStore.setUseDefaultSRS(useDefaultSRS);
View Full Code Here

    @Override
    protected GetFeatureParser getParser(final QName featureName, final String schemaLocation,
            final SimpleFeatureType featureType, final URL getFeaturesRequest) throws IOException {

        InputStream inputStream = new BufferedInputStream(getFeaturesRequest.openStream());
        GetFeatureParser parser = new XmlSimpleFeatureParser(inputStream,
                featureType, featureName, WFSDataStore.AXIS_ORDER_COMPLIANT,
                new HashMap<String, String>());
        return parser;
    }
View Full Code Here

TOP

Related Classes of org.geotools.data.wfs.v1_1_0.AbstractGetFeatureParserTest

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.