geoenclave
Version:
Validate if a point is inside a given polygon using GeoEnclave.
45 lines (44 loc) • 2.17 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const geoenclave_1 = require("geoenclave");
const polygonCoordinates = [
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ]
];
// Bounding coordinates of kathmandu valley
/* polygon coordinates(clipping boundry geojson) can be easily exported from https://export.hotosm.org/
in Geopackage .gpkg format */
const coordThamel = [85.3061304421, 27.709090497];
const coordCharikot = [86.0333332, 27.666664];
console.log((0, geoenclave_1.isPointInsidePolygon)(coordThamel, polygonCoordinates));
// returns true as thamel is inside the kathmandu valley
console.log((0, geoenclave_1.isPointInsidePolygon)(coordCharikot, polygonCoordinates));
// returns false as charikot is outside the kathmandu valley
console.log((0, geoenclave_1.countPointsInsidePolygon)([coordThamel], polygonCoordinates));
// returns 1 as thamel is inside the kathmandu valley
console.log((0, geoenclave_1.countPointsInsidePolygon)([coordCharikot], polygonCoordinates));
// returns 0 as charikot is outside the kathmandu valley