1.2.0 • Published 8 years ago
geomodels v1.2.0
geomodels
Javascript classes that can be parsed to and from GeoJson.
Installation
npm i geomodelsExample 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 installTo run all tasks subsequently, use:
npm run buildFor linting, use:
npm run lintFor building, use:
npm run mkdirs
npm run build-frontend
npm run build-backendFor testing you need to build first. Then use:
npm run testFor analysing the code test coverage, use:
npm run coverage