Skip to content

Commit 932da5c

Browse files
authored
Merge branch 'master' into metadata-footer
2 parents 652a58e + e988cdd commit 932da5c

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

redisgraph/query_result.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class ResultSetScalarTypes:
4141
VALUE_NODE = 8
4242
VALUE_PATH = 9
4343
VALUE_MAP = 10
44+
VALUE_POINT = 11
4445

4546

4647
class QueryResult:
@@ -198,6 +199,14 @@ def parse_map(self, cell):
198199

199200
return m
200201

202+
def parse_point(self, cell):
203+
p = {}
204+
# A point is received an array of the form: [latitude, longitude]
205+
# It is returned as a map of the form: {"latitude": latitude, "longitude": longitude}
206+
p["latitude"] = float(cell[0])
207+
p["longitude"] = float(cell[1])
208+
return p
209+
201210
def parse_scalar(self, cell):
202211
scalar_type = int(cell[0])
203212
value = cell[1]
@@ -242,6 +251,9 @@ def parse_scalar(self, cell):
242251
elif scalar_type == ResultSetScalarTypes.VALUE_MAP:
243252
scalar = self.parse_map(value)
244253

254+
elif scalar_type == ResultSetScalarTypes.VALUE_POINT:
255+
scalar = self.parse_point(value)
256+
245257
elif scalar_type == ResultSetScalarTypes.VALUE_UNKNOWN:
246258
print("Unknown scalar type\n")
247259

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def read_all(f):
1111

1212
setup(
1313
name='redisgraph',
14-
version='2.2.4',
14+
version='2.3.0',
1515
description='RedisGraph Python Client',
1616
long_description=read_all("README.md"),
1717
long_description_content_type='text/markdown',

tests/functional/test_all.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,26 @@ def test_map(self):
115115
# All done, remove graph.
116116
redis_graph.delete()
117117

118+
def test_point(self):
119+
redis_graph = Graph('map', self.r)
120+
121+
query = "RETURN point({latitude: 32.070794860, longitude: 34.820751118})"
122+
expected_lat = 32.070794860
123+
expected_lon = 34.820751118
124+
actual = redis_graph.query(query).result_set[0][0]
125+
self.assertTrue(abs(actual['latitude'] - expected_lat) < 0.001)
126+
self.assertTrue(abs(actual['longitude'] - expected_lon) < 0.001)
127+
128+
query = "RETURN point({latitude: 32, longitude: 34.0})"
129+
expected_lat = 32
130+
expected_lon = 34
131+
actual = redis_graph.query(query).result_set[0][0]
132+
self.assertTrue(abs(actual['latitude'] - expected_lat) < 0.001)
133+
self.assertTrue(abs(actual['longitude'] - expected_lon) < 0.001)
134+
135+
# All done, remove graph.
136+
redis_graph.delete()
137+
118138
def test_index_response(self):
119139
redis_graph = Graph('social', self.r)
120140

0 commit comments

Comments
 (0)