arcserver.rb 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{arcserver.rb}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Colin Casey"]
12
- s.date = %q{2009-10-12}
12
+ s.date = %q{2009-10-13}
13
13
  s.email = %q{casey.colin@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -23,8 +23,14 @@ module ArcServer
23
23
  end
24
24
 
25
25
  def get_legend_info(args = {})
26
+ image_return_type = args[:image_return_url] ? "esriImageReturnURL" : "esriImageReturnMimeData"
27
+
26
28
  response = invoke("ns:GetLegendInfo") do |message|
27
29
  message.add "MapName", args[:map_name] || get_default_map_name
30
+ message.add "ImageType" do |image_type|
31
+ image_type.add "ImageReturnType", image_return_type
32
+ image_type.add "ImageFormat", "esriImagePNG24"
33
+ end
28
34
  end
29
35
  node = response.document.xpath('//tns:GetLegendInfoResponse/Result', ns).first
30
36
  parse_legend_info_result(node)
@@ -25,12 +25,24 @@ class ArcServer::SOAP::MapServerTest < Test::Unit::TestCase
25
25
  assert_equal "Portland", @service.get_default_map_name
26
26
  end
27
27
 
28
- should "get the legend info" do
28
+ should "get the legend info (returning image data)" do
29
29
  legend_info = @service.get_legend_info(:map_name => 'Portland')
30
30
  legend_info.each do |item|
31
31
  layer_assertion = "assert_legend_info_result_layer_#{item[:layer_id]}".to_sym
32
32
  if respond_to?(layer_assertion)
33
- send(layer_assertion, item)
33
+ send(layer_assertion, item, :image_data)
34
+ else
35
+ raise "no assertions set for legend info with layer_id=#{item[:layer_id]}"
36
+ end
37
+ end
38
+ end
39
+
40
+ should "get the legend info (returning image urls)" do
41
+ legend_info = @service.get_legend_info(:map_name => 'Portland', :image_return_url => true)
42
+ legend_info.each do |item|
43
+ layer_assertion = "assert_legend_info_result_layer_#{item[:layer_id]}".to_sym
44
+ if respond_to?(layer_assertion)
45
+ send(layer_assertion, item, :image_url)
34
46
  else
35
47
  raise "no assertions set for legend info with layer_id=#{item[:layer_id]}"
36
48
  end
@@ -51,29 +63,30 @@ class ArcServer::SOAP::MapServerTest < Test::Unit::TestCase
51
63
  end
52
64
 
53
65
  # legend info assertion helpers
54
- def assert_legend_info_result_layer_1(item)
66
+ def assert_legend_info_result_layer_1(item, image_return_type = :image_data)
55
67
  expected = {
56
68
  :layer_id => 1,
57
69
  :name => 'Zoomed in',
58
70
  :legend_groups => [{
59
71
  :legend_classes => [{
60
72
  :symbol_image => {
61
- :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nR0lEQVR4nGP89/8/AzUBC4wR4O9PkckbNm5kZGBgYGCihmHIZrAgC8JsIdcwBgaoC6kJRg0cNXAw\nGIiSU6iRBanuQkZqF18AsvET5O8fag8AAAAASUVORK5CYII=\n"
73
+ :image_return_type => image_return_type
62
74
  }
63
75
  }]
64
76
  }]
65
77
  }
78
+
66
79
  assert_legend_info_result_layer(expected, item)
67
80
  end
68
81
 
69
- def assert_legend_info_result_layer_2(item)
82
+ def assert_legend_info_result_layer_2(item, image_return_type = :image_data)
70
83
  expected = {
71
84
  :layer_id => 2,
72
85
  :name => 'Zoomed out',
73
86
  :legend_groups => [{
74
87
  :legend_classes => [{
75
88
  :symbol_image => {
76
- :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nPklEQVR4nGP89/8/AzUBE1VNY2BgYIExAvz9KXbqho0bGVnQBcg1DOYgqnt51MBRA4elgShZjxr5\nmZHaxRcATwAQChHiw9IAAAAASUVORK5CYII=\n"
89
+ :image_return_type => image_return_type
77
90
  }
78
91
  }]
79
92
  }]
@@ -81,14 +94,14 @@ class ArcServer::SOAP::MapServerTest < Test::Unit::TestCase
81
94
  assert_legend_info_result_layer(expected, item)
82
95
  end
83
96
 
84
- def assert_legend_info_result_layer_3(item)
97
+ def assert_legend_info_result_layer_3(item, image_return_type = :image_data)
85
98
  expected = {
86
99
  :layer_id => 3,
87
100
  :name => 'Buildings',
88
101
  :legend_groups => [{
89
102
  :legend_classes => [{
90
103
  :symbol_image => {
91
- :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nNElEQVR4nGP89/8/AzUBE1VNY2BgYIExZtTVUeTUjKYmRgYGGrhw1MBRA0cNJAYwDvrSBgCGTgoZ\ncGsDFQAAAABJRU5ErkJggg==\n"
104
+ :image_return_type => image_return_type
92
105
  }
93
106
  }]
94
107
  }]
@@ -96,7 +109,7 @@ class ArcServer::SOAP::MapServerTest < Test::Unit::TestCase
96
109
  assert_legend_info_result_layer(expected, item)
97
110
  end
98
111
 
99
- def assert_legend_info_result_layer_4(item)
112
+ def assert_legend_info_result_layer_4(item, image_return_type = :image_data)
100
113
  expected = {
101
114
  :layer_id => 4,
102
115
  :name => 'Zoning',
@@ -104,32 +117,32 @@ class ArcServer::SOAP::MapServerTest < Test::Unit::TestCase
104
117
  :legend_classes => [{
105
118
  :label => 'Commercial',
106
119
  :symbol_image => {
107
- :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nNElEQVR4nGP89/8/AzUBE1VNY2BgYIExXjAyUuRUif//GRkYaODCUQNHDRw1kBjAOOhLGwBbzgoZ\npkxTgAAAAABJRU5ErkJggg==\n"
120
+ :image_return_type => image_return_type
108
121
  }
109
122
  }, {
110
123
  :label => 'Industrial',
111
124
  :symbol_image => {
112
- :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nNElEQVR4nGP89/8/AzUBE1VNY2BgYIEx2hhXUuTUqv/hjAwMNHDhqIGjBo4aSAxgHPSlDQBtTgoZ\nvbcuLAAAAABJRU5ErkJggg==\n"
125
+ :image_return_type => image_return_type
113
126
  }
114
127
  }, {
115
128
  :label => 'Residential',
116
129
  :symbol_image => {
117
- :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nNElEQVR4nGP89/8/AzUBE1VNY2BgYIExGBlKKHLqf4YeRgYGGrhw1MBRA0cNJAYwDvrSBgAaUgkZ\nJEjqtwAAAABJRU5ErkJggg==\n"
130
+ :image_return_type => image_return_type
118
131
  }
119
132
  }, {
120
133
  :label => 'Mixed use',
121
134
  :symbol_image => {
122
- :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nNElEQVR4nGP89/8/AzUBE1VNY2BgYIExvuW5UORUrkl7GBkYaODCUQNHDRw1kBjAOOhLGwCLTgoZ\nUbp19QAAAABJRU5ErkJggg==\n"
135
+ :image_return_type => image_return_type
123
136
  }
124
137
  }, {
125
138
  :label => 'Parks and open space',
126
139
  :symbol_image => {
127
- :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nOUlEQVR4nGP89/8/AzUBE1VNY2BgYIExGBkYKHLqfwYGRgYGGrhw1MBRA0cNJAbA8zIsL1IKqO5C\nAJdcBiBRj7wXAAAAAElFTkSuQmCC\n"
140
+ :image_return_type => image_return_type
128
141
  }
129
142
  }, {
130
143
  :label => 'Rural',
131
144
  :symbol_image => {
132
- :image_data => "iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nNElEQVR4nGP89/8/AzUBE1VNY2BgYIExus+lU+TUUqOZjAwMNHDhqIGjBo4aSAxgHPSlDQCRTgoZ\nWZnonwAAAABJRU5ErkJggg==\n"
145
+ :image_return_type => image_return_type
133
146
  }
134
147
  }]
135
148
  }]
@@ -164,8 +177,7 @@ class ArcServer::SOAP::MapServerTest < Test::Unit::TestCase
164
177
  end
165
178
 
166
179
  def assert_symbol_image(expected, actual)
167
- assert_not_nil expected[:image_data] if actual[:image_data]
168
- assert_equal expected[:image_url], actual[:image_url]
180
+ assert_not_nil actual[expected[:image_return_type]]
169
181
  assert_equal expected[:image_height] || 16, actual[:image_height]
170
182
  assert_equal expected[:image_width] || 20, actual[:image_width]
171
183
  assert_equal expected[:image_dpi] || 96, actual[:image_dpi]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arcserver.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin Casey
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-12 00:00:00 -03:00
12
+ date: 2009-10-13 00:00:00 -03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency