colincasey-arcserver.rb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ nbproject
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Colin Casey
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,7 @@
1
+ = arcserver.rb
2
+
3
+ Description goes here.
4
+
5
+ == Copyright
6
+
7
+ Copyright (c) 2009 Colin Casey. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "arcserver.rb"
8
+ gem.summary = %Q{TODO}
9
+ gem.email = "casey.colin@gmail.com"
10
+ gem.homepage = "http://github.com/colincasey/arcserver.rb"
11
+ gem.authors = ["Colin Casey"]
12
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
+ end
14
+
15
+ rescue LoadError
16
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
17
+ end
18
+
19
+ require 'rake/testtask'
20
+ Rake::TestTask.new(:test) do |test|
21
+ test.libs << 'lib' << 'test'
22
+ test.pattern = 'test/**/*_test.rb'
23
+ test.verbose = true
24
+ end
25
+
26
+ begin
27
+ require 'rcov/rcovtask'
28
+ Rcov::RcovTask.new do |test|
29
+ test.libs << 'test'
30
+ test.pattern = 'test/**/*_test.rb'
31
+ test.verbose = true
32
+ end
33
+ rescue LoadError
34
+ task :rcov do
35
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
36
+ end
37
+ end
38
+
39
+
40
+ task :default => :test
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ if File.exist?('VERSION.yml')
45
+ config = YAML.load(File.read('VERSION.yml'))
46
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
47
+ else
48
+ version = ""
49
+ end
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "arcserver.rb #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
56
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,55 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{arcserver.rb}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Colin Casey"]
9
+ s.date = %q{2009-07-22}
10
+ s.email = %q{casey.colin@gmail.com}
11
+ s.extra_rdoc_files = [
12
+ "LICENSE",
13
+ "README.rdoc"
14
+ ]
15
+ s.files = [
16
+ ".document",
17
+ ".gitignore",
18
+ "LICENSE",
19
+ "README.rdoc",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "arcserver.rb.gemspec",
23
+ "lib/arcserver.rb",
24
+ "lib/arcserver/map_server.rb",
25
+ "lib/arcserver/rest/map_server.rb",
26
+ "lib/arcserver/soap/map_server.rb",
27
+ "lib/arcserver/url_helper.rb",
28
+ "test/functional/soap/map_server_test.rb",
29
+ "test/functional/soap/portland_landbase_get_legend_info.yml",
30
+ "test/test_helper.rb",
31
+ "test/unit/map_server_test.rb",
32
+ "test/unit/url_helper_test.rb"
33
+ ]
34
+ s.homepage = %q{http://github.com/colincasey/arcserver.rb}
35
+ s.rdoc_options = ["--charset=UTF-8"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.4}
38
+ s.summary = %q{TODO}
39
+ s.test_files = [
40
+ "test/test_helper.rb",
41
+ "test/functional/soap/map_server_test.rb",
42
+ "test/unit/url_helper_test.rb",
43
+ "test/unit/map_server_test.rb"
44
+ ]
45
+
46
+ if s.respond_to? :specification_version then
47
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
+ else
52
+ end
53
+ else
54
+ end
55
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ require 'arcserver/rest/map_server'
3
+ require 'arcserver/soap/map_server'
4
+ require 'forwardable'
5
+
6
+ module ArcServer
7
+ class MapServer
8
+ include UrlHelper
9
+ extend Forwardable
10
+
11
+ attr_reader :soap_service
12
+ def_delegators :soap_service, :get_default_map_name, :get_legend_info
13
+
14
+ attr_reader :rest_service
15
+ def_delegators :rest_service, :export
16
+
17
+ def initialize(url, opts = {})
18
+ @soap_service = opts[:soap_service] || SOAP::MapServer.new(url)
19
+ @rest_service = opts[:rest_service] || REST::MapServer.new(url)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ require 'httparty'
3
+
4
+ module ArcServer
5
+ module REST
6
+ class MapServer
7
+ attr_reader :url
8
+
9
+ def initialize(url)
10
+ @url = url
11
+ end
12
+
13
+ def export(opts = {})
14
+ query = {
15
+ :bbox => opts[:bbox],
16
+ :f => opts[:f] || :image,
17
+ :format => opts[:format] || :png24,
18
+ :transparent => opts[:transparent] || true,
19
+ :size => opts[:size],
20
+ :dpi => opts[:dpi]
21
+ }
22
+ HTTParty.get("#{url}/export", :query => query)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,87 @@
1
+ # encoding: utf-8
2
+ require 'handsoap'
3
+
4
+ module ArcServer
5
+ module SOAP
6
+ class MapServer < Handsoap::Service
7
+ on_create_document do |doc|
8
+ doc.alias "env", "http://schemas.xmlsoap.org/soap/envelope/"
9
+ doc.alias "ns", "http://www.esri.com/schemas/ArcGIS/9.3"
10
+ end
11
+
12
+ def on_before_dispatch
13
+ self.class.instance_variable_set(:@uri, @soap_url)
14
+ end
15
+
16
+ def initialize(soap_url, protocol_version=2)
17
+ @soap_url = soap_url
18
+ self.class.instance_variable_set(:@protocol_version, protocol_version)
19
+ end
20
+
21
+ def get_default_map_name
22
+ response = invoke("ns:GetDefaultMapName")
23
+ node = response.document.xpath('//tns:GetDefaultMapNameResponse/Result', ns).first
24
+ parse_default_map_name_result(node)
25
+ end
26
+
27
+ def get_legend_info(args = {})
28
+ response = invoke("ns:GetLegendInfo") do |message|
29
+ message.add "MapName", args[:map_name]
30
+ end
31
+ node = response.document.xpath('//tns:GetLegendInfoResponse/Result', ns).first
32
+ parse_legend_info_result(node)
33
+ end
34
+
35
+ private
36
+ def ns
37
+ { 'tns', 'http://www.esri.com/schemas/ArcGIS/9.3' }
38
+ end
39
+
40
+ # helpers
41
+ def parse_default_map_name_result(node)
42
+ xml_to_str(node, './text()')
43
+ end
44
+
45
+ def parse_legend_info_result(node)
46
+ node.xpath('./MapServerLegendInfo', ns).collect { |child| parse_map_server_legend_info(child) }
47
+ end
48
+
49
+ def parse_map_server_legend_info(node)
50
+ {
51
+ :layer_id => xml_to_int(node, "./LayerID/text()"),
52
+ :name => xml_to_str(node, "./Name/text()"),
53
+ :legend_groups => node.xpath('./LegendGroups/MapServerLegendGroup', ns).collect { |child| parse_map_server_legend_group(child) }
54
+ }
55
+ end
56
+
57
+ def parse_map_server_legend_group(node)
58
+ {
59
+ :heading => xml_to_str(node, "./Heading/text()"),
60
+ :legend_classes => node.xpath("./LegendClasses/MapServerLegendClass", ns).collect { |child| parse_map_server_legend_class(child) }
61
+ }
62
+ end
63
+
64
+ def parse_map_server_legend_class(node)
65
+ {
66
+ :label => xml_to_str(node, "./Label/text()"),
67
+ :descriptions => xml_to_str(node, "./Description/text()"),
68
+ :symbol_image => {
69
+ :image_data => xml_to_str(node, "./SymbolImage/ImageData/text()"),
70
+ :image_url => xml_to_str(node, "./SymbolImage/ImageURL/text()"),
71
+ :image_height => xml_to_int(node, "./SymbolImage/ImageHeight/text()"),
72
+ :image_width => xml_to_int(node, "./SymbolImage/ImageWidth/text()"),
73
+ :image_dpi => xml_to_int(node, "./SymbolImage/ImageDPI/text()")
74
+ },
75
+ :transparent_color => {
76
+ :use_windows_dithering => xml_to_bool(node, "./TransparentColor/UseWindowsDithering/text()"),
77
+ :alpha_value => xml_to_int(node, "./TransparentColor/AlphaValue/text()"),
78
+ :red => xml_to_int(node, "./TransparentColor/Red/text()"),
79
+ :green => xml_to_int(node, "./TransparentColor/Green/text()"),
80
+ :blue => xml_to_int(node, "./TransparentColor/Blue/text()")
81
+ }
82
+ }
83
+ end
84
+
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ module ArcServer
4
+ module UrlHelper
5
+ def rest_service?(url)
6
+ url.to_s.match(/ArcGIS\/rest\/.*/)
7
+ end
8
+
9
+ def soap_service?(url)
10
+ url.to_s.match(/ArcGIS\/(?!rest\/).*/)
11
+ end
12
+
13
+ def to_rest(url)
14
+ rest_service?(url) ? url : url.sub('/ArcGIS/', '/ArcGIS/rest/')
15
+ end
16
+
17
+ def to_soap(url)
18
+ soap_service?(url) ? url : url.sub('/ArcGIS/rest/', '/ArcGIS/')
19
+ end
20
+ end
21
+ end
data/lib/arcserver.rb ADDED
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+ require 'arcserver/url_helper'
3
+ require 'arcserver/map_server'
@@ -0,0 +1,169 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/../../test_helper'
3
+ require 'yaml'
4
+
5
+ #ArcServer::SOAP::MapServer.logger = $stdout
6
+
7
+ class ArcServer::SOAP::MapServerTest < Test::Unit::TestCase
8
+ should "be able to use map services at two different locations" do
9
+ service1 = ArcServer::SOAP::MapServer.new('http://sampleserver1.arcgisonline.com/ArcGIS/services/Portland/ESRI_LandBase_WebMercator/MapServer')
10
+ service2 = ArcServer::SOAP::MapServer.new('http://sampleserver1.arcgisonline.com/ArcGIS/services/Demographics/ESRI_Census_USA/MapServer')
11
+
12
+ name1 = service1.get_default_map_name
13
+ name2 = service2.get_default_map_name
14
+
15
+ assert_equal "Portland", name1
16
+ assert_equal "Layers", name2
17
+ end
18
+
19
+ context "using ESRI's sample Portland Landbase service" do
20
+ setup do
21
+ @service = ArcServer::SOAP::MapServer.new('http://sampleserver1.arcgisonline.com/ArcGIS/services/Portland/ESRI_LandBase_WebMercator/MapServer')
22
+ end
23
+
24
+ should "get the default map name" do
25
+ assert_equal "Portland", @service.get_default_map_name
26
+ end
27
+
28
+ should "get the legend info" do
29
+ legend_info = @service.get_legend_info(:map_name => 'Portland')
30
+ legend_info.each do |item|
31
+ layer_assertion = "assert_legend_info_result_layer_#{item[:layer_id]}".to_sym
32
+ if respond_to?(layer_assertion)
33
+ send(layer_assertion, item)
34
+ else
35
+ raise "no assertions set for legend info with layer_id=#{item[:layer_id]}"
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ # legend info assertion helpers
42
+ def assert_legend_info_result_layer_1(item)
43
+ expected = {
44
+ :layer_id => 1,
45
+ :name => 'Zoomed in',
46
+ :legend_groups => [{
47
+ :legend_classes => [{
48
+ :symbol_image => {
49
+ :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nR0lEQVR4nGP89/8/AzUBC4wR4O9PkckbNm5kZGBgYGCihmHIZrAgC8JsIdcwBgaoC6kJRg0cNXAw\nGIiSU6iRBanuQkZqF18AsvET5O8fag8AAAAASUVORK5CYII=\n"
50
+ }
51
+ }]
52
+ }]
53
+ }
54
+ assert_legend_info_result_layer(expected, item)
55
+ end
56
+
57
+ def assert_legend_info_result_layer_2(item)
58
+ expected = {
59
+ :layer_id => 2,
60
+ :name => 'Zoomed out',
61
+ :legend_groups => [{
62
+ :legend_classes => [{
63
+ :symbol_image => {
64
+ :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nPklEQVR4nGP89/8/AzUBE1VNY2BgYIExAvz9KXbqho0bGVnQBcg1DOYgqnt51MBRA4elgShZjxr5\nmZHaxRcATwAQChHiw9IAAAAASUVORK5CYII=\n"
65
+ }
66
+ }]
67
+ }]
68
+ }
69
+ assert_legend_info_result_layer(expected, item)
70
+ end
71
+
72
+ def assert_legend_info_result_layer_3(item)
73
+ expected = {
74
+ :layer_id => 3,
75
+ :name => 'Buildings',
76
+ :legend_groups => [{
77
+ :legend_classes => [{
78
+ :symbol_image => {
79
+ :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nNElEQVR4nGP89/8/AzUBE1VNY2BgYIExZtTVUeTUjKYmRgYGGrhw1MBRA0cNJAYwDvrSBgCGTgoZ\ncGsDFQAAAABJRU5ErkJggg==\n"
80
+ }
81
+ }]
82
+ }]
83
+ }
84
+ assert_legend_info_result_layer(expected, item)
85
+ end
86
+
87
+ def assert_legend_info_result_layer_4(item)
88
+ expected = {
89
+ :layer_id => 4,
90
+ :name => 'Zoning',
91
+ :legend_groups => [{
92
+ :legend_classes => [{
93
+ :label => 'Commercial',
94
+ :symbol_image => {
95
+ :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nNElEQVR4nGP89/8/AzUBE1VNY2BgYIExXjAyUuRUif//GRkYaODCUQNHDRw1kBjAOOhLGwBbzgoZ\npkxTgAAAAABJRU5ErkJggg==\n"
96
+ }
97
+ }, {
98
+ :label => 'Industrial',
99
+ :symbol_image => {
100
+ :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nNElEQVR4nGP89/8/AzUBE1VNY2BgYIEx2hhXUuTUqv/hjAwMNHDhqIGjBo4aSAxgHPSlDQBtTgoZ\nvbcuLAAAAABJRU5ErkJggg==\n"
101
+ }
102
+ }, {
103
+ :label => 'Residential',
104
+ :symbol_image => {
105
+ :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nNElEQVR4nGP89/8/AzUBE1VNY2BgYIExGBlKKHLqf4YeRgYGGrhw1MBRA0cNJAYwDvrSBgAaUgkZ\nJEjqtwAAAABJRU5ErkJggg==\n"
106
+ }
107
+ }, {
108
+ :label => 'Mixed use',
109
+ :symbol_image => {
110
+ :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nNElEQVR4nGP89/8/AzUBE1VNY2BgYIExvuW5UORUrkl7GBkYaODCUQNHDRw1kBjAOOhLGwCLTgoZ\nUbp19QAAAABJRU5ErkJggg==\n"
111
+ }
112
+ }, {
113
+ :label => 'Parks and open space',
114
+ :symbol_image => {
115
+ :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nOUlEQVR4nGP89/8/AzUBE1VNY2BgYIExGBkYKHLqfwYGRgYGGrhw1MBRA0cNJAbA8zIsL1IKqO5C\nAJdcBiBRj7wXAAAAAElFTkSuQmCC\n"
116
+ }
117
+ }, {
118
+ :label => 'Rural',
119
+ :symbol_image => {
120
+ :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nNElEQVR4nGP89/8/AzUBE1VNY2BgYIExus+lU+TUUqOZjAwMNHDhqIGjBo4aSAxgHPSlDQCRTgoZ\nWZnonwAAAABJRU5ErkJggg==\n"
121
+ }
122
+ }]
123
+ }]
124
+ }
125
+ assert_legend_info_result_layer(expected, item)
126
+ end
127
+
128
+ def assert_legend_info_result_layer(expected, actual)
129
+ assert_equal expected[:layer_id], actual[:layer_id]
130
+ assert_equal expected[:name], actual[:name]
131
+ # check the legend groups
132
+ assert_equal expected[:legend_groups].length, actual[:legend_groups].length
133
+ actual[:legend_groups].each do |legend_group|
134
+ assert_legend_group expected[:legend_groups].shift, legend_group
135
+ end
136
+ end
137
+
138
+ def assert_legend_group(expected, actual)
139
+ assert_equal expected[:heading], actual[:heading]
140
+ # check the legend classes
141
+ assert_equal expected[:legend_classes].length, actual[:legend_classes].length
142
+ actual[:legend_classes].each do |legend_class|
143
+ assert_legend_class expected[:legend_classes].shift, legend_class
144
+ end
145
+ end
146
+
147
+ def assert_legend_class(expected, actual)
148
+ assert_equal expected[:label], actual[:label]
149
+ assert_equal expected[:description], actual[:description]
150
+ assert_symbol_image(expected[:symbol_image] || {}, actual[:symbol_image])
151
+ assert_transparent_color(expected[:transparent_color] || {}, actual[:transparent_color])
152
+ end
153
+
154
+ def assert_symbol_image(expected, actual)
155
+ assert_equal expected[:image_data], actual[:image_data]
156
+ assert_equal expected[:image_url], actual[:image_url]
157
+ assert_equal expected[:image_height] || 16, actual[:image_height]
158
+ assert_equal expected[:image_width] || 20, actual[:image_width]
159
+ assert_equal expected[:image_dpi] || 96, actual[:image_dpi]
160
+ end
161
+
162
+ def assert_transparent_color(expected, actual)
163
+ assert_equal expected[:use_windows_dithering] || true, actual[:use_windows_dithering]
164
+ assert_equal expected[:alpha_value] || 255, actual[:alpha_value]
165
+ assert_equal expected[:red] || 254, actual[:red]
166
+ assert_equal expected[:green] || 255, actual[:green]
167
+ assert_equal expected[:blue] || 255, actual[:blue]
168
+ end
169
+ end
@@ -0,0 +1,134 @@
1
+ ---
2
+ symbol_image_defaults: &symbol_image_defaults
3
+ :image_data:
4
+ :image_url:
5
+ :image_height: 16
6
+ :image_width: 20
7
+ :image_dpi: 96
8
+ transparent_color_defaults: &transparent_color_defaults
9
+ :use_windows_dithering: true
10
+ :alpha_value: 255
11
+ :red: 254
12
+ :green: 255
13
+ :blue: 255
14
+
15
+ get_legend_info_result:
16
+ - :layer_id: 1
17
+ :name: Zoomed in
18
+ :legend_groups:
19
+ - :heading:
20
+ :legend_classes:
21
+ - :label:
22
+ :description:
23
+ :symbol_image:
24
+ <<: *symbol_image_defaults
25
+ :image_data: |
26
+ iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
27
+ R0lEQVR4nGP89/8/AzUBC4wR4O9PkckbNm5kZGBgYGCihmHIZrAgC8JsIdcwBgaoC6kJRg0cNXAw
28
+ GIiSU6iRBanuQkZqF18AsvET5O8fag8AAAAASUVORK5CYII=
29
+
30
+ :transparent_color:
31
+ <<: *transparent_color_defaults
32
+ - :layer_id: 2
33
+ :name: Zoomed out
34
+ :legend_groups:
35
+ - :heading:
36
+ :legend_classes:
37
+ - :label:
38
+ :description:
39
+ :symbol_image:
40
+ <<: *symbol_image_defaults
41
+ :image_data: |
42
+ iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
43
+ PklEQVR4nGP89/8/AzUBE1VNY2BgYIExAvz9KXbqho0bGVnQBcg1DOYgqnt51MBRA4elgShZjxr5
44
+ mZHaxRcATwAQChHiw9IAAAAASUVORK5CYII=
45
+
46
+ :transparent_color:
47
+ <<: *transparent_color_defaults
48
+ - :layer_id: 3
49
+ :name: Buildings
50
+ :legend_groups:
51
+ - :heading:
52
+ :legend_classes:
53
+ - :label:
54
+ :description:
55
+ :symbol_image:
56
+ <<: *symbol_image_defaults
57
+ :image_data: |
58
+ iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
59
+ NElEQVR4nGP89/8/AzUBE1VNY2BgYIExZtTVUeTUjKYmRgYGGrhw1MBRA0cNJAYwDvrSBgCGTgoZ
60
+ cGsDFQAAAABJRU5ErkJggg==
61
+
62
+ :transparent_color:
63
+ <<: *transparent_color_defaults
64
+ - :layer_id: 4
65
+ :name: Zoning
66
+ :legend_groups:
67
+ - :heading:
68
+ :legend_classes:
69
+ - :label: Commercial
70
+ :description:
71
+ :symbol_image:
72
+ <<: *symbol_image_defaults
73
+ :image_data: |
74
+ iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
75
+ NElEQVR4nGP89/8/AzUBE1VNY2BgYIExXjAyUuRUif//GRkYaODCUQNHDRw1kBjAOOhLGwBbzgoZ
76
+ pkxTgAAAAABJRU5ErkJggg==
77
+
78
+ :transparent_color:
79
+ <<: *transparent_color_defaults
80
+ - :label: Industrial
81
+ :description:
82
+ :symbol_image:
83
+ <<: *symbol_image_defaults
84
+ :image_data: |
85
+ iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
86
+ NElEQVR4nGP89/8/AzUBE1VNY2BgYIEx2hhXUuTUqv/hjAwMNHDhqIGjBo4aSAxgHPSlDQBtTgoZ
87
+ vbcuLAAAAABJRU5ErkJggg==
88
+
89
+ :transparent_color:
90
+ <<: *transparent_color_defaults
91
+ - :label: Residential
92
+ :description:
93
+ :symbol_image:
94
+ <<: *symbol_image_defaults
95
+ :image_data: |
96
+ iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
97
+ NElEQVR4nGP89/8/AzUBE1VNY2BgYIExGBlKKHLqf4YeRgYGGrhw1MBRA0cNJAYwDvrSBgAaUgkZ
98
+ JEjqtwAAAABJRU5ErkJggg==
99
+
100
+ :transparent_color:
101
+ <<: *transparent_color_defaults
102
+ - :label: Mixed use
103
+ :description:
104
+ :symbol_image:
105
+ <<: *symbol_image_defaults
106
+ :image_data: |
107
+ iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
108
+ NElEQVR4nGP89/8/AzUBE1VNY2BgYIExvuW5UORUrkl7GBkYaODCUQNHDRw1kBjAOOhLGwCLTgoZ
109
+ Ubp19QAAAABJRU5ErkJggg==
110
+
111
+ :transparent_color:
112
+ <<: *transparent_color_defaults
113
+ - :label: Parks and open space
114
+ :description:
115
+ :symbol_image:
116
+ <<: *symbol_image_defaults
117
+ :image_data: |
118
+ iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
119
+ OUlEQVR4nGP89/8/AzUBE1VNY2BgYIExGBkYKHLqfwYGRgYGGrhw1MBRA0cNJAbA8zIsL1IKqO5C
120
+ AJdcBiBRj7wXAAAAAElFTkSuQmCC
121
+
122
+ :transparent_color:
123
+ <<: *transparent_color_defaults
124
+ - :label: Rural
125
+ :description:
126
+ :symbol_image:
127
+ <<: *symbol_image_defaults
128
+ :image_data: |
129
+ iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
130
+ NElEQVR4nGP89/8/AzUBE1VNY2BgYIExus+lU+TUUqOZjAwMNHDhqIGjBo4aSAxgHPSlDQCRTgoZ
131
+ WZnonwAAAABJRU5ErkJggg==
132
+
133
+ :transparent_color:
134
+ <<: *transparent_color_defaults
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+ require 'rubygems'
3
+ require 'test/unit'
4
+ require 'shoulda'
5
+ require 'mocha'
6
+
7
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
9
+ require 'arcserver'
10
+
11
+ class Test::Unit::TestCase
12
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/../test_helper'
3
+
4
+ class ArcServer::MapServerTest < Test::Unit::TestCase
5
+ context "verifying delegation of actions to the SOAP service" do
6
+ setup do
7
+ @mock_soap_service = mock
8
+ @map_server = ArcServer::MapServer.new('http://www.map.server/', :soap_service => @mock_soap_service)
9
+ end
10
+
11
+ should "forward get_default_map_name" do
12
+ @mock_soap_service.expects(:get_default_map_name => nil)
13
+ @map_server.get_default_map_name
14
+ end
15
+
16
+ should "forward get_legend_info" do
17
+ @mock_soap_service.expects(:get_legend_info => nil)
18
+ @map_server.get_legend_info
19
+ end
20
+ end
21
+
22
+ context "verifying delegation of actions to the REST service" do
23
+ setup do
24
+ @mock_rest_service = mock
25
+ @map_server = ArcServer::MapServer.new('http://www.map.server/', :rest_service => @mock_rest_service)
26
+ end
27
+
28
+ should "forward get_default_map_name" do
29
+ @mock_rest_service.expects(:export => nil)
30
+ @map_server.export
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/../test_helper'
3
+
4
+ class ArcServer::UrlHelperTest < Test::Unit::TestCase
5
+ include ArcServer::UrlHelper
6
+
7
+ context "when given a rest service url" do
8
+ setup do
9
+ @url = 'http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer'
10
+ end
11
+
12
+ should "be able to recognize it as a rest service" do
13
+ assert rest_service?(@url)
14
+ end
15
+
16
+ should "not be mistaken for a soap service" do
17
+ assert !soap_service?(@url)
18
+ end
19
+
20
+ should "be able to convert to soap service url" do
21
+ soap_url = to_soap(@url)
22
+ assert soap_service?(soap_url)
23
+ assert !rest_service?(soap_url)
24
+ end
25
+ end
26
+
27
+ context "when given a soap service url" do
28
+ setup do
29
+ @url = 'http://sampleserver1.arcgisonline.com/ArcGIS/services/Demographics/ESRI_Census_USA/MapServer'
30
+ end
31
+
32
+ should "be able to recognize it as a soap service" do
33
+ assert soap_service?(@url)
34
+ end
35
+
36
+ should "not be mistaken for a rest service" do
37
+ assert !rest_service?(@url)
38
+ end
39
+
40
+ should "be able to convert to rest service url" do
41
+ rest_url = to_rest(@url)
42
+ assert rest_service?(rest_url)
43
+ assert !soap_service?(rest_url)
44
+ end
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: colincasey-arcserver.rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Colin Casey
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-22 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: casey.colin@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.rdoc
25
+ files:
26
+ - .document
27
+ - .gitignore
28
+ - LICENSE
29
+ - README.rdoc
30
+ - Rakefile
31
+ - VERSION
32
+ - arcserver.rb.gemspec
33
+ - lib/arcserver.rb
34
+ - lib/arcserver/map_server.rb
35
+ - lib/arcserver/rest/map_server.rb
36
+ - lib/arcserver/soap/map_server.rb
37
+ - lib/arcserver/url_helper.rb
38
+ - test/functional/soap/map_server_test.rb
39
+ - test/functional/soap/portland_landbase_get_legend_info.yml
40
+ - test/test_helper.rb
41
+ - test/unit/map_server_test.rb
42
+ - test/unit/url_helper_test.rb
43
+ has_rdoc: false
44
+ homepage: http://github.com/colincasey/arcserver.rb
45
+ post_install_message:
46
+ rdoc_options:
47
+ - --charset=UTF-8
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ requirements: []
63
+
64
+ rubyforge_project:
65
+ rubygems_version: 1.2.0
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: TODO
69
+ test_files:
70
+ - test/test_helper.rb
71
+ - test/functional/soap/map_server_test.rb
72
+ - test/unit/url_helper_test.rb
73
+ - test/unit/map_server_test.rb