如何使用JDBC从PostgreSQL中摄取Geomesa中的数据

ndh0cuux  于 2023-06-22  发布在  PostgreSQL
关注(0)|答案(1)|浏览(144)

我正在尝试使用JDBC转换器将数据摄取到Geomesa(使用Accumulo Datastore)。
这是我的table:
| 目标|形状|
| - -----|- -----|
| 1| POLYGON((111.25821079700006-7.167984955999941,112.39345734300002-6.982487154999944,112.60121488000004 -7.613179679999973)|
| 2| POLYGON((111.25821079700006-7.167984955999941,112.39345734300002-6.982487154999944,112.60121488000004 -7.613179679999973))|
这是我的sft:

geomesa = {
  sfts = {
    example = {
      attributes = [
        { name = "uid", type = "String", index = true }
        { name = "shape", type = "Polygon",  default = true , srid = 4326  }
      ]
    }
  }
}

这是我的转换器:

geomesa.converters.example = {
  type       = "jdbc"
  connection = "jdbc:postgresql://localhost:port/databasename?currentSchema=sde&user=myuser&password=mypassword"
  id-field   = "toString($uid)"
  fields = [
    { name = "uid", type = "string", transform = "$uid"}
    { name = "shape", type = "geometry", transform = "geometry($shape)" }
  ]
}

我使用这个命令:

echo "SELECT OBJECTID, ST_AsText(shape) FROM table" | geomesa-accumulo ingest -u user -p password -c catalog -s test.sft -C test.conf

这就是结果:

INFO  Schema 'test' exists
INFO  Running ingestion in local mode
2023-06-12 08:31:21,478 DEBUG [org.locationtech.geomesa.convert.jdbc.JdbcConverter] Failed to evaluate field 'shape' on line 1
2023-06-12 08:31:21,479 DEBUG [org.locationtech.geomesa.convert.jdbc.JdbcConverter] Failed to evaluate field 'shape' on line 2
2023-06-12 08:31:21,745 INFO  [org.locationtech.geomesa.tools.user] Local ingestion complete in 00:00:02
2023-06-12 08:31:21,746 INFO  [org.locationtech.geomesa.tools.user] Ingested 0 features and failed to ingest 2 features for file: <stdin>..

有办法解决吗?

ghhkc1vu

ghhkc1vu1#

数据库字段在转换中由其(基于1的)索引标识,因此您需要将转换器更改为:

{ name = "uid", transform = "$1"}
    { name = "shape", transform = "polygon($2)" }

参见https://www.geomesa.org/documentation/stable/user/convert/jdbc.html#transform-functions

相关问题