geospatial-kml 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/geospatial/kml/extended_data.rb +53 -0
- data/lib/geospatial/kml/placemark.rb +13 -3
- data/lib/geospatial/kml/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18312284c65ee000a87f9e381f813aef1da189375cf12fc69f672762a77a5b32
|
4
|
+
data.tar.gz: 665752cef2fcfb5687988d7fb0f02ef927d4af22a835f6b6552a7650bf901252
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a87c7cdebf784cddbb85450131eb0b36b3c344ac1885c7370b27945084c50fe047cffc66b0995b90a1585b0c9b629aec33400b6c8fb3285a2cadf51f79fd7e3c
|
7
|
+
data.tar.gz: 5fed5e536e727a5dec781c5d4a53c54d87529da23b28aea40f0b951dbdfc97c624f1769766c7d9986d00b9db5f282f10f10dee8f6c48e4bbbd96a23247d7a6a5
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'nokogiri'
|
22
|
+
|
23
|
+
require 'geospatial/location'
|
24
|
+
require 'geospatial/circle'
|
25
|
+
require 'geospatial/polygon'
|
26
|
+
|
27
|
+
module Geospatial
|
28
|
+
module KML
|
29
|
+
class ExtendedData
|
30
|
+
include Enumerable
|
31
|
+
|
32
|
+
def initialize(node)
|
33
|
+
@node = node
|
34
|
+
end
|
35
|
+
|
36
|
+
attr :node
|
37
|
+
|
38
|
+
def each
|
39
|
+
return to_enum unless block_given?
|
40
|
+
|
41
|
+
@node.css("SimpleData").each do |node|
|
42
|
+
yield node["name"].to_sym, node.text
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def [] key
|
47
|
+
if node = @node.css("SimpleData[name=#{key.to_s.dump}]")
|
48
|
+
node.text
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -24,6 +24,8 @@ require 'geospatial/location'
|
|
24
24
|
require 'geospatial/circle'
|
25
25
|
require 'geospatial/polygon'
|
26
26
|
|
27
|
+
require_relative 'extended_data'
|
28
|
+
|
27
29
|
module Geospatial
|
28
30
|
module KML
|
29
31
|
class Placemark
|
@@ -31,6 +33,8 @@ module Geospatial
|
|
31
33
|
@node = node
|
32
34
|
end
|
33
35
|
|
36
|
+
attr :node
|
37
|
+
|
34
38
|
def name
|
35
39
|
if node = @node.css("name").first
|
36
40
|
node.text.strip
|
@@ -43,6 +47,12 @@ module Geospatial
|
|
43
47
|
end
|
44
48
|
end
|
45
49
|
|
50
|
+
def extended_data
|
51
|
+
if node = @node.css("ExtendedData").first
|
52
|
+
ExtendedData.new(node)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
46
56
|
def bounding_circle
|
47
57
|
if look_at = @node.css("LookAt").first
|
48
58
|
longitude = look_at.css("longitude").first.text.to_f
|
@@ -55,10 +65,10 @@ module Geospatial
|
|
55
65
|
end
|
56
66
|
end
|
57
67
|
|
58
|
-
def polygons
|
59
|
-
return to_enum(:polygons) unless block_given?
|
68
|
+
def polygons(match = "Polygon, LineString")
|
69
|
+
return to_enum(:polygons, match) unless block_given?
|
60
70
|
|
61
|
-
@node.css(
|
71
|
+
@node.css(match).collect do |polygon_node|
|
62
72
|
coordinates_node = polygon_node.css("coordinates").first
|
63
73
|
|
64
74
|
text = coordinates_node.text.strip
|
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.5.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:
|
11
|
+
date: 2019-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: geospatial
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- Rakefile
|
97
97
|
- geospatial-kml.gemspec
|
98
98
|
- lib/geospatial/kml.rb
|
99
|
+
- lib/geospatial/kml/extended_data.rb
|
99
100
|
- lib/geospatial/kml/placemark.rb
|
100
101
|
- lib/geospatial/kml/reader.rb
|
101
102
|
- lib/geospatial/kml/version.rb
|
@@ -117,8 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
118
|
- !ruby/object:Gem::Version
|
118
119
|
version: '0'
|
119
120
|
requirements: []
|
120
|
-
|
121
|
-
rubygems_version: 2.7.8
|
121
|
+
rubygems_version: 3.0.4
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: Read geo data from keyhole markup language files.
|