File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ class ResultSetScalarTypes:
41
41
VALUE_NODE = 8
42
42
VALUE_PATH = 9
43
43
VALUE_MAP = 10
44
+ VALUE_POINT = 11
44
45
45
46
46
47
class QueryResult :
@@ -198,6 +199,14 @@ def parse_map(self, cell):
198
199
199
200
return m
200
201
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
+
201
210
def parse_scalar (self , cell ):
202
211
scalar_type = int (cell [0 ])
203
212
value = cell [1 ]
@@ -242,6 +251,9 @@ def parse_scalar(self, cell):
242
251
elif scalar_type == ResultSetScalarTypes .VALUE_MAP :
243
252
scalar = self .parse_map (value )
244
253
254
+ elif scalar_type == ResultSetScalarTypes .VALUE_POINT :
255
+ scalar = self .parse_point (value )
256
+
245
257
elif scalar_type == ResultSetScalarTypes .VALUE_UNKNOWN :
246
258
print ("Unknown scalar type\n " )
247
259
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ def read_all(f):
11
11
12
12
setup (
13
13
name = 'redisgraph' ,
14
- version = '2.2.4 ' ,
14
+ version = '2.3.0 ' ,
15
15
description = 'RedisGraph Python Client' ,
16
16
long_description = read_all ("README.md" ),
17
17
long_description_content_type = 'text/markdown' ,
Original file line number Diff line number Diff line change @@ -115,6 +115,26 @@ def test_map(self):
115
115
# All done, remove graph.
116
116
redis_graph .delete ()
117
117
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
+
118
138
def test_index_response (self ):
119
139
redis_graph = Graph ('social' , self .r )
120
140
You can’t perform that action at this time.
0 commit comments