Search in sources :

Example 1 with LayerSchemaDTO

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

the class InjectGetFeatureModelEvent method dispatch.

@Override
protected void dispatch(WFSGetFeatureHandler handler) {
    final GPLayerBean layer = layerSchemaBinder.getSelectedLayer();
    final LayerSchemaDTO schema = layerSchemaBinder.getLayerSchemaDTO();
    handler.injectGetFeatureModel(new GetFeatureModel() {

        @Override
        public String getFeatureNameSpace() {
            return layer instanceof GPVectorBean ? ((GPVectorBean) layer).getFeatureNameSpace() : schema.getTargetNamespace();
        }

        @Override
        public String getFeatureType() {
            int pos = layer.getName().indexOf(":");
            return pos > 0 ? layer.getName().substring(pos + 1, layer.getName().length()) : layer.getName();
        }

        @Override
        public String getSrsName() {
            return layer.getCrs();
        }

        @Override
        public String getGeometryName() {
            return (layer instanceof GPVectorBean) ? ((GPVectorBean) layer).getGeometryName() : schema.getGeometry().getName();
        }

        @Override
        public WMS getWMSLayer() {
            return (WMS) wms;
        }
    });
}
Also used : GetFeatureModel(org.geosdi.geoplatform.gui.impl.map.control.feature.GetFeatureModel) GPVectorBean(org.geosdi.geoplatform.gui.model.GPVectorBean) LayerSchemaDTO(org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO) WMS(org.gwtopenmaps.openlayers.client.layer.WMS) GPLayerBean(org.geosdi.geoplatform.gui.model.GPLayerBean)

Example 2 with LayerSchemaDTO

use of org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO 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 3 with LayerSchemaDTO

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

the class FeatureReaderNetworkTest method readSFStreamsAllNet.

@Test
public void readSFStreamsAllNet() throws Exception {
    List<LayerSchemaDTO> schemas = featureReaderXSD.read(new URL(DESCRIBE_FEATURE_PATH.concat("sf:streams")).openStream());
    Assert.assertNotNull(schemas);
    Assert.assertEquals(1, schemas.size());
    LayerSchemaDTO layerSchema = schemas.get(0);
    logger.debug("######################HERE THE SCHEMA FOR : sf:streams : \n{}\n", layerSchema);
}
Also used : LayerSchemaDTO(org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO) URL(java.net.URL) Test(org.junit.Test)

Example 4 with LayerSchemaDTO

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

the class FeatureReaderNetworkTest method readStatesAllNet.

@Test
public void readStatesAllNet() throws Exception {
    List<LayerSchemaDTO> schemas = featureReaderXSD.read(new URL(DESCRIBE_FEATURE_PATH.concat("topp:states")).openStream());
    Assert.assertNotNull(schemas);
    Assert.assertEquals(1, schemas.size());
    LayerSchemaDTO layerSchema = schemas.get(0);
    logger.debug("######################HERE THE SCHEMA FOR : topp:states : \n{}\n", layerSchema);
}
Also used : LayerSchemaDTO(org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO) URL(java.net.URL) Test(org.junit.Test)

Example 5 with LayerSchemaDTO

use of org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO 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)

Aggregations

LayerSchemaDTO (org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO)44 Test (org.junit.Test)28 URL (java.net.URL)19 QName (javax.xml.namespace.QName)17 Schema (org.geosdi.geoplatform.xml.xsd.v2001.Schema)14 FeatureCollectionDTO (org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO)13 GPWFSConnectorStore (org.geosdi.geoplatform.connector.GPWFSConnectorStore)10 WFSGetFeatureRequest (org.geosdi.geoplatform.connector.server.request.WFSGetFeatureRequest)10 WFSGetFeatureStaxReader (org.geosdi.geoplatform.support.wfs.feature.reader.WFSGetFeatureStaxReader)10 File (java.io.File)8 JAXBElement (javax.xml.bind.JAXBElement)8 AttributeDTO (org.geosdi.geoplatform.connector.wfs.response.AttributeDTO)7 Ignore (org.junit.Ignore)7 BBox (org.geosdi.geoplatform.gui.shared.bean.BBox)5 StringWriter (java.io.StringWriter)4 BeforeClass (org.junit.BeforeClass)4 FeatureCollection (org.geojson.FeatureCollection)3 ArrayList (java.util.ArrayList)2 BasicPreemptiveSecurityConnector (org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector)2 FeatureDTO (org.geosdi.geoplatform.connector.wfs.response.FeatureDTO)2