Search in sources :

Example 1 with FeatureCollectionDTO

use of org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO in project geo-platform by geosdi.

the class FeatureReaderTest method testFeature.

@Test
public void testFeature() throws Exception {
    FileInputStream ff = null;
    try {
        File dftFile = new File(fileDFT);
        ff = new FileInputStream(dftFile);
        List<LayerSchemaDTO> schemas = featureReaderXSD.read(ff);
        Assert.assertNotNull(schemas);
        Assert.assertEquals(1, schemas.size());
        LayerSchemaDTO layerSchema = schemas.get(0);
        Assert.assertNotNull(layerSchema.getTypeName());
        String name = layerSchema.getTypeName().substring(layerSchema.getTypeName().indexOf(":") + 1);
        Assert.assertNotNull(layerSchema.getTargetNamespace());
        Assert.assertNotNull(layerSchema.getGeometry());
        List<AttributeDTO> attributes = layerSchema.getAttributes();
        Assert.assertNotNull(attributes);
        Assert.assertEquals(numAttributes, attributes.size());
        for (AttributeDTO att : attributes) {
            Assert.assertTrue(att.getMinOccurs() >= 0);
            Assert.assertTrue(att.getMaxOccurs() > att.getMinOccurs());
            Assert.assertNotNull(att.getName());
            Assert.assertNotNull(att.getType());
        }
        logger.debug("@@@@@@@@@@@@@@@@@@@@LAYER_SCHEMA : {}", layerSchema);
        WFSGetFeatureStaxReader featureReader = new WFSGetFeatureStaxReader(layerSchema);
        FeatureCollectionDTO fc = featureReader.read(new File(fileGF));
        Assert.assertNotNull(fc);
        Assert.assertNotNull(fc.getTimeStamp());
        Assert.assertEquals(numFeatures, fc.getNumberOfFeatures());
        List<FeatureDTO> features = fc.getFeatures();
        Assert.assertNotNull(features);
        Assert.assertEquals(numFeatures, features.size());
        for (FeatureDTO feature : features) {
            Assert.assertNotNull(feature.getFID());
            Assert.assertTrue(feature.getFID().contains(name));
            Assert.assertNotNull(feature.getGeometry());
            if (numAttributes == 0) {
                Assert.assertTrue(feature.getAttributes().getAttributesMap().isEmpty());
            } else {
                Assert.assertNotNull(feature.getAttributes());
                Map<String, String> fMap = feature.getAttributes().getAttributesMap();
                Assert.assertNotNull(fMap);
                logger.debug("#################FMAP_SIZE : {}\n", fMap.size());
                Assert.assertEquals(numAttributes, fMap.size());
            }
            logger.debug("@@@@@@@@@@@@@@@@@@@@ {} - {}", feature.getFID(), feature.getAttributes());
            logger.debug("GEOMETRY @@@@@@@@@@@@@@@@ : {}", feature.getGeometry());
        }
    } finally {
        if (ff != null) {
            ff.close();
        }
    }
}
Also used : AttributeDTO(org.geosdi.geoplatform.connector.wfs.response.AttributeDTO) WFSGetFeatureStaxReader(org.geosdi.geoplatform.support.wfs.feature.reader.WFSGetFeatureStaxReader) LayerSchemaDTO(org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO) FeatureDTO(org.geosdi.geoplatform.connector.wfs.response.FeatureDTO) File(java.io.File) FileInputStream(java.io.FileInputStream) FeatureCollectionDTO(org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO) Test(org.junit.Test)

Example 2 with FeatureCollectionDTO

use of org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO in project geo-platform by geosdi.

the class WFSGetFeatureWSTest method statesAllFeaturesV110.

@Test
public void statesAllFeaturesV110() throws Exception {
    String typeName = TOPP_STATES.getLocalPart();
    FeatureCollectionDTO fc = wfsService.getAllFeatureDirect(addressDatastore, typeName, 10, EMPTY_MAP);
    this.checkFeatureCollection(fc, typeName, 22, 10);
}
Also used : FeatureCollectionDTO(org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO) Test(org.junit.Test)

Example 3 with FeatureCollectionDTO

use of org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO in project geo-platform by geosdi.

the class WFSGetFeatureWSTest method statesFeatureV110.

@Test
public void statesFeatureV110() throws Exception {
    String typeName = TOPP_STATES.getLocalPart();
    BBox bBox = new BBox(-75.102613, 40.212597, -72.361859, 41.512517);
    FeatureCollectionDTO fc = wfsService.getFeatureByBBoxDirect(addressDatastore, typeName, bBox, EMPTY_MAP);
    this.checkFeatureCollection(fc, typeName, 22, 4);
}
Also used : BBox(org.geosdi.geoplatform.gui.shared.bean.BBox) FeatureCollectionDTO(org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO) Test(org.junit.Test)

Example 4 with FeatureCollectionDTO

use of org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO in project geo-platform by geosdi.

the class WFSGetFeatureWSTest method statesFeatureLayerV110.

@Test
public void statesFeatureLayerV110() throws Exception {
    String typeName = TOPP_STATES.getLocalPart();
    LayerSchemaDTO layerSchema = wfsService.describeFeatureType(addressDatastore, typeName, EMPTY_MAP);
    logger.debug("\n\n\n@@@ {}", layerSchema);
    BBox bBox = new BBox(-75.102613, 40.212597, -72.361859, 41.512517);
    FeatureCollectionDTO fc = wfsService.getFeatureByBBox(layerSchema, bBox, EMPTY_MAP);
    this.checkFeatureCollection(fc, typeName, 22, 4);
}
Also used : BBox(org.geosdi.geoplatform.gui.shared.bean.BBox) LayerSchemaDTO(org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO) FeatureCollectionDTO(org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO) Test(org.junit.Test)

Example 5 with FeatureCollectionDTO

use of org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO in project geo-platform by geosdi.

the class WFSTransactionUpdateWSTest method multiUpdate.

@Test
public void multiUpdate() throws Exception {
    String typeName = TOPP_STATES.getLocalPart();
    LayerSchemaDTO describeFeatureType = wfsService.describeFeatureType(addressDatastore, typeName, EMPTY_MAP);
    AttributeDTO att1 = null, att2 = null;
    for (AttributeDTO attribute : describeFeatureType.getAttributes()) {
        if ("LAND_KM".equals(attribute.getName())) {
            att1 = attribute;
        } else if ("WATER_KM".equals(attribute.getName())) {
            att2 = attribute;
        }
    }
    assertNotNull(att1);
    assertNotNull(att2);
    BBox bbox = new BBox(-75.102613, 40.212597, -75.361859, 40.512517);
    FeatureCollectionDTO featureCollection = wfsService.getFeatureByBBoxDirect(addressDatastore, typeName, bbox, EMPTY_MAP);
    assertEquals(1, featureCollection.getNumberOfFeatures());
    assertNotNull(featureCollection.getFeatures());
    FeatureDTO feature = featureCollection.getFeatures().get(0);
    assertNotNull(feature);
    assertNotNull(feature.getFID());
    Map<String, String> attributesMap = feature.getAttributes().getAttributesMap();
    String val1 = attributesMap.get(att1.getName());
    double d1 = Double.valueOf(val1) + 0.001;
    att1.setValue(Double.toString(d1));
    String val2 = attributesMap.get(att2.getName());
    double d2 = Double.valueOf(val2) + 0.001;
    att2.setValue(Double.toString(d2));
    logger.info("\n\n*** val1: from {} to {}\n*** val2: from {} to {}\n\n", val1, att1.getValue(), val2, att2.getValue());
    boolean updated = wfsService.transactionUpdate(addressDatastore, typeName, feature.getFID(), Arrays.asList(att1, att2), EMPTY_MAP);
    Assert.assertTrue(updated);
    feature = wfsService.getFeatureByFIDDirect(addressDatastore, typeName, feature.getFID(), EMPTY_MAP);
    assertNotNull(feature);
    assertNotNull(feature.getFID());
    attributesMap = feature.getAttributes().getAttributesMap();
    val1 = attributesMap.get(att1.getName());
    assertEquals(Double.toString(d1), val1);
    val2 = attributesMap.get(att2.getName());
    assertEquals(Double.toString(d2), val2);
}
Also used : AttributeDTO(org.geosdi.geoplatform.connector.wfs.response.AttributeDTO) BBox(org.geosdi.geoplatform.gui.shared.bean.BBox) LayerSchemaDTO(org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO) FeatureDTO(org.geosdi.geoplatform.connector.wfs.response.FeatureDTO) FeatureCollectionDTO(org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO) Test(org.junit.Test)

Aggregations

FeatureCollectionDTO (org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO)26 Test (org.junit.Test)18 WFSGetFeatureStaxReader (org.geosdi.geoplatform.support.wfs.feature.reader.WFSGetFeatureStaxReader)17 LayerSchemaDTO (org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO)13 WFSGetFeatureRequest (org.geosdi.geoplatform.connector.server.request.WFSGetFeatureRequest)10 URL (java.net.URL)9 QName (javax.xml.namespace.QName)9 FeatureDTO (org.geosdi.geoplatform.connector.wfs.response.FeatureDTO)9 GPWFSConnectorStore (org.geosdi.geoplatform.connector.GPWFSConnectorStore)8 Schema (org.geosdi.geoplatform.xml.xsd.v2001.Schema)8 BBox (org.geosdi.geoplatform.gui.shared.bean.BBox)6 Ignore (org.junit.Ignore)4 JAXBElement (javax.xml.bind.JAXBElement)3 FeatureCollection (org.geojson.FeatureCollection)3 AttributeDTO (org.geosdi.geoplatform.connector.wfs.response.AttributeDTO)3 HashMap (java.util.HashMap)2 BasicPreemptiveSecurityConnector (org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector)2 GetAllFeatureResponse (org.geosdi.geoplatform.gui.client.command.wfst.basic.GetAllFeatureResponse)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1