Search in sources :

Example 1 with GeoObjectAtTimeShapefileExporter

use of net.geoprism.registry.shapefile.GeoObjectAtTimeShapefileExporter in project geoprism-registry by terraframe.

the class GeoObjectAtTimeShapefileExporterTest method testCreateFeatureType.

@Test
@Request
public void testCreateFeatureType() {
    ServerGeoObjectType type = ServerGeoObjectType.get(FastTestDataset.PROVINCE.getCode());
    GeoObjectAtTimeShapefileExporter exporter = new GeoObjectAtTimeShapefileExporter(type, FastTestDataset.DEFAULT_OVER_TIME_DATE);
    SimpleFeatureType featureType = exporter.createFeatureType();
    Assert.assertNotNull(featureType);
    Assert.assertEquals(GeoObjectAtTimeShapefileExporter.GEOM, featureType.getGeometryDescriptor().getLocalName());
    List<AttributeDescriptor> attributes = featureType.getAttributeDescriptors();
    Assert.assertEquals(3, attributes.size());
}
Also used : SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) AttributeDescriptor(org.opengis.feature.type.AttributeDescriptor) GeoObjectAtTimeShapefileExporter(net.geoprism.registry.shapefile.GeoObjectAtTimeShapefileExporter) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 2 with GeoObjectAtTimeShapefileExporter

use of net.geoprism.registry.shapefile.GeoObjectAtTimeShapefileExporter in project geoprism-registry by terraframe.

the class GeoObjectAtTimeShapefileExporterTest method testCreateFeatures.

@Test
@Request
public void testCreateFeatures() {
    ServerGeoObjectType type = FastTestDataset.PROVINCE.getServerObject();
    GeoObjectAtTimeShapefileExporter exporter = new GeoObjectAtTimeShapefileExporter(type, FastTestDataset.DEFAULT_OVER_TIME_DATE);
    SimpleFeatureType featureType = exporter.createFeatureType();
    FeatureCollection<SimpleFeatureType, SimpleFeature> features = exporter.features(featureType);
    Assert.assertTrue(features.size() > 0);
    final FeatureIterator<SimpleFeature> it = features.features();
    boolean hasCentralProvince = false;
    while (it.hasNext()) {
        SimpleFeature feature = it.next();
        if (feature.getID().equals(FastTestDataset.PROV_CENTRAL.getCode())) {
            hasCentralProvince = true;
            final ServerGeoObjectIF object = FastTestDataset.PROV_CENTRAL.getServerObject();
            Object geometry = feature.getDefaultGeometry();
            Assert.assertNotNull(geometry);
            Collection<AttributeType> attributes = new ImportAttributeSerializer(Session.getCurrentLocale(), false, false, LocalizationFacade.getInstalledLocales()).attributes(type.getType());
            for (AttributeType attribute : attributes) {
                String attributeName = attribute.getName();
                Object oValue = object.getValue(attributeName);
                Object fValue = feature.getAttribute(exporter.getColumnName(attributeName));
                if (attribute instanceof AttributeTermType) {
                    Assert.assertEquals("Attributes not equal [" + attributeName + "]", GeoObjectUtil.convertToTermString((AttributeTermType) attribute, oValue), fValue);
                } else if (attribute instanceof AttributeLocalType) {
                    Assert.assertEquals("Attributes not equal [" + attributeName + "]", ((LocalizedValue) oValue).getValue(), fValue);
                } else {
                    Assert.assertEquals("Attributes not equal [" + attributeName + "]", oValue, fValue);
                }
            }
        }
    }
    Assert.assertTrue("Unable to find the central province feature", hasCentralProvince);
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectAtTimeShapefileExporter(net.geoprism.registry.shapefile.GeoObjectAtTimeShapefileExporter) SimpleFeature(org.opengis.feature.simple.SimpleFeature) AttributeLocalType(org.commongeoregistry.adapter.metadata.AttributeLocalType) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 3 with GeoObjectAtTimeShapefileExporter

use of net.geoprism.registry.shapefile.GeoObjectAtTimeShapefileExporter in project geoprism-registry by terraframe.

the class GeoObjectAtTimeShapefileExporterTest method testExport.

@Test
@Request
public void testExport() throws IOException {
    ServerGeoObjectType type = FastTestDataset.PROVINCE.getServerObject();
    GeoObjectAtTimeShapefileExporter exporter = new GeoObjectAtTimeShapefileExporter(type, FastTestDataset.DEFAULT_OVER_TIME_DATE);
    InputStream export = exporter.export();
    Assert.assertNotNull(export);
    IOUtils.copy(export, NullOutputStream.NULL_OUTPUT_STREAM);
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) InputStream(java.io.InputStream) GeoObjectAtTimeShapefileExporter(net.geoprism.registry.shapefile.GeoObjectAtTimeShapefileExporter) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 4 with GeoObjectAtTimeShapefileExporter

use of net.geoprism.registry.shapefile.GeoObjectAtTimeShapefileExporter in project geoprism-registry by terraframe.

the class GeoObjectAtTimeShapefileExporterTest method testGenerateName.

@Test
@Request
public void testGenerateName() {
    ServerGeoObjectType type = ServerGeoObjectType.get(FastTestDataset.PROVINCE.getCode());
    GeoObjectAtTimeShapefileExporter exporter = new GeoObjectAtTimeShapefileExporter(type, FastTestDataset.DEFAULT_OVER_TIME_DATE);
    Assert.assertEquals("testestest", exporter.generateColumnName("testestestest1"));
    Assert.assertEquals("testestes1", exporter.generateColumnName("testestestest2"));
    Assert.assertEquals("testestes2", exporter.generateColumnName("testestestest3"));
    Assert.assertEquals("testestes3", exporter.generateColumnName("testestestest4"));
    Assert.assertEquals("testestes4", exporter.generateColumnName("testestestest5"));
    Assert.assertEquals("testestes5", exporter.generateColumnName("testestestest6"));
    Assert.assertEquals("testestes6", exporter.generateColumnName("testestestest7"));
    Assert.assertEquals("testestes7", exporter.generateColumnName("testestestest8"));
    Assert.assertEquals("testestes8", exporter.generateColumnName("testestestest9"));
    Assert.assertEquals("testestes9", exporter.generateColumnName("testestestest10"));
    Assert.assertEquals("testeste10", exporter.generateColumnName("testestestest11"));
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectAtTimeShapefileExporter(net.geoprism.registry.shapefile.GeoObjectAtTimeShapefileExporter) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 5 with GeoObjectAtTimeShapefileExporter

use of net.geoprism.registry.shapefile.GeoObjectAtTimeShapefileExporter in project geoprism-registry by terraframe.

the class GeoObjectAtTimeShapefileExporterTest method testWriteToFile.

@Test
@Request
public void testWriteToFile() throws IOException {
    ServerGeoObjectType type = FastTestDataset.PROVINCE.getServerObject();
    GeoObjectAtTimeShapefileExporter exporter = new GeoObjectAtTimeShapefileExporter(type, FastTestDataset.DEFAULT_OVER_TIME_DATE);
    File directory = exporter.writeToFile();
    Assert.assertTrue(directory.exists());
    File[] files = directory.listFiles();
    Assert.assertEquals(5, files.length);
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) File(java.io.File) GeoObjectAtTimeShapefileExporter(net.geoprism.registry.shapefile.GeoObjectAtTimeShapefileExporter) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Aggregations

Request (com.runwaysdk.session.Request)5 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)5 GeoObjectAtTimeShapefileExporter (net.geoprism.registry.shapefile.GeoObjectAtTimeShapefileExporter)5 Test (org.junit.Test)5 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)2 File (java.io.File)1 InputStream (java.io.InputStream)1 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)1 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)1 AttributeLocalType (org.commongeoregistry.adapter.metadata.AttributeLocalType)1 AttributeTermType (org.commongeoregistry.adapter.metadata.AttributeTermType)1 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)1 SimpleFeature (org.opengis.feature.simple.SimpleFeature)1 AttributeDescriptor (org.opengis.feature.type.AttributeDescriptor)1