Support for Spatial area of intersection using DQL

@mrjn, @iluminae

I have this use case where: -

I have a list of destination polygons and a source polygon (destination and source are just used to denote polygons).
What I want to do is find area of intersection of the source polygon with each of the destination polygons
Then select the one with the maximum area of intersection.
Polygon here is list of Points, of course.

For instance, in the image shown below: -

  1. I have destination polygons D1 to D4

  2. Source polygon → S

  1. Return D4 since it has max area of intersection with S

I could not find an example to calculate area of intersection, let alone iterating and finding the maximum. Could you please help me with this in DQL
We are exploring this to evaluate the possibility of spatially linking two nodes based on the geometry which has maximum intersection.

Also a reference of it could be done in POSTGIS

sql - Calculate the percentage of polygon inside the buffer in postgresql - Stack Overflow

@iluminae Pease let me know if this is possible in dgraph
-Murali

Not currently - the intersects() function will act as a boolean function but would return D{1,2,3,4} in your case. You would have to order them by area and take the top 1 after that in your client code. I suggest creating a feature request using the template when you make a new topic here.

There is a feature request out there for string data manipulation functions - this would be the geo equivalent.

Thanks for the response.
Does Dgraph support the extensibility to write and deploy custom user defined functions.
For example: Can i write and deploy a custom function like ‘intersectsArea()’ for the above usecase on the server side of dgraph.

No it does not - not without forking the server. You can use plugins to tokenizers (indexing) but not functions.

Do you have an example or any documentation to develop the above using plugins to tokenizers.

yep, in the docs: https://dgraph.io/docs/query-language/indexing-custom-tokenizers

Thanks again
One last question, does Dgraph cloud provide a mechanism to support/plug-in custom plugins.

It does not, as far as I know.