Skip to main content

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

Hello,

I believe that you can make an equivalent query by using 'lessThan AND greaterThan' on your date field. As such, we didn't add 'during' as it is somewhat redundant, and is not really a standard operator outside of ECQL. That said, I'm not opposed to extending the API. Do you have a specific need for 'during'?

Thanks,

Emilio

On 09/14/2018 03:19 AM, phil.xiao wrote:
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



_______________________________________________
geomesa-dev mailing list
geomesa-dev@xxxxxxxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.locationtech.org/mailman/listinfo/geomesa-dev


Back to the top