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();
}
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations