@@ -218,7 +218,14 @@ class CsvReader implements Reader {
218218 name = parts[0 ]
219219 type = parts[1 ]
220220 }
221- new Field (name, type)
221+ // Make sure the type is valid
222+ if (Schema . isValidFieldType(type)) {
223+ new Field (name, type)
224+ }
225+ // Otherwise fall back
226+ else {
227+ new Field (" ${ name} :${ type} " , " String" )
228+ }
222229 }
223230 fields. add(new Field (" geom" , " Point" ))
224231 Schema schema = new Schema (layerName, fields)
@@ -245,8 +252,8 @@ class CsvReader implements Reader {
245252 def v = values[i]
246253 def colType = " String"
247254 def proj = null
248- // Get the type from the header
249- if (c. contains(" :" )) {
255+ // Get the type from the header (if the type is valid)
256+ if (c. contains(" :" ) && Schema . isValidFieldType(c . split( " : " )[ 1 ]) ) {
250257 String [] parts = c. split(" :" )
251258 c = parts[0 ]
252259 colType = parts[1 ]
@@ -293,6 +300,9 @@ class CsvReader implements Reader {
293300 Map valueMap = [:]
294301 cols. eachWithIndex {c ,i ->
295302 String colName = getColumnName(c)
303+ if (! layer. schema. has(colName)) {
304+ colName = c
305+ }
296306 def v = values[i]
297307 if (usingSingleColumn && colName. equalsIgnoreCase(column)) {
298308 if (isGeom) {
@@ -400,7 +410,11 @@ class CsvReader implements Reader {
400410 str. startsWith(" MULTILINESTRING (" ) || str. startsWith(" MULTILINESTRING(" ) ||
401411 str. startsWith(" MULTIPOLYGON" ) || str. startsWith(" MULTIPOLYGON(" ) ||
402412 str. startsWith(" GEOMETRYCOLLECTION (" ) || str. startsWith(" GEOMETRYCOLLECTION(" ) ||
403- str. startsWith(" LINEARRING (" ) || str. startsWith(" LINEARRING(" )
413+ str. startsWith(" LINEARRING (" ) || str. startsWith(" LINEARRING(" ) ||
414+ str. startsWith(" CIRCULARSTRING (" ) || str. startsWith(" CIRCULARSTRING(" ) ||
415+ str. startsWith(" CIRCULARRING (" ) || str. startsWith(" CIRCULARRING(" ) ||
416+ str. startsWith(" COMPOUNDCURVE (" ) || str. startsWith(" COMPOUNDCURVE(" ) ||
417+ str. startsWith(" COMPOUNDRING (" ) || str. startsWith(" COMPOUNDRING(" )
404418 ) {
405419 return true
406420 }
0 commit comments