# geomodels

> Javascript 6 classes that are compatible with GeoJSON.

Latest version **1.2.0** (published 2018-04-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install geomodels
pnpm add geomodels
yarn add geomodels
bun add geomodels
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2018-04-20 |
| First published | 2018-03-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 26 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ramon Hagenaars |
| Maintainers | ramonhagenaars |
| Keywords | GeoJSON, models, classes, geometry, ES6, Javascript 6 |

## Links

- npm: https://www.npmjs.com/package/geomodels
- npm.io page: https://npm.io/package/geomodels

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.2.0 (latest) — 2018-04-20
- 1.1.1 — 2018-04-11
- 1.1.0 — 2018-04-11
- 1.0.1 — 2018-03-31
- 1.0.0 — 2018-03-31

## 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:
```
<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
```

---
_Source: https://npm.io/package/geomodels · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
