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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42ca9f834fa5b69ab7e4182d22bf8f31dbee103e
4
- data.tar.gz: 001bc30f9653e984c75b58f12203ae58e4724199
3
+ metadata.gz: a8acf89241d682ea66f5490e33b62d55573cdb82
4
+ data.tar.gz: 4dbfca3ded430a6cd00d23b0395321e7e86a76ba
5
5
  SHA512:
6
- metadata.gz: b3fbdca1449198492c2878a7d07e7d2751f18e533976ad785991b9263cedb3bcde7753eca821f19285da99eb2b27a9eebb340bc4fc7236216af6d1b2583bd97f
7
- data.tar.gz: 5a8b06c239f997014531e6802b697bb20a119954a29b9872c68a35e8120c7c499abbf98ad57a159d40ac17eafc7995d99929776d7e8ddbaeda1c8120770509ba
6
+ metadata.gz: 76e4edd14008f44a5654e9fa6dab4d110bf5f27c397c7dc29012ce4f8c64f5ea6f09ef156a45e6ebc7f8477afe4fd1e28f194990fe672e97c9eee0fbfaad2f59
7
+ data.tar.gz: 90599a422b5dcfe6f23f38450c3070626640dc80c3be64d9ad6f8835d48101b64b555293e3212d888bb147770555b858b35b486a06f8201ad94c662fcc133b87
data/README.md CHANGED
@@ -1,36 +1,64 @@
1
- # Geospatial::KML
1
+ # Geospatial
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/geospatial/kml`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ This is a very basic gem for loading geometric primatives from KML files into geospatial data structures.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
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
- ```ruby
12
- gem 'geospatial-kml'
13
- ```
17
+ gem 'geospatial-kml'
14
18
 
15
19
  And then execute:
16
20
 
17
- $ bundle
21
+ $ bundle
18
22
 
19
23
  Or install it yourself as:
20
24
 
21
- $ gem install geospatial-kml
25
+ $ gem install geospatial-kml
22
26
 
23
27
  ## Usage
24
28
 
25
- TODO: Write usage instructions here
29
+ The simplest way to use this library is to use the `Reader`:
26
30
 
27
- ## Development
31
+ reader = Geospatial::KML::Reader.load_file("test.kml")
32
+ reader.polygons -> [Geospatial::Polygon...]
28
33
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+ ## Contributing
30
35
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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
- ## Contributing
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
- Bug reports and pull requests are welcome on GitHub at https://github.com/Samuel Williams/geospatial-kml.
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
- text.split(/\s+/).collect{|coordinate| coordinate.split(',').collect(&:to_f)}
48
+ Polygon.new(coordinates)
44
49
  end
45
50
  end
46
51
  end
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Geospatial
22
22
  module KML
23
- VERSION = "0.1.0"
23
+ VERSION = "0.2.0"
24
24
  end
25
25
  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.1.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-03 00:00:00.000000000 Z
11
+ date: 2017-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: geospatial