Skip to content

Commit

Permalink
Merge pull request #35 from Mygod/fix-latlon-type
Browse files Browse the repository at this point in the history
Fix latlon types
  • Loading branch information
versx authored Aug 16, 2020
2 parents 57958e5 + 50876d9 commit a9170f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions src/data/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a9170f1

Please sign in to comment.