Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[geomesa-dev] Temporal query in geomesa-geojson component

Hi ,

We plan to use GeoJSON API and REST as our service interface. Howerver, I found that the GeoJSON REST way doesn’t support temporal query keywords such as “during”, right? Anybody know why GeoJSON API doesn’t provide this part?

So our solution is to add  some temporal query funcitons in the class of “GeoJsonQuery” to make full use of Z3 index ,  the code segment looks like below:

private def evaluatePredicate(prop: String, json: JObject): GeoJsonQuery = {
    println(json.obj.headOption)
    json.obj.headOption match {
      case Some(("$bbox", v: JArray)) =>
        // { "$bbox" : [-180, -90, 180, 90] }
        val List(xmin, ymin, xmax, ymax) = v.values.asInstanceOf[List[Number]]
        Bbox(prop, xmin.doubleValue, ymin.doubleValue, xmax.doubleValue, ymax.doubleValue)
      case Some(("$during", v)) =>
        // { "$during" : "2014-01-01T00:00:00.000Z/2014-01-01T07:59:59.000Z" }
        During(prop,v.values)
      case Some(("$intersects", v: JObject)) =>
        // { "$intersects" : { "$geometry" : { "type" : "Point", "coordinates" : [30, 10] } } }
        Intersects(prop, evaluateGeometry(v))
       …...
      case None =>
        throw new IllegalArgumentException("Invalid json structure")
    }
  }
//…
/**
    * Temporal Duration
    *
    * @param prop property to evaluate
    * @param value value to compare with property value
    */
  case class During(prop: String, value: Any) extends GeoJsonQuery{
    override def toFilter(propertyTransformer: PropertyTransformer): Filter = {
      ECQL.toFilter("dtg DURING "+ff.literal(value).toString.replace("\"",""))
    }
    override def toString = s"""{"$prop":${printJson(value)}}"""
  }


Then we can do the spatiotempral queries like this:
curl 'localhost/geoserver/geomesa/geojson/index/tdrive_ds/tdrive_index/features' --get --data-urlencode 'q={"properties.num":"1007","geometry":{"$bbox":[116.3398,39.8407,116.34,39.8409]},"dtg":{"$during" : "2008-02-02T08:00:00Z/2008-02-02T10:00:00Z"}}'

I am wondering if anybody can give me some suggestions if this approach is OK. If yes I plan to add more temporal funtions to GeoJsonQuery in order to enhance the temporal query capabilities. 

Best regards,
Phil

from 阿里邮箱 macOS

Back to the top