Geolocation List

I wish I could make a geo list as if it were a geo track/trace. And a way where I could add an timestamp like order to the recordings for later analysis. For example. I need to record the position of a truck from point A to point B every 2 minutes “according to my needs in an application”.

I think to do this today I would need to create new nodes every 2 minutes. I think a list is better than that.

What would be your way to do that?

And I was already forgetting, it looks like “location: [geo] @index (geo).” as list does not work. I tried to at least do so and he did not list my additions. He replaced the previous recording.

Best Regards

{
        "predicate": "location",
        "type": "geo",
        "index": true,
        "tokenizer": [
          "geo"
        ],
        "list": true
      },

`<0x3> <location> "
  {  'type':'Point', 
     'record':'001' # <===this is an example to "timestamp",
     'coordinates':[-122.4220186,37.772317]}"^^<geo:geojson> .`

https://docs.dgraph.io/query-language/#geolocation

Interesting. I would model this as time series data using a time tree as the ‘backbone’ graph.

Time tree would be something like

Y - has_month → M - has_day → D - has_minute → M

Y - next → Y; M - next → M; D - next → D etc

If we don’t need finer resolution than minutes, this time tree can be created up-front. If something like sub-second resolution is needed, I would create those time nodes on demand.

Now, indeed every geolocation visited would be added as an individual node (with a truck id or something). Geolocation nodes have a @reverse edge to their respective time nodes.

IMHO, cramming geolocations as a list into a single node, we will lose a lot of the benefits a graph model has to offer.

In addition, I would expect a GraphDB to handle a LOT of nodes without problems and hence never be reluctant to add a lot of them.

Cheers,
Andreas

1 Like

Thanks for your answer.

I do agree with your approach, though, in my specific case the way I’m studying an implementation. Having each geolocation recording individually on separate nodes is indifferent to me. Then I see listing as best.

In my case I thought I could normally manipulate a Dgraph “geo” list. And manipulate the generated object into it. In Drgaph I believe the type template is predefined and it’s obj is immutable. Point and Polygon.

The “timestamp” I imagined, does not need to be accurate. I thought that way only to have a recording order. The main node would have data such as what time the track started and other information. As a truck number plate, driver’s name and ID, and so on.

In case a track/record would be an node that has a geo list. The list itself I would manipulate / itinerate later in the application. None of the functions or filters from Dgraph are useful for this particulary situation (for me).

And as I’ve seen I can use ““list”: true”. I think you should at least add data even without order. But It can’t.

My understanding is that if you want to store a list of Points you would use either a LineString or a MultiLineString.

Both currently don’t have indexing support, though.

Hey @MichelDiz

List type should work with geo. I tried with the following schema and mutations.

loc: [geo] @index(geo) .
{
  set {
    <_:0xeb1dde9c> <loc> "{'type':'Point','coordinates':[-122.4220186,37.772318]}"^^<geo:geojson> .
    <_:0xeb1dde9c> <loc> "{'type':'Point','coordinates':[-123.4220186,38.772318]}"^^<geo:geojson> .
  }
}

The I ran this query

{
  me(func: uid(0x1)) {
    loc
  }
}

And got expected results

{
  "data": {
    "me": [
      {
        "loc": [
          {
            "type": "Point",
            "coordinates": [
              -122.4220186,
              37.772318
            ]
          },
          {
            "type": "Point",
            "coordinates": [
              -123.4220186,
              38.772318
            ]
          }
        ]
      }
    ]
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 10792,
      "processing_ns": 44677,
      "encoding_ns": 390974
    },
    "txn": {
      "start_ts": 7,
      "lin_read": {
        "ids": {
          "1": 7
        }
      }
    }
  }
}
1 Like

Now I see what’s the whole point of the initial question :grinning: Thanks!

1 Like

All right, but one more thing. So now in thesis I could add a facet for each recording. Right? That way I can placate what I wanted, which was to give order to this list.

Would be like this:

{
set {
<:0xeb1dde9c> <loc> “{‘type’:‘Point’,‘coordinates’:[-122.4220186,37.772318]}”^^<geo:geojson>(timestamp=2017-12-02T15:04:05) .
<:0xeb1dde9c> <loc> “{‘type’:‘Point’,‘coordinates’:[-123.4220186,38.772318]}”^^<geo:geojson>(timestamp=2017-12-02T15:04:10) .
}
}

Right?

And then a could use something like:

myTracker (orderasc: val(timestamp)) (first: 13) {
          loc
      }

or


  myTracker  (func: anyofterms(name, "Alice Bob Charlie")) {
    name
    loc @facets(orderasc: timestamp) {
      loc
    }
  }
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.