Skip to content

Add support for Point datatype #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 24, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add support for Point datatype
  • Loading branch information
jeffreylovitz committed Feb 17, 2021
commit 94df38782b2afe51f7408ce0f2473dd898f9182e
12 changes: 12 additions & 0 deletions redisgraph/query_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ResultSetScalarTypes:
VALUE_NODE = 8
VALUE_PATH = 9
VALUE_MAP = 10
VALUE_POINT = 11


class QueryResult:
Expand Down Expand Up @@ -179,6 +180,14 @@ def parse_map(self, cell):

return m

def parse_point(self, cell):
p = {}
# A point is received an array of the form: [latitude, longitude]
# It is returned as a map of the form: {"x": latitude, "y": longitude}
p["x"] = float(cell[0])
p["y"] = float(cell[1])
return p

def parse_scalar(self, cell):
scalar_type = int(cell[0])
value = cell[1]
Expand Down Expand Up @@ -223,6 +232,9 @@ def parse_scalar(self, cell):
elif scalar_type == ResultSetScalarTypes.VALUE_MAP:
scalar = self.parse_map(value)

elif scalar_type == ResultSetScalarTypes.VALUE_POINT:
scalar = self.parse_point(value)

elif scalar_type == ResultSetScalarTypes.VALUE_UNKNOWN:
print("Unknown scalar type\n")

Expand Down