Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/geocrystal/geojson_area
Calculate the area inside of any GeoJSON geometry
https://github.com/geocrystal/geojson_area
crystal geojson
Last synced: 2 days ago
JSON representation
Calculate the area inside of any GeoJSON geometry
- Host: GitHub
- URL: https://github.com/geocrystal/geojson_area
- Owner: geocrystal
- License: mit
- Created: 2020-03-29T14:15:11.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-30T07:55:01.000Z (7 months ago)
- Last Synced: 2024-05-06T00:04:51.121Z (6 months ago)
- Topics: crystal, geojson
- Language: Crystal
- Homepage:
- Size: 18.6 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GeoJSON::Area
![Crystal CI](https://github.com/geocrystal/geojson_area/workflows/Crystal%20CI/badge.svg)
[![License](https://img.shields.io/github/license/geocrystal/geojson_area.svg)](https://github.com/geocrystal/geojson_area/blob/master/LICENSE)Calculate the area inside of any [GeoJSON](https://github.com/geocrystal/geojson) geometry.
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
geojson_area:
github: geocrystal/geojson_area
```2. Run `shards install`
## Usage
```crystal
require "geojson_area"
```This adds `area` method for all `GeoJSON` objects:
```crystal
polygon = GeoJSON::Polygon.new([
[[-10.0, -10.0], [10.0, -10.0], [10.0, 10.0], [-10.0,-10.0]],
[[-1.0, -2.0], [3.0, -2.0], [3.0, 2.0], [-1.0,-2.0]]
])polygon.area
# => 2366726096087.807
```Also you can use `GeoJSON::Area.area()` directly.
This method accept any `GeoJSON` object, and returns contained area as square meters.```crystal
polygon = GeoJSON::Polygon.new([
[[-10.0, -10.0], [10.0, -10.0], [10.0, 10.0], [-10.0,-10.0]],
[[-1.0, -2.0], [3.0, -2.0], [3.0, 2.0], [-1.0,-2.0]]
])GeoJSON::Area.area(polygon)
# => 2366726096087.807
```## Contributing
1. Fork it ()
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request## Contributors
- [Anton Maminov](https://github.com/mamantoha) - creator and maintainer