geospatial-kml 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +42 -14
- data/lib/geospatial/kml/reader.rb +6 -1
- data/lib/geospatial/kml/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8acf89241d682ea66f5490e33b62d55573cdb82
|
4
|
+
data.tar.gz: 4dbfca3ded430a6cd00d23b0395321e7e86a76ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76e4edd14008f44a5654e9fa6dab4d110bf5f27c397c7dc29012ce4f8c64f5ea6f09ef156a45e6ebc7f8477afe4fd1e28f194990fe672e97c9eee0fbfaad2f59
|
7
|
+
data.tar.gz: 90599a422b5dcfe6f23f38450c3070626640dc80c3be64d9ad6f8835d48101b64b555293e3212d888bb147770555b858b35b486a06f8201ad94c662fcc133b87
|
data/README.md
CHANGED
@@ -1,36 +1,64 @@
|
|
1
|
-
# Geospatial
|
1
|
+
# Geospatial
|
2
2
|
|
3
|
-
|
3
|
+
This is a very basic gem for loading geometric primatives from KML files into geospatial data structures.
|
4
4
|
|
5
|
-
|
5
|
+
[![Build Status](https://secure.travis-ci.org/ioquatix/geospatial-kml.svg)](http://travis-ci.org/ioquatix/geospatial-kml)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/ioquatix/geospatial-kml.svg)](https://codeclimate.com/github/ioquatix/geospatial-kml)
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/ioquatix/geospatial-kml/badge.svg)](https://coveralls.io/r/ioquatix/geospatial-kml)
|
8
|
+
|
9
|
+
## Motivation
|
10
|
+
|
11
|
+
There are plenty of tools for generating polygons, lines, etc and KML is a standard export format. Therefore, it makes sense that geospatial can load these files.
|
6
12
|
|
7
13
|
## Installation
|
8
14
|
|
9
15
|
Add this line to your application's Gemfile:
|
10
16
|
|
11
|
-
|
12
|
-
gem 'geospatial-kml'
|
13
|
-
```
|
17
|
+
gem 'geospatial-kml'
|
14
18
|
|
15
19
|
And then execute:
|
16
20
|
|
17
|
-
|
21
|
+
$ bundle
|
18
22
|
|
19
23
|
Or install it yourself as:
|
20
24
|
|
21
|
-
|
25
|
+
$ gem install geospatial-kml
|
22
26
|
|
23
27
|
## Usage
|
24
28
|
|
25
|
-
|
29
|
+
The simplest way to use this library is to use the `Reader`:
|
26
30
|
|
27
|
-
|
31
|
+
reader = Geospatial::KML::Reader.load_file("test.kml")
|
32
|
+
reader.polygons -> [Geospatial::Polygon...]
|
28
33
|
|
29
|
-
|
34
|
+
## Contributing
|
30
35
|
|
31
|
-
|
36
|
+
1. Fork it
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create new Pull Request
|
32
41
|
|
33
|
-
##
|
42
|
+
## License
|
43
|
+
|
44
|
+
Released under the MIT license.
|
45
|
+
|
46
|
+
Copyright, 2017, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
|
47
|
+
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
49
|
+
of this software and associated documentation files (the "Software"), to deal
|
50
|
+
in the Software without restriction, including without limitation the rights
|
51
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
52
|
+
copies of the Software, and to permit persons to whom the Software is
|
53
|
+
furnished to do so, subject to the following conditions:
|
34
54
|
|
35
|
-
|
55
|
+
The above copyright notice and this permission notice shall be included in
|
56
|
+
all copies or substantial portions of the Software.
|
36
57
|
|
58
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
59
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
60
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
61
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
62
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
63
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
64
|
+
THE SOFTWARE.
|
@@ -19,6 +19,7 @@
|
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
21
|
require 'nokogiri'
|
22
|
+
require 'geospatial/polygon'
|
22
23
|
|
23
24
|
module Geospatial
|
24
25
|
module KML
|
@@ -38,9 +39,13 @@ module Geospatial
|
|
38
39
|
def polygons
|
39
40
|
@doc.css("Polygon").collect do |polygon_node|
|
40
41
|
coordinates_node = polygon_node.css("coordinates").first
|
42
|
+
|
41
43
|
text = coordinates_node.text.strip
|
44
|
+
coordinates = text.split(/\s+/).collect do |coordinate|
|
45
|
+
Vector.elements(coordinate.split(',').collect(&:to_f).first(2))
|
46
|
+
end
|
42
47
|
|
43
|
-
|
48
|
+
Polygon.new(coordinates)
|
44
49
|
end
|
45
50
|
end
|
46
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geospatial-kml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: geospatial
|