1.2.0 • Published 6 years ago

geomodels v1.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

Build Status DeepScan grade

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:

<script type="text/javascript" src="node_modules/geomodels/dist/frontend/geomodels.js"></script>

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