Feature Request: GeoJson LineString Type

Moved from GitHub dgraph/2316

Posted by allen-munsch:

  • What version of Dgraph are you using?

Dgraph version : v1.0.4
Commit SHA-1 : aad59072
Commit timestamp : 2018-03-09 17:37:44 +1100
Branch : HEAD

  • Have you tried reproducing the issue with latest release?

whatever was on master as of a few hours ago

  • What is the hardware spec (RAM, OS)?
system_profiler SPHardwareDataType | grep "  Memory:"

      Memory: 16 GB

sw_vers

    ProductName:        Mac OS X
    ProductVersion: 10.13.3
    BuildVersion:   17D47
  • Steps to reproduce the issue (command/config used to run Dgraph).

Load geojson:

find ../json/*json | xargs -IHMM bash -c 'filename=`basename -- "HMM"`; go run dgraph/cmd/dgraph-converter/main.go --geo ../json/$filename --out ../rdf_gz/"${filename%.*}".rdf.gz'

find ../rdf_gz | xargs -I{} bash -c 'dgraph live -r {}'

Unable to query featues type “LineString” coordinates :

curl -s http://127.0.0.1:8080/query -X POST -d $'q(func: near(loc, [ -93.962679,44.320331], 100) ) {\n    from_name,\n  }' | python -m json.tool
  • Expected behaviour and actual result.

approximate behaviour :

{
    "data": {
        "q": [
            {
                "circuit": "1",
                "from_name": "XXX",
                "loc": {
                    "coordinates": [
                        [
                            -93.962679,
                            44.320331
                        ],
                        [
                            -93.962679,
                            44.320331
                        ]
                    ],
                    "type": "LineString"
                },
                "status": "Closed",
                "to_name": "YYY"
            }
        ]
    },
    "extensions": {
        "server_latency": {
            "encoding_ns": 784000,
            "parsing_ns": 35000,
            "processing_ns": 4496000
        },
        "txn": {
            "lin_read": {
                "ids": {
                    "1": 455
                }
            },
            "start_ts": 464
        }
    }
}

actual result:

{
    "data": {
        "q": []
    },
    "extensions": {
        "server_latency": {
            "encoding_ns": 412000,
            "parsing_ns": 11000,
            "processing_ns": 107000
        },
        "txn": {
            "lin_read": {
                "ids": {
                    "1": 456
                }
            },
            "start_ts": 478
        }
    }
}

Related:

New to go, but wondering what it would take to do a near query on the points of a LineString.

campoy commented :

According to the GeoJSON specs there are the following geometry objects:

  • Position
  • Point
  • MultiPoint
  • LineString
  • MultiLineString
  • Polygon
  • MultiPolygon
  • GeometryCollection
  • Antimeridian Cutting
  • Uncertainty and Precision

We currently support Point and Polygon, it would make sense to figure out which others (other than LineString makes sense to support.

allen-munsch commented :

The use case that I was interested in at the time was neighbours to point x1, y1 … any xn, yn, where xn, yn could be within distance of any of the flattened/decomposed position objects [point, multipoint, linestring, multilinestring, polygon, multipolygon, GeometryCollection] … I’m not sure of the utility related to Antimeridian Cutting, or Uncertainty and Precision

@campoy Thanks for taking a look at this.

campoy commented :

Thanks for the input, I was also reading the Antimeridian and didn’t see much of a use case for us.
I will consider when we can add this into our roadmap :slight_smile: