An open API service indexing awesome lists of open source software.

https://github.com/ramonhagenaars/geomodels


https://github.com/ramonhagenaars/geomodels

Last synced: 8 months ago
JSON representation

Awesome Lists containing this project

README

          

[![Build Status](https://travis-ci.org/ramonhagenaars/geomodels.svg?branch=master)](https://travis-ci.org/ramonhagenaars/geomodels)
[![DeepScan grade](https://deepscan.io/api/projects/2171/branches/11531/badge/grade.svg)](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
```