1.0.2 • Published 2 years ago

hk-area v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

hk-area

NPM Version NPM Install Size NPM Downloads

Version

Return the area (NT, Kowloon, HK, Island) of a given coorindates

🏠 Homepage

Install

npm install hk-area
yarn add hk-area

Example

import getHKArea from "hk-area";

let area = getHKArea(22.203350936422417, 113.86662909332935);
console.log(area); // HK

Methods

Summary

Details

getHKArea()

getHKArea(lat, long);

Parameters:

NameTypeRequiredDescription
latdoubleYesLatitude in WGS84 Coordinates
longdoubleYesLongitude in WGS84 Coordinates

Run tests

yarn test

Data Source

The boundaries data is based on HKGov's Hong Kong Geodata Store, specifically the Boundary Plan of District Lands Office.

The original boundaries definition is too large (1.5MB after minified), for sake of performance and package size, the boundaries definition are simplified using mapshaper. Therefore, some locations near the edge of the area (particularly between NT and Kowloon) might not be accurate. But it's good enough for most of the use case.

All coordinates has been converted from HK1980 to WGS84 coordinates.

Author

Github: @alanho

License

License: MIT


This README was generated with ❤️ by readme-md-generator