@@ -59,7 +59,31 @@ describe('Geo Point', () => {
5959 } ) ;
6060 } ) ;
6161
62- it ( 'can sequence a line of points by distance' , ( done ) => {
62+ it ( 'can sequence a line of points by distance - without unsorted parameter' , ( done ) => {
63+ let line = [ ] ;
64+ for ( let i = 0 ; i < 10 ; i ++ ) {
65+ let obj = new TestObject ( ) ;
66+ let point = new Parse . GeoPoint ( i * 4 - 12 , i * 3.2 - 11 ) ;
67+ obj . set ( 'location' , point ) ;
68+ obj . set ( 'construct' , 'line' ) ;
69+ obj . set ( 'seq' , i ) ;
70+ line . push ( obj ) ;
71+ }
72+ Parse . Object . saveAll ( line ) . then ( ( ) => {
73+ let query = new Parse . Query ( TestObject ) ;
74+ let point = new Parse . GeoPoint ( 24 , 19 ) ;
75+ query . equalTo ( 'construct' , 'line' ) ;
76+ query . withinMiles ( 'location' , point , 10000 ) ;
77+ return query . find ( ) ;
78+ } ) . then ( ( results ) => {
79+ assert . equal ( results . length , 10 ) ;
80+ assert . equal ( results [ 0 ] . get ( 'seq' ) , 9 ) ;
81+ assert . equal ( results [ 3 ] . get ( 'seq' ) , 6 ) ;
82+ done ( ) ;
83+ } ) ;
84+ } ) ;
85+
86+ it ( 'can sequence a line of points by distance - with unsorted parameter' , ( done ) => {
6387 let line = [ ] ;
6488 for ( let i = 0 ; i < 10 ; i ++ ) {
6589 let obj = new TestObject ( ) ;
@@ -97,7 +121,7 @@ describe('Geo Point', () => {
97121 let query = new Parse . Query ( TestObject ) ;
98122 let point = new Parse . GeoPoint ( 1 , - 1 ) ;
99123 query . equalTo ( 'construct' , 'large_dist' ) ;
100- query . withinRadians ( 'location' , point , 3.14 , true ) ;
124+ query . withinRadians ( 'location' , point , 3.14 ) ;
101125 return query . find ( ) ;
102126 } ) . then ( ( results ) => {
103127 assert . equal ( results . length , 3 ) ;
@@ -119,7 +143,7 @@ describe('Geo Point', () => {
119143 let query = new Parse . Query ( TestObject ) ;
120144 let point = new Parse . GeoPoint ( 1 , - 1 ) ;
121145 query . equalTo ( 'construct' , 'medium_dist' ) ;
122- query . withinRadians ( 'location' , point , 3.14 * 0.5 , true ) ;
146+ query . withinRadians ( 'location' , point , 3.14 * 0.5 ) ;
123147 return query . find ( ) ;
124148 } ) . then ( ( results ) => {
125149 assert . equal ( results . length , 2 ) ;
@@ -143,7 +167,7 @@ describe('Geo Point', () => {
143167 let query = new Parse . Query ( TestObject ) ;
144168 let point = new Parse . GeoPoint ( 1 , - 1 ) ;
145169 query . equalTo ( 'construct' , 'small_dist' ) ;
146- query . withinRadians ( 'location' , point , 3.14 * 0.25 , true ) ;
170+ query . withinRadians ( 'location' , point , 3.14 * 0.25 ) ;
147171 return query . find ( ) ;
148172 } ) . then ( ( results ) => {
149173 assert . equal ( results . length , 1 ) ;
@@ -155,7 +179,7 @@ describe('Geo Point', () => {
155179 it ( 'can measure distance within km - everywhere' , ( done ) => {
156180 let sfo = new Parse . GeoPoint ( 37.6189722 , - 122.3748889 ) ;
157181 let query = new Parse . Query ( TestPoint ) ;
158- query . withinKilometers ( 'location' , sfo , 4000.0 , true ) ;
182+ query . withinKilometers ( 'location' , sfo , 4000.0 ) ;
159183 query . find ( ) . then ( ( results ) => {
160184 assert . equal ( results . length , 3 ) ;
161185 done ( ) ;
@@ -165,7 +189,7 @@ describe('Geo Point', () => {
165189 it ( 'can measure distance within km - california' , ( done ) => {
166190 let sfo = new Parse . GeoPoint ( 37.6189722 , - 122.3748889 ) ;
167191 let query = new Parse . Query ( TestPoint ) ;
168- query . withinKilometers ( 'location' , sfo , 3700.0 , true ) ;
192+ query . withinKilometers ( 'location' , sfo , 3700.0 ) ;
169193 query . find ( ) . then ( ( results ) => {
170194 assert . equal ( results . length , 2 ) ;
171195 assert . equal ( results [ 0 ] . get ( 'name' ) , 'San Francisco' ) ;
@@ -177,7 +201,7 @@ describe('Geo Point', () => {
177201 it ( 'can measure distance within km - bay area' , ( done ) => {
178202 let sfo = new Parse . GeoPoint ( 37.6189722 , - 122.3748889 ) ;
179203 let query = new Parse . Query ( TestPoint ) ;
180- query . withinKilometers ( 'location' , sfo , 100.0 , true ) ;
204+ query . withinKilometers ( 'location' , sfo , 100.0 ) ;
181205 query . find ( ) . then ( ( results ) => {
182206 assert . equal ( results . length , 1 ) ;
183207 assert . equal ( results [ 0 ] . get ( 'name' ) , 'San Francisco' ) ;
@@ -188,7 +212,7 @@ describe('Geo Point', () => {
188212 it ( 'can measure distance within km - mid peninsula' , ( done ) => {
189213 let sfo = new Parse . GeoPoint ( 37.6189722 , - 122.3748889 ) ;
190214 let query = new Parse . Query ( TestPoint ) ;
191- query . withinKilometers ( 'location' , sfo , 10.0 , true ) ;
215+ query . withinKilometers ( 'location' , sfo , 10.0 ) ;
192216 query . find ( ) . then ( ( results ) => {
193217 assert . equal ( results . length , 0 ) ;
194218 done ( ) ;
@@ -198,7 +222,7 @@ describe('Geo Point', () => {
198222 it ( 'can measure distance within miles - everywhere' , ( done ) => {
199223 let sfo = new Parse . GeoPoint ( 37.6189722 , - 122.3748889 ) ;
200224 let query = new Parse . Query ( TestPoint ) ;
201- query . withinMiles ( 'location' , sfo , 2500.0 , true ) ;
225+ query . withinMiles ( 'location' , sfo , 2500.0 ) ;
202226 query . find ( ) . then ( ( results ) => {
203227 assert . equal ( results . length , 3 ) ;
204228 done ( ) ;
@@ -208,7 +232,7 @@ describe('Geo Point', () => {
208232 it ( 'can measure distance within miles - california' , ( done ) => {
209233 let sfo = new Parse . GeoPoint ( 37.6189722 , - 122.3748889 ) ;
210234 let query = new Parse . Query ( TestPoint ) ;
211- query . withinMiles ( 'location' , sfo , 2200.0 , true ) ;
235+ query . withinMiles ( 'location' , sfo , 2200.0 ) ;
212236 query . find ( ) . then ( ( results ) => {
213237 assert . equal ( results . length , 2 ) ;
214238 assert . equal ( results [ 0 ] . get ( 'name' ) , 'San Francisco' ) ;
@@ -220,7 +244,7 @@ describe('Geo Point', () => {
220244 it ( 'can measure distance within miles - bay area' , ( done ) => {
221245 let sfo = new Parse . GeoPoint ( 37.6189722 , - 122.3748889 ) ;
222246 let query = new Parse . Query ( TestPoint ) ;
223- query . withinMiles ( 'location' , sfo , 75.0 , true ) ;
247+ query . withinMiles ( 'location' , sfo , 75.0 ) ;
224248 query . find ( ) . then ( ( results ) => {
225249 assert . equal ( results . length , 1 ) ;
226250 assert . equal ( results [ 0 ] . get ( 'name' ) , 'San Francisco' ) ;
@@ -231,7 +255,7 @@ describe('Geo Point', () => {
231255 it ( 'can measure distance within km - mid peninsula' , ( done ) => {
232256 let sfo = new Parse . GeoPoint ( 37.6189722 , - 122.3748889 ) ;
233257 let query = new Parse . Query ( TestPoint ) ;
234- query . withinMiles ( 'location' , sfo , 10.0 , true ) ;
258+ query . withinMiles ( 'location' , sfo , 10.0 ) ;
235259 query . find ( ) . then ( ( results ) => {
236260 assert . equal ( results . length , 0 ) ;
237261 done ( ) ;
0 commit comments