https://github.com/ramonhagenaars/geomodels
https://github.com/ramonhagenaars/geomodels
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ramonhagenaars/geomodels
- Owner: ramonhagenaars
- License: bsd-3-clause
- Created: 2018-03-31T20:04:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-20T09:30:23.000Z (over 7 years ago)
- Last Synced: 2024-12-30T21:17:56.318Z (10 months ago)
- Language: JavaScript
- Size: 34.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/ramonhagenaars/geomodels)
[](https://deepscan.io/dashboard#view=project&pid=2171&bid=11531)# geomodels
Javascript classes that can be parsed to and from GeoJson.## Installation
```
npm i geomodels
```## Example usage
```
const geoJSON = {
"type": "MultiPoint",
"coordinates": [[0, 0], [1, 1], [2, 2]]
};
const multiPoint = GeoModel.fromJSON(geoJSON);const mappedMultiPoint = multiPoint.mapSubElements(GeoPoint,
p => new GeoPoint(p.x + 1, p.y + 1, p.epsg));
```## Getting started
The GeoModels module can be used on the server-side with Node.js as well as in the browser.### Node apps
Import 'geomodels' in your script. For example:
```
const GeoPoint = require("geomodels").GeoPoint;
```You can now use the imported class. For example:
```
const p = new GeoPoint(52.090694, 5.121312);
console.log(p.toJSON());
```### Frontend apps
Include `geomodels.js` from the 'frontend' directory. For example:
``````
You can now use the geomodel classes. For example:
```
const GeoPoint = geomodels.GeoPoint;
const p = new GeoPoint(52.090694, 5.121312);
console.log(p.toJSON());
```## Linting, building, testing, code coverage
To start, make sure that all dependencies are met:
```
npm install
```To run all tasks subsequently, use:
```
npm run build
```For linting, use:
```
npm run lint
```For building, use:
```
npm run mkdirs
npm run build-frontend
npm run build-backend
```For testing you need to build first. Then use:
```
npm run test
```For analysing the code test coverage, use:
```
npm run coverage
```