// My type
val typeBuilder = new SimpleFeatureTypeBuilder()
typeBuilder.setName("line-query-seg")
typeBuilder.add("value", classOf[Double])
typeBuilder.setDefaultGeometry("the_geom")
typeBuilder.add("the_geom", classOf[LineString])
val sft = typeBuilder.buildFeatureType()
// Trying to create a shapefile of this type
val dataStoreFactory = new ShapefileDataStoreFactory()
val shp = new File("/tmp/collection.shp")
val params = scala.collection.Map[String, Serializable]("url" -> shp.toURI.toURL,
"create spatial index" -> true
)
val shpDS = dataStoreFactory.createNewDataStore(params.asJava).asInstanceOf[ShapefileDataStore]
shpDS.createSchema(sft)
The above code fails with:
java.io.IOException: Unable to write column value : double
I'm using scala version 2.10.4 and geotools version 11.2
I used:
typeBuilder.add("value", classOf[java.lang.Double])
instead of
typeBuilder.add("value", classOf[Double])
classOf[java.lang.Double] // returns class java.lang.Double
classOf[Double] // returns double
java.lang.Double.TYPE // returns double
You need the class to be java.lang.Double