From 7291531702dd3c3f92f8ac8718bffa25f12c75d0 Mon Sep 17 00:00:00 2001 From: Mygod Date: Sat, 15 Aug 2020 18:20:40 -0400 Subject: [PATCH 1/2] Fix latlon types --- src/data/map.js | 16 ++++++++-------- src/routes/api.js | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/data/map.js b/src/data/map.js index 302317b5..714f0f32 100644 --- a/src/data/map.js +++ b/src/data/map.js @@ -792,10 +792,10 @@ const getS2Cells = async (minLat, maxLat, minLon, maxLon, updated) => { }; const getSubmissionPlacementCells = async (minLat, maxLat, minLon, maxLon) => { - let minLatReal = parseFloat(minLat - 0.001); - let maxLatReal = parseFloat(maxLat + 0.001); - let minLonReal = parseFloat(minLon - 0.001); - let maxLonReal = parseFloat(maxLon + 0.001); + let minLatReal = minLat - 0.001; + let maxLatReal = maxLat + 0.001; + let minLonReal = minLon - 0.001; + let maxLonReal = maxLon + 0.001; let allStops = await getPokestops(minLatReal - 0.002, maxLatReal + 0.002, minLonReal - 0.002, maxLonReal + 0.002, 0, true, false, false, false, null, null, null); allStops = allStops.filter(x => x.sponsor_id === null || x.sponsor_id === 0); @@ -850,10 +850,10 @@ const getSubmissionPlacementCells = async (minLat, maxLat, minLon, maxLon) => { }; const getSubmissionTypeCells = async (minLat, maxLat, minLon, maxLon) => { - let minLatReal = parseFloat(minLat - 0.01); - let maxLatReal = parseFloat(maxLat + 0.01); - let minLonReal = parseFloat(minLon - 0.01); - let maxLonReal = parseFloat(maxLon + 0.01); + let minLatReal = minLat - 0.01; + let maxLatReal = maxLat + 0.01; + let minLonReal = minLon - 0.01; + let maxLonReal = maxLon + 0.01; let allStops = await getPokestops(minLatReal - 0.02, maxLatReal + 0.02, minLonReal - 0.02, maxLonReal + 0.02, 0, true, false, false, false, null, null, null); allStops = allStops.filter(x => x.sponsor_id === null || x.sponsor_id === 0); diff --git a/src/routes/api.js b/src/routes/api.js index ef8ca0d6..ff0a569f 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -23,10 +23,10 @@ router.post('/get_data', async (req, res) => { const getData = async (perms, filter) => { //console.log('Filter:', filter); - const minLat = filter.min_lat; - const maxLat = filter.max_lat; - const minLon = filter.min_lon; - const maxLon = filter.max_lon; + const minLat = parseFloat(filter.min_lat); + const maxLat = parseFloat(filter.max_lat); + const minLon = parseFloat(filter.min_lon); + const maxLon = parseFloat(filter.max_lon); const showGyms = filter.show_gyms && filter.show_gyms !== 'false' || false; const showRaids = filter.show_raids && filter.show_raids !== 'false' || false; const showPokestops = filter.show_pokestops && filter.show_pokestops !== 'false' || false; From 50876d9dc7c888c29a6fc81a662b422faccefd05 Mon Sep 17 00:00:00 2001 From: Mygod Date: Sat, 15 Aug 2020 18:29:02 -0400 Subject: [PATCH 2/2] Fix some S2 cell issues --- src/data/map.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data/map.js b/src/data/map.js index 714f0f32..e82bab51 100644 --- a/src/data/map.js +++ b/src/data/map.js @@ -828,14 +828,14 @@ const getSubmissionPlacementCells = async (minLat, maxLat, minLon, maxLon) => { } for (let i = 0; i < allGymCoods.length; i++) { let coord = allGymCoods[i]; - let level1Cell = S2.S2Cell.fromLatLng(new S2.S2LatLng(coord)); + let level1Cell = S2.S2Cell.fromLatLng(S2.S2LatLng.fromDegrees(coord.lat, coord.lon)); let regionCoverer = new S2.S2RegionCoverer(); regionCoverer.minLevel = 17; regionCoverer.maxLevel = 17; regionCoverer.maxCells = 1; let region = level1Cell.getRectBound(); let coveringCells = regionCoverer.getCoveringCells(region); - let level17Cell = coveringCells[0];// TODO: .parent(17); + let level17Cell = coveringCells[0].parentL(17); let cellId = BigInt(level17Cell.id).toString(); let cell = indexedCells[cellId]; if (cell) {