// @Ignore(value = "FIX PROBLEM TO RETRIEVE ATTRIBUTES WITHOUT GEOMETRY") @Test public void statesTest() throws Exception { String wfsURL = "http://150.145.141.92/geoserver/wfs"; GPWFSConnectorStore serverConnector = WFSConnectorBuilder.newConnector().withServerUrl(new URL(wfsURL)).build(); WFSDescribeFeatureTypeRequest<Schema> request = serverConnector.createDescribeFeatureTypeRequest(); request.setTypeName(Arrays.asList(states)); Schema response = request.getResponse(); LayerSchemaDTO layerSchema = featureReaderXSD.getFeature(response, statesName); if (layerSchema == null) { throw new IllegalStateException("The Layer Schema is null."); } layerSchema.setScope(wfsURL); logger.debug("\n\t##################################LAYER_SCHEMA : {}", layerSchema); WFSGetFeatureRequest getFeatureRequest = serverConnector.createGetFeatureRequest(); getFeatureRequest.setTypeName(new QName(layerSchema.getTypeName())); getFeatureRequest.setPropertyNames(Arrays.asList(new String[] {"STATE_NAME", "PERSONS"})); getFeatureRequest.setBBox(new BBox(-75.102613, 40.212597, -72.361859, 41.512517)); getFeatureRequest.setSRS("EPSG:4326"); getFeatureRequest.setResultType(ResultTypeType.RESULTS.value()); getFeatureRequest.setMaxFeatures(BigInteger.valueOf(50)); logger.debug( "\n\t@@@@@@@@@@@@@@@@@@RESPONSE_AS_STRING : {}", getFeatureRequest.getResponseAsString()); InputStream is = getFeatureRequest.getResponseAsStream(); final WFSGetFeatureStaxReader featureReaderStAX = new WFSGetFeatureStaxReader(layerSchema); FeatureCollectionDTO featureCollection = featureReaderStAX.read(is); if (!featureCollection.isFeaturesLoaded()) { featureCollection.setErrorMessage(getFeatureRequest.getResponseAsString()); } logger.debug("\n\t@@@@@@@@@@@@@@@@@@@@@@@@@@@FEATURE_COLLECTION_DTO : {}", featureCollection); }
@Test public void getAllFeaturesTest() throws Exception { String wfsURL = "http://geoserver.wfppal.org/geoserver/wfs"; GPWFSConnectorStore serverConnector = WFSConnectorBuilder.newConnector().withServerUrl(new URL(wfsURL)).build(); WFSDescribeFeatureTypeRequest<Schema> request = serverConnector.createDescribeFeatureTypeRequest(); request.setTypeName(Arrays.asList(information)); Schema response = request.getResponse(); LayerSchemaDTO layerSchema = featureReaderXSD.getFeature(response, informationName); if (layerSchema == null) { throw new IllegalStateException("The Layer Schema is null."); } layerSchema.setScope(wfsURL); logger.debug("\n\t##################################LAYER_SCHEMA : {}", layerSchema); WFSGetFeatureRequest getFeatureRequest = serverConnector.createGetFeatureRequest(); getFeatureRequest.setTypeName(new QName(layerSchema.getTypeName())); getFeatureRequest.setSRS("EPSG:4326"); getFeatureRequest.setResultType(ResultTypeType.RESULTS.value()); getFeatureRequest.setMaxFeatures(BigInteger.valueOf(50)); logger.debug( "\n\t@@@@@@@@@@@@@@@@@@RESPONSE_AS_STRING : {}", getFeatureRequest.getResponseAsString()); InputStream is = getFeatureRequest.getResponseAsStream(); final WFSGetFeatureStaxReader featureReaderStAX = new WFSGetFeatureStaxReader(layerSchema); FeatureCollectionDTO featureCollection = featureReaderStAX.read(is); if (!featureCollection.isFeaturesLoaded()) { featureCollection.setErrorMessage(getFeatureRequest.getResponseAsString()); } logger.debug("\n\t@@@@@@@@@@@@@@@@@@@@@@@@@@@FEATURE_COLLECTION_DTO : {}", featureCollection); }