File tree 2 files changed +32
-0
lines changed
2 files changed +32
-0
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 :
@@ -179,6 +180,14 @@ def parse_map(self, cell):
179
180
180
181
return m
181
182
183
+ def parse_point (self , cell ):
184
+ p = {}
185
+ # A point is received an array of the form: [latitude, longitude]
186
+ # It is returned as a map of the form: {"latitude": latitude, "longitude": longitude}
187
+ p ["latitude" ] = float (cell [0 ])
188
+ p ["longitude" ] = float (cell [1 ])
189
+ return p
190
+
182
191
def parse_scalar (self , cell ):
183
192
scalar_type = int (cell [0 ])
184
193
value = cell [1 ]
@@ -223,6 +232,9 @@ def parse_scalar(self, cell):
223
232
elif scalar_type == ResultSetScalarTypes .VALUE_MAP :
224
233
scalar = self .parse_map (value )
225
234
235
+ elif scalar_type == ResultSetScalarTypes .VALUE_POINT :
236
+ scalar = self .parse_point (value )
237
+
226
238
elif scalar_type == ResultSetScalarTypes .VALUE_UNKNOWN :
227
239
print ("Unknown scalar type\n " )
228
240
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