wms_getcapabilities 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/test.rb +6 -0
- data/lib/wms_getcapabilities.rb +5 -1
- data/lib/wms_getcapabilities/geoserver.rb +24 -0
- data/lib/wms_getcapabilities/layer.rb +12 -0
- data/lib/wms_getcapabilities/parser.rb +34 -0
- data/lib/wms_getcapabilities/version.rb +1 -1
- data/wms_getcapabilities.gemspec +2 -0
- metadata +18 -3
data/examples/test.rb
ADDED
data/lib/wms_getcapabilities.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
module WmsGetcapabilities
|
2
|
+
|
3
|
+
class Geoserver
|
4
|
+
|
5
|
+
def initialize(url)
|
6
|
+
@root_url = url
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_capabilities
|
10
|
+
service = "WMS"
|
11
|
+
request = "GetCapabilities"
|
12
|
+
|
13
|
+
response = open("#{@root_url}/wms?SERVICE=#{service}&request=#{request}")
|
14
|
+
@parser = Parser.new(response)
|
15
|
+
end
|
16
|
+
|
17
|
+
def layers
|
18
|
+
layers = @parser.get_layers
|
19
|
+
layers
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module WmsGetcapabilities
|
2
|
+
|
3
|
+
class Parser
|
4
|
+
|
5
|
+
def initialize(xml)
|
6
|
+
@doc = ::Nokogiri::XML(xml)
|
7
|
+
end
|
8
|
+
|
9
|
+
def search(xpath)
|
10
|
+
@doc.xpath(xpath)
|
11
|
+
end
|
12
|
+
|
13
|
+
def custom_search(doc, xpath)
|
14
|
+
doc.xpath(xpath)
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_layers
|
18
|
+
layers = []
|
19
|
+
nodes = self.search("//xmlns:Layer")
|
20
|
+
nodes.each do |layer|
|
21
|
+
children = layer.children
|
22
|
+
name = children.at("Name").text
|
23
|
+
title = children.at("Title").text
|
24
|
+
crs = children.at("CRS").text
|
25
|
+
box = children.search("BoundingBox").last
|
26
|
+
bbox = [box.attr("minx"), box.attr("miny"), box.attr("maxx"), box.attr("maxy")]
|
27
|
+
l = Layer.new(name, title, crs, bbox)
|
28
|
+
layers << l
|
29
|
+
end
|
30
|
+
layers
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/wms_getcapabilities.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wms_getcapabilities
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,19 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
13
|
-
dependencies:
|
12
|
+
date: 2012-10-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: &2168822400 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2168822400
|
14
25
|
description: Interface between ruby and Geoserver WMS GetCapabilities
|
15
26
|
email:
|
16
27
|
- jchapron@dotgee.fr
|
@@ -22,7 +33,11 @@ files:
|
|
22
33
|
- Gemfile
|
23
34
|
- README.md
|
24
35
|
- Rakefile
|
36
|
+
- examples/test.rb
|
25
37
|
- lib/wms_getcapabilities.rb
|
38
|
+
- lib/wms_getcapabilities/geoserver.rb
|
39
|
+
- lib/wms_getcapabilities/layer.rb
|
40
|
+
- lib/wms_getcapabilities/parser.rb
|
26
41
|
- lib/wms_getcapabilities/version.rb
|
27
42
|
- wms_getcapabilities.gemspec
|
28
43
|
homepage: https://github.com/imperYaL/wms_getcapabilities
|