Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@treblefm/offline-geocoder",
"version": "1.0.0",
"name": "@swayam18/offline-geocoder",
"version": "1.0.4",
"main": "src/index.js",
"engines": {
"node": ">=4"
Expand All @@ -10,8 +10,8 @@
},
"scripts": {
"test": "eslint '**/*.js'",
"postinstall": "cd data && ../scripts/postinstall.sh",
"generate": "cd data && ../scripts/generate.sh"
"postinstall": "mkdir -p data && cd data && . ../scripts/postinstall.sh",
"generate": "mkdir -p data && cd data && . ../scripts/generate.sh"
},
"author": "Luca Spiller",
"license": "MIT",
Expand Down
28 changes: 28 additions & 0 deletions src/reverse.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,35 @@ const format = require("./location").format;
// different at the poles vs the equator.
//
// Based upon http://stackoverflow.com/a/7261601/155715
const Singapore = {
formatted: "Singapore, Central Singapore, Singapore",

city: {
id: 1880252,
name: "Singapore"
},
region: {
id: 1,
name: "Singapore"
},
country: {
id: "SG",
name: "Singapore"
},

coordinates: {
latitude: 1.28967,
longitude: 103.85007
}
}
module.exports = function Reverse(geocoder, latitude, longitude) {
// hardcode Singapore
if (latitude > 1.2113 && latitude < 1.4653 && longitude > 103.524 && longitude < 104.0265) {
return new Promise((resolve) => {
resolve(Singapore);
});
}

const scale = Math.pow(Math.cos(latitude * Math.PI / 180), 2);

return new Promise((resolve, reject) => {
Expand Down