Skip to content

Commit eb11525

Browse files
committed
Fix geo tests
1 parent 7b3afa1 commit eb11525

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

src/adapter/search-request-adapter/__tests__/geo-rules.tests.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ test('Adapt geoPoints rules with same 0 lat and 0 lng geo points', () => {
1010
insideBoundingBox: '0,0,0,0',
1111
})
1212

13-
expect(rules?.filter).toBe('_geoRadius(0, 0, 0)')
13+
expect(rules?.filter).toBe('_geoRadius(0.00000, 0.00000, 0)')
1414
})
1515

1616
test('Adapt geoPoints rules with integer geo points', () => {
1717
const rules = adaptGeoPointsRules({
1818
insideBoundingBox: '1,2,3,4',
1919
})
20-
expect(rules?.filter).toBe(
21-
'_geoRadius(2.0003044085023727, 2.999390393801055, 157201.47551181243)'
22-
)
20+
expect(rules?.filter).toBe('_geoRadius(3.17650, 3.19394, 157201.47551181243)')
2321
})
2422

2523
test('Try geoContext with only a radius', () => {
@@ -41,15 +39,15 @@ test('Try geoContext with an aroundLatLng and a radius', () => {
4139
aroundLatLng: '51.1241999, 9.662499900000057',
4240
aroundRadius: 1,
4341
})
44-
expect(rules?.filter).toBe('_geoRadius(51.1241999, 9.662499900000057, 1)')
42+
expect(rules?.filter).toBe('_geoRadius(51.12420, 9.66250, 1)')
4543
})
4644

4745
test('Try geoContext with an aroundLatLng and a 0 radius', () => {
4846
const rules = adaptGeoPointsRules({
4947
aroundLatLng: '51.1241999, 9.662499900000057',
5048
aroundRadius: 0,
5149
})
52-
expect(rules?.filter).toBe('_geoRadius(51.1241999, 9.662499900000057, 0)')
50+
expect(rules?.filter).toBe('_geoRadius(51.12420, 9.66250, 0)')
5351
})
5452

5553
test('Try geoContext with aroundLatLng, radius and insideBoundingBox', () => {
@@ -58,25 +56,19 @@ test('Try geoContext with aroundLatLng, radius and insideBoundingBox', () => {
5856
aroundRadius: 1,
5957
insideBoundingBox: '1,2,3,4',
6058
})
61-
expect(rules?.filter).toBe(
62-
'_geoRadius(2.0003044085023727, 2.999390393801055, 157201.47551181243)'
63-
)
59+
expect(rules?.filter).toBe('_geoRadius(3.17650, 3.19394, 157201.47551181243)')
6460
})
6561
test('Try geoContext with a radius and insideBoundingBox', () => {
6662
const rules = adaptGeoPointsRules({
6763
aroundRadius: 1,
6864
insideBoundingBox: '1,2,3,4',
6965
})
70-
expect(rules?.filter).toBe(
71-
'_geoRadius(2.0003044085023727, 2.999390393801055, 157201.47551181243)'
72-
)
66+
expect(rules?.filter).toBe('_geoRadius(3.17650, 3.19394, 157201.47551181243)')
7367
})
7468
test('Try geoContext with aroundLatLng and insideBoundingBox', () => {
7569
const rules = adaptGeoPointsRules({
7670
aroundLatLng: '51.1241999, 9.662499900000057',
7771
insideBoundingBox: '1,2,3,4',
7872
})
79-
expect(rules?.filter).toBe(
80-
'_geoRadius(2.0003044085023727, 2.999390393801055, 157201.47551181243)'
81-
)
73+
expect(rules?.filter).toBe('_geoRadius(3.17650, 3.19394, 157201.47551181243)')
8274
})

src/adapter/search-request-adapter/geo-rules-adapter.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ export function adaptGeoPointsRules(
4040
}
4141

4242
if (middlePoint != null && radius != null) {
43-
const [lat3, lng3] = middlePoint.split(',')
44-
43+
let [lat3, lng3] = middlePoint.split(',')
44+
lat3 = Number.parseFloat(lat3).toFixed(5)
45+
lng3 = Number.parseFloat(lng3).toFixed(5)
4546
const filter = `_geoRadius(${lat3}, ${lng3}, ${radius})`
4647

4748
return { filter }

0 commit comments

Comments
 (0)