嗨,大家好,我是GeoMesa的新手。并尝试将我的MySQL表导入其中。如在其http://www.geomesa.org/documentation/user/commandline_tools.html网站上给出的。

要摄取.csv文件,可以在application.conf文件中放置一个名为renegades的SimpleFeatureType和一个名为renegades-csv的转换器:

geomesa {
  sfts {
    renegades = {
      attributes = [
        { name = "id",       type = "Integer",      index = false                             }
        { name = "name",     type = "String",       index = true                              }
        { name = "age",      type = "Integer",      index = false                             }
        { name = "lastseen", type = "Date",         index = true                              }
        { name = "friends",  type = "List[String]", index = true                              }
        { name = "geom",     type = "Point",        index = true, srid = 4326, default = true }
      ]
    }
  }
  converters {
    renegades-csv = {
      type   = "delimited-text"
      format = "CSV"
      options {
        skip-lines = 1 //skip the header
      }
      id-field = "toString($id)"
      fields = [
        { name = "id",       transform = "$1::int"                 }
        { name = "name",     transform = "$2::string"              }
        { name = "age",      transform = "$3::int"                 }
        { name = "lastseen", transform = "date('YYYY-MM-dd', $4)"  }
        { name = "friends",  transform = "parseList('string', $5)" }
        { name = "lon",      transform = "$6::double"              }
        { name = "lat",      transform = "$7::double"              }
        { name = "geom",     transform = "point($lon, $lat)"       }
      ]
    }
  }
}


但是问题是:


在上面的示例中,我找不到任何教程或关于如何使该文件具有某些数据类型的帮助。但是我的一些SQL DB值是varchar,tinyint,float和datetime。现在,对于叛教者和转化者而言,GeoMesa中的数据类型都与这些数据类型相似。
以及何时使叛军的index = true或false。

最佳答案

对于#1,当您在MySQL和GeoMesa的SimpleFeatureTypes之间进行映射时,varchar变为“字符串”,任何整数字段都应为“整数”或“长”,日期为“日期”,而几何字段可能为“点”, “线串”,“多边形”或“几何”。 (注意:有多个版本,但您可能不需要这些版本。)

对于#2,“ index = true”(或false)位与GeoMesa中的二级索引有关。默认情况下,GeoMesa为几何和时间字段创建索引。如果您打算按时空查询,那么您的查询应该是最佳的。如果只希望通过属性查询,请在上面的示例中说“ friends”,然后使用“ index = true”为该字段创建索引可能会有所帮助。

关于mysql - Geomesa .csv转换格式,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39304910/

10-10 09:20