@@ -5,7 +5,6 @@ import groovy.transform.CompileStatic
5
5
import groovy.util.logging.Slf4j
6
6
import org.apache.commons.io.FileUtils
7
7
import org.apache.commons.io.IOUtils
8
- import org.apache.commons.io.filefilter.IOFileFilter
9
8
import org.apache.commons.lang3.tuple.Pair
10
9
import org.geotools.data.DefaultTransaction
11
10
import org.geotools.data.FileDataStore
@@ -26,7 +25,11 @@ import org.geotools.referencing.CRS
26
25
import org.geotools.referencing.crs.DefaultGeographicCRS
27
26
import org.locationtech.jts.geom.Geometry
28
27
import org.locationtech.jts.geom.GeometryCollection
28
+ import org.locationtech.jts.geom.LineString
29
+ import org.locationtech.jts.geom.MultiLineString
30
+ import org.locationtech.jts.geom.MultiPoint
29
31
import org.locationtech.jts.geom.MultiPolygon
32
+ import org.locationtech.jts.geom.Point
30
33
import org.locationtech.jts.geom.Polygon
31
34
import org.locationtech.jts.io.ParseException
32
35
import org.locationtech.jts.io.WKTReader
@@ -49,13 +52,6 @@ import java.util.zip.ZipOutputStream
49
52
@CompileStatic
50
53
class SpatialConversionUtils {
51
54
52
- public final static String WKT_MAP_KEY = " WKT_MAP_KEY_****"
53
- // works as long as this is not uploaded as a field in the shapefile
54
- /**
55
- * log4j logger
56
- */
57
- // private static final Logger logger = log.getLogger(SpatialConversionUtils.class);
58
-
59
55
static List<String > getGeometryCollectionParts (String wkt ) {
60
56
if (wkt. matches(" GEOMETRYCOLLECTION\\ (.+\\ )" )) {
61
57
String parts = wkt. substring(19 , wkt. length() - 1 )
@@ -207,7 +203,10 @@ class SpatialConversionUtils {
207
203
manifestData. add(pairList)
208
204
}
209
205
210
- // it.close();
206
+ try {
207
+ store. dispose()
208
+ } catch (Exception ignored) {
209
+ }
211
210
212
211
return manifestData
213
212
}
@@ -242,8 +241,7 @@ class SpatialConversionUtils {
242
241
SimpleFeatureCollection featureCollection = featureSource. getFeatures()
243
242
it = featureCollection. features()
244
243
245
- // transform CRS to the same as the shapefile (at least try)
246
- // default to 4326
244
+ // transform CRS to the same as the shapefile (at least try) default to 4326
247
245
CoordinateReferenceSystem crs = null
248
246
try {
249
247
crs = store. getSchema(). getCoordinateReferenceSystem()
@@ -448,26 +446,30 @@ class SpatialConversionUtils {
448
446
}
449
447
}
450
448
451
- private static SimpleFeatureType createFeatureType (String type ) {
449
+ static SimpleFeatureType createFeatureType (String type ) {
452
450
453
451
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder ()
454
452
builder. setName(" ActiveArea" )
455
- builder. setCRS(DefaultGeographicCRS . WGS84 ) // <- Coordinate reference
456
- // system
453
+ builder. setCRS(DefaultGeographicCRS . WGS84 ) // <- Coordinate reference system
457
454
458
455
// add attributes in order
459
456
if (" GEOMETRYCOLLECTION" . equalsIgnoreCase(type)) {
460
457
builder. add(" the_geom" , MultiPolygon . class)
461
458
} else if (" MULTIPOLYGON" . equalsIgnoreCase(type)) {
462
459
builder. add(" the_geom" , MultiPolygon . class)
460
+ } else if (" LINESTRING" . equalsIgnoreCase(type)) {
461
+ builder. add(" the_geom" , LineString . class)
462
+ } else if (" MULTILINESTRING" . equalsIgnoreCase(type)) {
463
+ builder. add(" the_geom" , MultiLineString . class)
464
+ } else if (" POINT" . equalsIgnoreCase(type)) {
465
+ builder. add(" the_geom" , Point . class)
466
+ } else if (" MULTIPOINT" . equalsIgnoreCase(type)) {
467
+ builder. add(" the_geom" , MultiPoint . class)
463
468
} else {
464
469
builder. add(" the_geom" , Polygon . class)
465
470
}
466
- builder. length(50 ). add(" name" , String . class) // <- 50 chars width for
467
- // name field
468
- builder. length(100 ). add(" desc" , String . class) // 100 chars width
469
- // for description
470
- // field
471
+ builder. length(50 ). add(" name" , String . class) // <- 50 chars width for name field
472
+ builder. length(100 ). add(" desc" , String . class) // 100 chars width for description field
471
473
472
474
// build the type
473
475
return builder. buildFeatureType()
0 commit comments