-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
91 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# compiled output | ||
/dist | ||
/node_modules | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# OS | ||
.DS_Store | ||
|
||
# Tests | ||
/coverage | ||
/.nyc_output | ||
|
||
# IDEs and editors | ||
/.idea | ||
.project | ||
.classpath | ||
.c9/ | ||
*.launch | ||
.settings/ | ||
*.sublime-workspace | ||
|
||
# IDE - VSCode | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
inside = (point, polygon) => { | ||
const inside = (point: [number, number], polygon: [number, number][]): boolean => { | ||
const x = point[0], y = point[1]; | ||
|
||
let inside = false; | ||
let isInside = false; | ||
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) { | ||
const xi = polygon[i][0], yi = polygon[i][1]; | ||
const xj = polygon[j][0], yj = polygon[j][1]; | ||
|
||
const intersect = ((yi > y) != (yj > y)) | ||
const isIntersect = ((yi > y) !== (yj > y)) | ||
&& (x < (xj - xi) * (y - yi) / (yj - yi) + xi); | ||
if (intersect) inside = !inside; | ||
if (isIntersect) isInside = !isInside; | ||
} | ||
return inside; | ||
return isInside; | ||
}; | ||
|
||
module.exports = { inside }; | ||
export { inside }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
{ | ||
"name": "loc-bind", | ||
"version": "1.0.6", | ||
"description": "Package that takes lat long array and validates geocoordinates if that lies inside it.", | ||
"main": "index.js", | ||
"name": "geoenclave", | ||
"version": "2.0.0", | ||
"description": "Validate if a point is inside a given polygon using GeoEnclave.", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [ | ||
"loc-bind", | ||
"location-binder", | ||
"geoenclave", | ||
"geocoordinate", | ||
"validation", | ||
"location security", | ||
"npm package", | ||
"location-validation" | ||
], | ||
"author": "Sandip Basnet", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/mondyfy/loc-bind" | ||
"url": "git+https://github.com/mondyfy/geoenclave" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"typescript": "^5.1.6" | ||
}, | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES6", | ||
"module": "CommonJS", | ||
"outDir": "./dist", | ||
"strict": true, | ||
"esModuleInterop": true | ||
}, | ||
"exclude": [ | ||
"node_modules", | ||
"dist" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
typescript@^4.4.3: | ||
version "4.9.5" | ||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" | ||
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== |