arcserver.rb 0.1.4 → 0.1.5

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.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.travis.yml +12 -0
  4. data/Gemfile +7 -0
  5. data/Gemfile.lock +274 -0
  6. data/LICENSE +20 -20
  7. data/README.md +160 -0
  8. data/Rakefile +9 -62
  9. data/arcserver.rb.gemspec +35 -0
  10. data/lib/arcserver.rb +33 -7
  11. data/lib/arcserver/Identifiable.rb +10 -0
  12. data/lib/arcserver/Queryable.rb +10 -0
  13. data/lib/arcserver/feature_server.rb +19 -0
  14. data/lib/arcserver/geometry/geometry.rb +91 -0
  15. data/lib/arcserver/geometry_service.rb +18 -0
  16. data/lib/arcserver/gp_server.rb +20 -0
  17. data/lib/arcserver/graphics/feature.rb +23 -0
  18. data/lib/arcserver/graphics/feature_set.rb +26 -0
  19. data/lib/arcserver/map_server.rb +34 -40
  20. data/lib/arcserver/rest/feature_server.rb +30 -0
  21. data/lib/arcserver/rest/geometry_service.rb +54 -0
  22. data/lib/arcserver/rest/gp_server.rb +80 -0
  23. data/lib/arcserver/rest/identify.rb +66 -0
  24. data/lib/arcserver/rest/map_server.rb +230 -230
  25. data/lib/arcserver/rest/query.rb +68 -0
  26. data/lib/arcserver/url_helper.rb +31 -25
  27. data/lib/arcserver/util/legend_image.rb +0 -0
  28. data/lib/arcserver/version.rb +6 -6
  29. data/spec/custom_spec.rb +50 -0
  30. data/spec/factories/feature.rb +21 -0
  31. data/spec/feature_server_spec.rb +52 -0
  32. data/spec/feature_spec.rb +20 -0
  33. data/spec/geometry_service_spec.rb +31 -0
  34. data/spec/geometry_spec.rb +80 -0
  35. data/spec/gp_server_spec.rb +57 -0
  36. data/spec/identify_spec.rb +21 -0
  37. data/spec/query_spec.rb +38 -0
  38. data/spec/shared_context.rb +17 -0
  39. data/spec/spec_helper.rb +15 -0
  40. metadata +217 -158
  41. data/README.rdoc +0 -57
  42. data/lib/arcserver/soap/map_server.rb +0 -263
  43. data/test/functional/soap/map_server_test.rb +0 -193
  44. data/test/test_helper.rb +0 -25
  45. data/test/unit/map_server_test.rb +0 -61
  46. data/test/unit/url_helper_test.rb +0 -54
  47. data/test/unit/util/legend_image_test.rb +0 -69
@@ -1,57 +0,0 @@
1
- = arcserver.rb
2
-
3
- arcserver.rb is a unified interface for interacting with ESRI Arcserver (9.3+)
4
- SOAP and REST APIs from Ruby. Extra utility methods are also provided for
5
- generating legend images.
6
-
7
- == Installation
8
-
9
- [sudo] gem install arcserver.rb
10
-
11
- <em>Optional: (some of the utility methods require RMagick)</em>
12
- [sudo] gem install rmagick
13
-
14
- == Quick Example
15
-
16
- require 'arcserver'
17
-
18
- # connect to a map server instance using either its REST or SOAP url
19
- map_server = ArcServer::MapServer.new('http://sampleserver1.arcgisonline.com/ArcGIS/services/Portland/ESRI_LandBase_WebMercator/MapServer')
20
-
21
- # get the default map name using the SOAP API
22
- puts map_server.get_default_map_name
23
-
24
- # get legend information using the SOAP API
25
- puts map_server.get_legend_info
26
-
27
- # export an image using the REST
28
- puts map_server.export
29
-
30
- == Contributors
31
-
32
- The following people have contributed their time and effort to arcserver.rb:
33
-
34
- * Colin Casey
35
- * Glenn Goodrich
36
-
37
- == Contribute
38
-
39
- If you'd like to hack on arcserver.rb, start by forking my repo on GitHub:
40
-
41
- http://github.com/colincasey/arcserver.rb
42
-
43
- To get all of the dependencies, install the gem first. The best way to get your changes merged back into core is as follows:
44
-
45
- 1. Clone your fork
46
- 2. Create a thoughtfully named topic branch to contain your change
47
- 3. Hack away
48
- 4. Add tests and make sure everything still passes by running rake
49
- 5. If you are adding new functionality, document it in the README
50
- 6. Do not change the version number, I will do that on my end
51
- 7. If necessary, rebase your commits into logical chunks, without errors
52
- 8. Push the branch up to GitHub
53
- 9. Send me (colincasey[http://github.com/colincasey]) a pull request for your branch
54
-
55
- == Copyright
56
-
57
- Copyright (c) 2010 Colin Casey. See LICENSE for details.
@@ -1,263 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module ArcServer
4
- module SOAP
5
- # Map services offer access to map and attribute content. Map services can either be cached
6
- # or dynamic. A map service that fulfills requests with pre-created tiles from a cache instead
7
- # of dynamically rendering part of the map is called a cached map service. A dynamic map
8
- # service requires the server to render the map each time a request comes in. Map services
9
- # using a tile cache can significantly improve performance while delivering maps, while dynamic
10
- # map services offer more flexibility.
11
- #
12
- # Map services offer the following capabilities:
13
- # * Generate map images for a specified geographic area
14
- # * Change the description of the map
15
- # * Control the output map image
16
- # * Get map legend information
17
- # * Query map features using attributes or spatial filters
18
- # * Get information regarding the cache
19
- # * Get a scale bar
20
- #
21
- # WSDL syntax:
22
- # http://<Web Server Hostname>/<ArcGIS Instance>/services/<ServiceName>/MapServer?wsdl
23
- #
24
- # =Working with map services
25
- #
26
- # ==Get information about the map and its layers
27
- #
28
- # To access information about a map and its layers use GetServerInfo. GetServerInfo returns MapServerInfo
29
- # and MapLayerInfo. MapServerInfo contains read-only information describing the default state of a map
30
- # service, such as the name of the map, the background color or the spatial extent of the map. Read-only
31
- # layer properties, such as the layer’s name, the layer’s attributes and whether or not the layer has
32
- # labels associated with it, can be retrieved from MapLayerInfo.
33
- #
34
- # If you wish to make changes to the map or to map layers you will need to use MapDescription or
35
- # LayerDescription. Use MapDescription to access map settings that can be changed such as geographic
36
- # extent and spatial reference. MapDescription provides access to information on individual layers within
37
- # the map. LayerDescription provides the ability to change the visibility of a layer, to toggle the visibility
38
- # of existing labels belonging to the layer and to assign a expression in order to display a specified
39
- # subset of features.
40
- #
41
- # == Exporting a map image
42
- #
43
- # To export a map image from a dynamic map service use ExportMapImage. An ImageDescription contains an ImageType
44
- # and an ImageDisplay. Specifying the image format, such as JPG or PNG, is done using ImageType. Use ImageDisplay to
45
- # specify the height and width of the image. You can also specify a transparent color using ImageDisplay. The server
46
- # will restrict the maximum size an image can be. Use GetServiceConfigurationInfo to view the maximum height and width.
47
- # GetServiceConfigurationInfo contains a set of name-value pairs for properties set for the MapServer Service
48
- # Configuration Restrictions.
49
- #
50
- # ==Information about legend elements
51
- #
52
- # You can retrieve legend elements including the symbol image, labels, descriptions and headings. A common use would
53
- # be to populate a table of contents. To retrieve legend information, use GetLegendInfo and MapServerLegendInfo
54
- # to retrieve specific information for a particular layer.
55
- #
56
- # ==Querying the map
57
- #
58
- # Map services offer a number of methods to perform query operations on the map. These include:
59
- # * Find
60
- # * Identify
61
- # * QueryHyperlinks
62
- # * QueryFeatureCount
63
- # * QueryFeatureData
64
- # * QueryFeatureIDs
65
- # * QueryFeatureCount2
66
- # * QueryFeatureData2
67
- # * QueryFeatureIDs2
68
- #
69
- # Find returns an array of MapServerFindResults based on a search string. Use MapServerFindResult to access properties
70
- # of found features, such as the found value, the layer ID, the field name, the geometry of the found feature and a
71
- # set of name-value pairs for the field names and values of the found features.
72
- #
73
- # Identify returns an array of MapServerIdentifyResults based on search shape. Use MapServerIdentifyResult to access
74
- # properties of identified features. These include: layer ID, name, a set of name-value pairs for the field names and values
75
- # of the identified object, and the geometry of the identified.
76
- #
77
- # QueryFeatureCount and QueryFeatureCount2 both return the number of features that match a query. The difference between
78
- # the two operations is QueryFeatureCount requires a LayerID as one of the parameters, while QueryFeatureCount2 requires
79
- # a LayerDescription instead. By passing in a LayerDescription you can query against a specific sub set of the layer by
80
- # apply a definition expression.
81
- #
82
- # QueryFeatureID and QueryFeatureID2 both return an FIDSet. This is the set of feature IDs that match the query criteria.
83
- # The difference between the two operations is QueryFeatureCount requires a LayerID as one of the parameters, while
84
- # QueryFeatureCount2 requires a LayerDescription instead. By passing in a LayerDescription you can query against a specific
85
- # subset of the layer by apply a definition expression.
86
- #
87
- # QueryFeatureData and QueryFeatureData2 differ not only in the required parameters, but also in what is returned.
88
- # QueryFeatureData returns a RecordSet base on a specific query and includes a LayerID in the method parameters.
89
- # QueryFeatureData2 returns a QueryResult. A QueryResult includes the URL of the generated query result in the requested
90
- # format. The result format can be specified by using QueryResultOptions. The query result can be formatted into a RecordSet
91
- # or KMZ format (either as a URL to the kmz file or a Mime object). Another property includes GeoTransformation. This is
92
- # used to specify any needed geographic transformation on the results.
93
- #
94
- # The server will restrict the maximum number of records that can be sent. Use GetServiceConfigurationInfo the maximum records
95
- # that can be returned in a query for this particular map service. GetServiceConfigurationInfo contains a set of name-value
96
- # pairs for properties set for the MapServer Service Configuration Restrictions. This restriction does not affect
97
- # QueryFeatureCount, QueryFeatureIds, QueryFeatureCount2 or QueryFeatureIds2.
98
- #
99
- # =Working with cached vs. dynamic map services
100
- #
101
- # ArcGIS Server map services provide access to two types of visible map content: dynamic and cached. Dynamic maps
102
- # are generated on-the-fly per a user request. Layer visibility, graphics, and other variables can be modified before
103
- # the dynamic map is generated. Unfortunately, as the amount of content and complexity in the map increases, so
104
- # does the amount of time it takes to generate the map. Alternatively, cached maps consist of pre-generated map
105
- # tiles available for immediate access. Since the cost of generating the maps has already been paid, the performance
106
- # penalty associated with map generation is not a factor. Working with a map cache requires knowledge of cache
107
- # properties, such a location and structure, so that you are able to retrieve the appropriate cached image. In
108
- # general, a map cache is stored in a nested set of directories which contain image tiles for map extents at specific
109
- # scale levels, or levels of detail. The author of the map service determines these levels. The cached tiles are
110
- # usually accessible via a public virtual directory or an ArcGIS Server map service tile handler.
111
- #
112
- # ==Information about a map cache
113
- #
114
- # Use IsFixedScaleMap to determine if a map service is cached. The term fixed scale map service and cached map service are
115
- # used synonymously. GetCacheDescriptionInfo returns information on a cached map service in one call including its
116
- # cache type, its tiling scheme (TileCacheInfo), image information (TileImageInfo) and control information (TileControlInfo).
117
- #
118
- # TileCacheInfo contains information on the tiling scheme for the cache. The tiling scheme includes the tiling origin,
119
- # spatial reference, tile size in pixels and information on the Levels of Detail (LOD) at which the service is cached.
120
- # LODInfos enumerate a LODInfo object which describes a scale and resolution. Using the tiling scheme information in
121
- # TileCacheInfo the client can calculate the tiles that cover any rectangular extent in map space and then retrieve
122
- # tiles either directly from the virtual directory, or from the tile handler or by making GetMapTile or GetLayerTile
123
- # requests against the map service.
124
- #
125
- # GetMapTile gets the specified tile from a map service that has a single fused cache. GetLayerTile gets the specified
126
- # tile for a defined layer from a map service that has a multi-layer cache.
127
- #
128
- # GetTileImageInfo returns information describing the image format for the cached tiles. TileImageInfo has two main
129
- # properties Format and Compression quality. Format can have values (PNG8, PNG24, PNG32 and JPEG). If the selected format
130
- # is JPEG, then the compression quality can have a value from 0 to 100. The value of format must be used in constructing
131
- # the URL to the tile.
132
- #
133
- # GetCacheControlInfo returns cache control information that allows clients to discover information such as if client
134
- # caching is allowed.
135
- #
136
- # =Limitations
137
- #
138
- # When generating a map image, map services are not able to perform the following tasks:
139
- # * Change feature render for an existing layer.
140
- # * Add a dynamic layer
141
- # * Change layer draw order
142
- #
143
- # Map services do not expose editing capabilities. They merely provide read-only access to feature and attribute content.
144
- class MapServer < Handsoap::Service
145
- protected
146
- on_create_document do |doc|
147
- doc.alias "env", "http://schemas.xmlsoap.org/soap/envelope/"
148
- doc.alias "ns", "http://www.esri.com/schemas/ArcGIS/9.3"
149
- end
150
-
151
- def on_before_dispatch
152
- self.class.endpoint(:uri => @soap_url, :version => 1)
153
- end
154
-
155
- public
156
- def initialize(soap_url, protocol_version=2)
157
- @soap_url = soap_url
158
- end
159
-
160
- # Get the name of the active map (data frame) in a map service.
161
- # @return [String] A string representing name of the active map in the map service.
162
- def get_default_map_name
163
- response = invoke("ns:GetDefaultMapName")
164
- node = response.document.xpath('//tns:GetDefaultMapNameResponse/Result', ns).first
165
- parse_default_map_name_result(node)
166
- end
167
-
168
- # Returns legend information, such as layer name, group heading, classification labels and symbol swatches,
169
- # for layers in a map.
170
- #
171
- # A map service does not have the ability to generate a single legend image will all legend content. Instead,
172
- # the GetLegendInfo() method provides access to legend content which can be used to construct a single consolidated
173
- # legend.
174
- #
175
- # Each MapServerLegendInfo object contains one or more MapServerLegendGroup objects. Each MapServerLegendGroup object
176
- # contains one or more MapServerLegendClass objects. The relationship between value objects and legend content is
177
- # illustrated in the following diagram. Note that each MapServerLegendClass contains a classification label and symbol
178
- # swatch.
179
- #
180
- # @param [Hash] args the arguments to send in the SOAP request
181
- #
182
- # @option args [String] :map_name (get_default_map_name()) the name of the map (data frame) that will
183
- # be used to generate legend info
184
- #
185
- # @option args [Array<Integer>] :layer_ids (nil) An array of layer ids for which legend information will
186
- # be returned. If empty or null, all layers will be included.
187
- #
188
- # @option args [LegendPatch] :legend_patch (nil) A MapServerLegendPatch used to define symbol swatch properties
189
- # for legend classifications. If empty or null, the default patch properties defined in the map will be used.
190
- #
191
- # @option args [String] :image_type ("esriImageReturnMimeData") An ImageType defines the image type and method for
192
- # returning the image content for the symbol swatches. Supported image types are 'bmp', 'jpg', 'tif', 'png'/'png8',
193
- # 'png24', 'emf', 'ps', 'pdf', 'ai', 'gif', and 'svg'/'svgz'. Image content can be returned as a URL or as a
194
- # MIME data stream.
195
- #
196
- # @return [Hash] the SOAP response decoded into a Hash
197
- def get_legend_info(args = {})
198
- image_return_type = args[:image_return_url] ? "esriImageReturnURL" : "esriImageReturnMimeData"
199
- response = invoke("ns:GetLegendInfo") do |message|
200
- message.add "MapName", args[:map_name] || get_default_map_name
201
- message.add "ImageType" do |image_type|
202
- image_type.add "ImageReturnType", image_return_type
203
- image_type.add "ImageFormat", "esriImagePNG24"
204
- end
205
- end
206
- node = response.document.xpath('//tns:GetLegendInfoResponse/Result', ns).first
207
- parse_legend_info_result(node)
208
- end
209
-
210
- private
211
- def ns
212
- { 'tns' => 'http://www.esri.com/schemas/ArcGIS/9.3' }
213
- end
214
-
215
- # helpers
216
- def parse_default_map_name_result(node)
217
- xml_to_str(node, './text()')
218
- end
219
-
220
- def parse_legend_info_result(node)
221
- node.xpath('./MapServerLegendInfo', ns).collect { |child| parse_map_server_legend_info(child) }
222
- end
223
-
224
- def parse_map_server_legend_info(node)
225
- {
226
- :layer_id => xml_to_int(node, "./LayerID/text()"),
227
- :name => xml_to_str(node, "./Name/text()"),
228
- :legend_groups => node.xpath('./LegendGroups/MapServerLegendGroup', ns).collect { |child| parse_map_server_legend_group(child) }
229
- }
230
- end
231
-
232
- def parse_map_server_legend_group(node)
233
- {
234
- :heading => xml_to_str(node, "./Heading/text()"),
235
- :legend_classes => node.xpath("./LegendClasses/MapServerLegendClass", ns).collect { |child| parse_map_server_legend_class(child) }
236
- }
237
- end
238
-
239
- def parse_map_server_legend_class(node)
240
- {
241
- :label => xml_to_str(node, "./Label/text()"),
242
- :descriptions => xml_to_str(node, "./Description/text()"),
243
- :symbol_image => {
244
- :image_data => xml_to_str(node, "./SymbolImage/ImageData/text()"),
245
- :image_url => xml_to_str(node, "./SymbolImage/ImageURL/text()"),
246
- :image_height => xml_to_int(node, "./SymbolImage/ImageHeight/text()"),
247
- :image_width => xml_to_int(node, "./SymbolImage/ImageWidth/text()"),
248
- :image_dpi => xml_to_int(node, "./SymbolImage/ImageDPI/text()")
249
- },
250
- :transparent_color => {
251
- :use_windows_dithering => xml_to_bool(node, "./TransparentColor/UseWindowsDithering/text()"),
252
- :alpha_value => xml_to_int(node, "./TransparentColor/AlphaValue/text()"),
253
- :red => xml_to_int(node, "./TransparentColor/Red/text()"),
254
- :green => xml_to_int(node, "./TransparentColor/Green/text()"),
255
- :blue => xml_to_int(node, "./TransparentColor/Blue/text()")
256
- }
257
- }
258
- end
259
-
260
-
261
- end
262
- end
263
- end
@@ -1,193 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path("../../../test_helper", __FILE__)
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 (returning image data)" 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, :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)
46
- else
47
- raise "no assertions set for legend info with layer_id=#{item[:layer_id]}"
48
- end
49
- end
50
- end
51
-
52
- should "use the default map name when getting the legend info" do
53
- legend_info = @service.get_legend_info
54
- legend_info.each do |item|
55
- layer_assertion = "assert_legend_info_result_layer_#{item[:layer_id]}".to_sym
56
- if respond_to?(layer_assertion)
57
- send(layer_assertion, item)
58
- else
59
- raise "no assertions set for legend info with layer_id=#{item[:layer_id]}"
60
- end
61
- end
62
- end
63
- end
64
-
65
- # legend info assertion helpers
66
- def assert_legend_info_result_layer_1(item, image_return_type = :image_data)
67
- expected = {
68
- :layer_id => 1,
69
- :name => 'Zoomed in',
70
- :legend_groups => [{
71
- :legend_classes => [{
72
- :symbol_image => {
73
- :image_return_type => image_return_type
74
- }
75
- }]
76
- }]
77
- }
78
-
79
- assert_legend_info_result_layer(expected, item)
80
- end
81
-
82
- def assert_legend_info_result_layer_2(item, image_return_type = :image_data)
83
- expected = {
84
- :layer_id => 2,
85
- :name => 'Zoomed out',
86
- :legend_groups => [{
87
- :legend_classes => [{
88
- :symbol_image => {
89
- :image_return_type => image_return_type
90
- }
91
- }]
92
- }]
93
- }
94
- assert_legend_info_result_layer(expected, item)
95
- end
96
-
97
- def assert_legend_info_result_layer_3(item, image_return_type = :image_data)
98
- expected = {
99
- :layer_id => 3,
100
- :name => 'Buildings',
101
- :legend_groups => [{
102
- :legend_classes => [{
103
- :symbol_image => {
104
- :image_return_type => image_return_type
105
- }
106
- }]
107
- }]
108
- }
109
- assert_legend_info_result_layer(expected, item)
110
- end
111
-
112
- def assert_legend_info_result_layer_4(item, image_return_type = :image_data)
113
- expected = {
114
- :layer_id => 4,
115
- :name => 'Zoning',
116
- :legend_groups => [{
117
- :legend_classes => [{
118
- :label => 'Commercial',
119
- :symbol_image => {
120
- :image_return_type => image_return_type
121
- }
122
- }, {
123
- :label => 'Industrial',
124
- :symbol_image => {
125
- :image_return_type => image_return_type
126
- }
127
- }, {
128
- :label => 'Residential',
129
- :symbol_image => {
130
- :image_return_type => image_return_type
131
- }
132
- }, {
133
- :label => 'Mixed use',
134
- :symbol_image => {
135
- :image_return_type => image_return_type
136
- }
137
- }, {
138
- :label => 'Parks and open space',
139
- :symbol_image => {
140
- :image_return_type => image_return_type
141
- }
142
- }, {
143
- :label => 'Rural',
144
- :symbol_image => {
145
- :image_return_type => image_return_type
146
- }
147
- }]
148
- }]
149
- }
150
- assert_legend_info_result_layer(expected, item)
151
- end
152
-
153
- def assert_legend_info_result_layer(expected, actual)
154
- assert_equal expected[:layer_id], actual[:layer_id]
155
- assert_equal expected[:name], actual[:name]
156
- # check the legend groups
157
- assert_equal expected[:legend_groups].length, actual[:legend_groups].length
158
- actual[:legend_groups].each do |legend_group|
159
- assert_legend_group expected[:legend_groups].shift, legend_group
160
- end
161
- end
162
-
163
- def assert_legend_group(expected, actual)
164
- assert_equal expected[:heading], actual[:heading]
165
- # check the legend classes
166
- assert_equal expected[:legend_classes].length, actual[:legend_classes].length
167
- actual[:legend_classes].each do |legend_class|
168
- assert_legend_class expected[:legend_classes].shift, legend_class
169
- end
170
- end
171
-
172
- def assert_legend_class(expected, actual)
173
- assert_equal expected[:label], actual[:label]
174
- assert_equal expected[:description], actual[:description]
175
- assert_symbol_image(expected[:symbol_image] || {}, actual[:symbol_image])
176
- assert_transparent_color(expected[:transparent_color] || {}, actual[:transparent_color])
177
- end
178
-
179
- def assert_symbol_image(expected, actual)
180
- assert_not_nil actual[expected[:image_return_type]]
181
- assert_equal expected[:image_height] || 16, actual[:image_height]
182
- assert_equal expected[:image_width] || 20, actual[:image_width]
183
- assert_equal expected[:image_dpi] || 96, actual[:image_dpi]
184
- end
185
-
186
- def assert_transparent_color(expected, actual)
187
- assert_equal expected[:use_windows_dithering] || true, actual[:use_windows_dithering]
188
- assert_equal expected[:alpha_value] || 255, actual[:alpha_value]
189
- assert_equal expected[:red] || 254, actual[:red]
190
- assert_equal expected[:green] || 255, actual[:green]
191
- assert_equal expected[:blue] || 255, actual[:blue]
192
- end
193
- end