geographic
v0.2.0
Published
Geographic javascript utilities
Readme
Geographic
Geographicis a collection of abstractions that ease the pain of working with geographic features in JavaScript.
Installation
Node.js version 6.x.x or higher is required. To install geographic with yarn, run the command:
yarn add geographicAlternatively, it can be installed through npm:
npm install geographic --saveUsage
Point Class
Takes point with several possible formats:
- Object
latandlngpropertieslatandlongpropertieslatitudeandlongitudeproperties
- Array
- Normally ordered,
latitude, longitude - Inverted,
longitude, latitude
- Normally ordered,
- Browser Geolocation Object (with a
Positionconstructor) - An instance of the
Pointclass
(Note: If instantiated with an inverted array, it should be accompanied by the inverted: true property in the options object, or the boolean true)
It includes several useful getters:
coordinates: Outputs an object with coordinates in the{ latitude: ..., longitude: ... }format.short: Returns an object with the format{ lat: ..., long: ... }shortest: Returns the shortest coordinates format{ lat: ..., lng: ... }array: An array of coordinates in the format[ [latitude], [longitude] ].arrayInverted: An array of coordinates in the format[ [longitude], [latitude] ].
Path Class
Takes an array of at least two points. Any valid format to instantiate a Point is valid to instantiate a Path object.
Running Tests
To run tests on geographic locally, please clone the repository, run yarn install or npm install, followed by npm run test.
To run tests on the development mode (refreshing after each file save) run the command npm run test:dev.
Authorship
Developed by José Carneiro. Email me at [email protected].
License
geographic is licensed under the MIT License, meaning it's free to be used for any purpose.
