制作 shapefile 时无法创建双精度类型的列

Can't create column of type double when making a shapefile

// 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)

以上代码失败:

java.io.IOException: Unable to write column value : double

我使用的是 scala 2.10.4 版和 geotools 11.2 版

我用过:

typeBuilder.add("value", classOf[java.lang.Double])

而不是

typeBuilder.add("value", classOf[Double])

classOf[java.lang.Double] // returns class java.lang.Double
classOf[Double] // returns double
java.lang.Double.TYPE // returns double

您需要 class 为 java.lang.Double