From 8e534b6b19169ea98651b156c259353aa29ab2e7 Mon Sep 17 00:00:00 2001 From: Anton Maminov Date: Sun, 29 Mar 2020 18:31:57 +0300 Subject: [PATCH] update readme --- README.md | 25 +++++++++++++++++-------- spec/geojson_area_spec.cr | 10 ++++++++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index eef889d..dc4af3d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ -# geojson_area +# GeoJSON::Area -TODO: Write a description here +[![Build Status](https://travis-ci.org/geocrystal/geojson_area.svg?branch=master)](https://travis-ci.org/geocrystal/geojson_area) +[![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 @@ -9,7 +12,7 @@ TODO: Write a description here ```yaml dependencies: geojson_area: - github: your-github-user/geojson_area + github: geocrystal/geojson_area ``` 2. Run `shards install` @@ -20,15 +23,21 @@ TODO: Write a description here require "geojson_area" ``` -TODO: Write usage instructions here +`GeoJSON::Area.area()` accept any `GeoJSON` object, and returns contained area as square meters. -## Development +```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]] +]) -TODO: Write development instructions here +GeoJSON::Area.area(polygon) +# => 2366726096087.807 +``` ## Contributing -1. Fork it () +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`) @@ -36,4 +45,4 @@ TODO: Write development instructions here ## Contributors -- [Anton Maminov](https://github.com/your-github-user) - creator and maintainer +- [Anton Maminov](https://github.com/mamantoha) - creator and maintainer diff --git a/spec/geojson_area_spec.cr b/spec/geojson_area_spec.cr index 7b62fae..6ef0faf 100644 --- a/spec/geojson_area_spec.cr +++ b/spec/geojson_area_spec.cr @@ -48,4 +48,14 @@ describe GeoJSON::Area do area.zero?.should be_truthy end + + it "computes the area of polygon from readme" do + 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]], + ]) + + area = GeoJSON::Area.area(polygon) + area.should eq(2366726096087.807) + end end