Comparing version 0.1.1 to 0.1.2
@@ -0,1 +1,7 @@ | ||
#### 0.1.2 (2018-07-23) | ||
##### Build System / Dependencies | ||
* change build process to rollup ([42322971](https://github.com/MichaelSolati/geokit/commit/42322971fd54fbba434d4848390fd0dcdd20dfba)) | ||
#### 0.1.1 (2018-06-02) | ||
@@ -2,0 +8,0 @@ |
@@ -0,0 +0,0 @@ import { LatLngLiteral } from './interfaces'; |
@@ -1,90 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var helpers_1 = require("./helpers"); | ||
/** | ||
* A class for the Geokit. | ||
*/ | ||
var Geokit = /** @class */ (function () { | ||
function Geokit() { | ||
} | ||
/** | ||
* Get the distance between two coordinates. | ||
* @param start Starting coordinates. | ||
* @param end Ending coordinates. | ||
* @param unit Unit of distance returned, defaults to Km. | ||
* @returns The distance between two coordinates. | ||
*/ | ||
Geokit.distance = function (start, end, unit) { | ||
if (unit === void 0) { unit = 'km'; } | ||
var startValid = helpers_1.validateCoordinates(start); | ||
if (startValid instanceof Error) { | ||
throw new Error('Start coordinates: ' + startValid.message); | ||
} | ||
var endValid = helpers_1.validateCoordinates(end); | ||
if (endValid instanceof Error) { | ||
throw new Error('End coordinates: ' + endValid.message); | ||
} | ||
var radius = (unit.toLowerCase() === 'miles') ? 3963 : 6371; | ||
var dLat = helpers_1.toRad(end.lat - start.lat); | ||
var dLon = helpers_1.toRad(end.lng - start.lng); | ||
var lat1 = helpers_1.toRad(start.lat); | ||
var lat2 = helpers_1.toRad(end.lat); | ||
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + | ||
Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(lat1) * Math.cos(lat2); | ||
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); | ||
return (radius * c); | ||
}; | ||
/** | ||
* Get the geohash of a point. | ||
* @param coordinates Coordinates to hash. | ||
* @param precision Precision of hash desired, defaults to 10. | ||
* @returns Geohash of point. | ||
*/ | ||
Geokit.hash = function (coordinates, precision) { | ||
if (precision === void 0) { precision = 10; } | ||
var valid = helpers_1.validateCoordinates(coordinates); | ||
if (valid instanceof Error) { | ||
throw valid; | ||
} | ||
var hash = ''; | ||
var latRng = [-90, 90]; | ||
var lngRng = [-180, 180]; | ||
while (hash.length < precision) { | ||
var temp = 0; | ||
for (var i = 0; i < 5; i++) { | ||
var even = (((hash.length * 5) + i) % 2) == 0; | ||
var coord = (even) ? coordinates.lng : coordinates.lat; | ||
var range = (even) ? lngRng : latRng; | ||
var middle = (range[0] + range[1]) / 2; | ||
temp = (temp << 1) + helpers_1.getBit(coord, range); | ||
(coord > middle) ? range[0] = middle : range[1] = middle; | ||
} | ||
hash += helpers_1.base32(temp); | ||
} | ||
return hash; | ||
}; | ||
/** | ||
* Decodes a Geohash into a LatLngLiteral. | ||
* @param hash Geohash string. | ||
* @returns Coordinates to hash. | ||
*/ | ||
Geokit.decodeHash = function (hash) { | ||
var even = true; | ||
var latRng = [-90, 90]; | ||
var lngRng = [-180, 180]; | ||
var hashChars = hash.split(''); | ||
while (hashChars.length) { | ||
var chunk = helpers_1.decimalChunk(hashChars.shift()); | ||
for (var i = 0; i < 5; i++) { | ||
var mask = [16, 8, 4, 2, 1][i]; | ||
var range = (even) ? lngRng : latRng; | ||
var middle = (range[0] + range[1]) / 2; | ||
range[((chunk & mask) ? 0 : 1)] = middle; | ||
even = !even; | ||
} | ||
} | ||
return { lat: ((latRng[0] + latRng[1]) / 2), lng: ((lngRng[0] + lngRng[1]) / 2) }; | ||
}; | ||
return Geokit; | ||
}()); | ||
exports.Geokit = Geokit; | ||
var geokit=function(t){"use strict";function f(t){return t*Math.PI/180}function g(t){var r=[];if(90<t.lat&&r.push("Your latitude is greater than 90°"),t.lat<-90&&r.push("Your latitude is less than -90°"),180<t.lng&&r.push("Your longitude is greater than 180°"),t.lng<-180&&r.push("Your longitude is less than -180°"),0!==r.length)return new Error(r.join(" "))}var r=function(){function t(){}return t.distance=function(t,r,n){void 0===n&&(n="km");var a=g(t);if(a instanceof Error)throw new Error("Start coordinates: "+a.message);var e=g(r);if(e instanceof Error)throw new Error("End coordinates: "+e.message);var o="miles"===n.toLowerCase()?3963:6371,s=f(r.lat-t.lat),i=f(r.lng-t.lng),h=f(t.lat),u=f(r.lat),l=Math.sin(s/2)*Math.sin(s/2)+Math.sin(i/2)*Math.sin(i/2)*Math.cos(h)*Math.cos(u);return o*(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)))},t.hash=function(t,r){void 0===r&&(r=10);var n=g(t);if(n instanceof Error)throw n;for(var a,e="",o=[-90,90],s=[-180,180];e.length<r;){for(var i=0,h=0;h<5;h++){var u=(5*e.length+h)%2==0,l=u?t.lng:t.lat,f=u?s:o,c=(f[0]+f[1])/2;i=(i<<1)+(l<((a=f)[0]+a[1])/2?0:1),c<l?f[0]=c:f[1]=c}e+="0123456789bcdefghjkmnpqrstuvwxyz".charAt(i)}return e},t.decodeHash=function(t){for(var r,n=!0,a=[-90,90],e=[-180,180],o=t.split("");o.length;)for(var s=(r=o.shift(),"0123456789bcdefghjkmnpqrstuvwxyz".indexOf(r.toLowerCase())),i=0;i<5;i++){var h=[16,8,4,2,1][i],u=n?e:a,l=(u[0]+u[1])/2;u[s&h?0:1]=l,n=!n}return{lat:(a[0]+a[1])/2,lng:(e[0]+e[1])/2}},t}();return t.Geokit=r,t}({}); |
@@ -0,0 +0,0 @@ import { LatLngLiteral } from './interfaces'; |
export { Geokit } from './geokit'; | ||
export * from './interfaces'; |
{ | ||
"name": "geokit", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "An assortment of geolocation related tools, all packaged in one easy to use kit.", | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"scripts": { | ||
"build": "tsc", | ||
"build": "rm -rf ./dist && rollup -c", | ||
"docs": "typedoc --module node --target es5 --out docs/ src/", | ||
"test": "mocha --reporter spec --require ts-node/register 'tests/**/*.test.ts'", | ||
"start": "npm run build", | ||
"release:major": "npm run build && changelog -M && git add . && git commit -m 'chore(release): major version release' && npm version major && git push origin && git push origin --tags", | ||
"release:minor": "npm run build && changelog -m && git add . && git commit -m 'chore(release): minor version release' && npm version minor && git push origin && git push origin --tags", | ||
"release:patch": "npm run build && changelog -p && git add . && git commit -m 'chore(release): patch version release' && npm version patch && git push origin && git push origin --tags" | ||
"release:patch": "npm run build && changelog -p && git add . && git commit -m 'chore(release): patch version release' && npm version patch && git push origin && git push origin --tags", | ||
"prepare": "npm run build" | ||
}, | ||
"main": "dist/index.cjs.js", | ||
"module": "dist/index.esm.js", | ||
"typings": "dist/index.d.ts", | ||
"author": "Michael Solati mkslt04@gmail.com", | ||
"homepage": "https://github.com/MichaelSolati/geokit", | ||
"repository": { | ||
@@ -20,2 +23,7 @@ "type": "git", | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/MichaelSolati/geokit/issues" | ||
}, | ||
"readme": "README.md", | ||
"license": "ISC", | ||
"keywords": [ | ||
@@ -27,19 +35,25 @@ "geo", | ||
], | ||
"author": "Michael Solati", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/MichaelSolati/geokit/issues" | ||
}, | ||
"homepage": "https://github.com/MichaelSolati/geokit#readme", | ||
"files": [ | ||
"dist/**", | ||
"CHANGELOG.md", | ||
"LICENSE", | ||
"README.md", | ||
"package.json" | ||
], | ||
"devDependencies": { | ||
"@types/chai": "^4.1.3", | ||
"@types/mocha": "^5.2.1", | ||
"@types/chai": "^4.1.4", | ||
"@types/mocha": "^5.2.5", | ||
"chai": "^4.1.2", | ||
"firebase-tools": "^3.18.5", | ||
"firebase-tools": "^3.19.3", | ||
"generate-changelog": "^1.7.1", | ||
"mocha": "^5.2.0", | ||
"ts-node": "^6.0.5", | ||
"rollup": "^0.63.4", | ||
"rollup-plugin-commonjs": "^9.1.3", | ||
"rollup-plugin-node-resolve": "^3.3.0", | ||
"rollup-plugin-typescript2": "^0.16.1", | ||
"rollup-plugin-uglify": "^4.0.0", | ||
"ts-node": "^7.0.0", | ||
"typedoc": "^0.11.1", | ||
"typescript": "^2.9.1" | ||
"typescript": "^2.9.2" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21371
357
14
10
1