arcserver.rb 0.1.3 → 0.1.4

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.
@@ -1,7 +1,57 @@
1
1
  = arcserver.rb
2
2
 
3
- Description goes here.
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
4
54
 
5
55
  == Copyright
6
56
 
7
- Copyright (c) 2009 Colin Casey. See LICENSE for details.
57
+ Copyright (c) 2010 Colin Casey. See LICENSE for details.
data/Rakefile CHANGED
@@ -33,6 +33,16 @@ Rake::RDocTask.new do |rdoc|
33
33
  rdoc.rdoc_files.include('lib/**/*.rb')
34
34
  end
35
35
 
36
+
37
+ begin
38
+ require 'yard'
39
+ YARD::Rake::YardocTask.new do |t|
40
+ t.files = ['lib/**/*.rb']
41
+ end
42
+ rescue LoadError
43
+
44
+ end
45
+
36
46
  desc "Build arcserver.rb gem"
37
47
  task :build do
38
48
  system "gem build arcserver.rb.gemspec"
@@ -25,14 +25,14 @@ module ArcServer
25
25
  end
26
26
 
27
27
  # Utility method for generating a legend image
28
- # (requires optional dependency, RMagick [>= 2.13.1], to be installed)
28
+ # (requires optional dependency, RMagick [>= 2.12.0], to be installed)
29
29
  #
30
30
  # @return [Magick::Image] the legend as an RMagick Image object
31
31
  def get_legend_image
32
32
  begin
33
33
  require 'RMagick' unless Object.const_defined?("Magick")
34
34
  rescue LoadError
35
- raise ArcServerError, "#{self.class}#get_legend_image needs an optional dependency 'RMagick [>= 2.13.1]' to be installed - try `gem install rmagick`"
35
+ raise ArcServerError, "#{self.class}#get_legend_image needs an optional dependency 'RMagick [>= 2.12.0]' to be installed - try `gem install rmagick`"
36
36
  end
37
37
  Util::LegendImage.new(self).get_image
38
38
  end
@@ -2,23 +2,228 @@
2
2
 
3
3
  module ArcServer
4
4
  module REST
5
+ # Map services offer access to map and layer content. Map services can either
6
+ # be cached or dynamic. A map service that fulfills requests with pre-created
7
+ # tiles from a cache instead of dynamically rendering part of the map is called
8
+ # a cached map service. A dynamic map service requires the server to render
9
+ # the map each time a request comes in. Map services using a tile cache can
10
+ # significantly improve performance while delivering maps, while dynamic map
11
+ # services offer more flexibility. Map services should always be published as
12
+ # pooled services.
13
+ #
14
+ # The REST API map service resource represents a map service. This resource
15
+ # works only with the default data frame of your published map document. This
16
+ # resource provides basic information about the map, including the layers that
17
+ # it contains, whether the map is cached or not, its spatial reference, initial
18
+ # and full extents, map units, and copyright text. It also provides some metadata
19
+ # associated with the service such as its service description, its author, and
20
+ # keywords. If the map is cached, then additional information about its tiling
21
+ # scheme such as the origin of the cached tiles, the levels of detail, and tile
22
+ # size is included. Note that multi-layer caches are only accessible in REST
23
+ # via export, and these requests are treated as a dynamic map service. Tile
24
+ # access is not supported in REST for multi-layer caches.
25
+ #
26
+ # The map service resource supports several operations:
27
+ #
28
+ # * Export map - Used to export a map image from a dynamic map service. The
29
+ # resulting map can be used for display and be in a different projection from
30
+ # the original data source. When generating a map image, map services are
31
+ # not able to change feature rendering for an existing layer, add a dynamic
32
+ # layer, or change the layer draw order.
33
+ #
34
+ # * Identify - Returns information about features in one or more layers based
35
+ # on where a user clicks on the map.
36
+ #
37
+ # * Find - Returns information about features in one or more fields in one or
38
+ # more layers based on a key word.
39
+ #
40
+ # * Generate KML - Generates a KML document wrapped in a kmz file. The document
41
+ # contains a network link to the KML service endpoint with specified properties
42
+ # and parameters. This operation is valid on services that have not been restricted
43
+ # by using a token service.
44
+ #
45
+ # * Query on a Layer - Returns a subset of features in a layer based on query
46
+ # criteria.
47
+ #
48
+ # * Map services do not expose editing capabilities. They provide read-only
49
+ # access to feature and attribute content.
5
50
  class MapServer
51
+ # The REST url of a map service
6
52
  attr_reader :url
7
53
 
54
+ # @param [String] url the REST url of a map service
55
+ # @example
56
+ # ArcServer::MapServer.new("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer")
8
57
  def initialize(url)
9
58
  @url = url
10
59
  end
11
60
 
12
- def export(opts = {})
13
- query = {
14
- :bbox => opts[:bbox],
15
- :f => opts[:f] || :image,
16
- :format => opts[:format] || :png24,
17
- :transparent => opts[:transparent] || true,
18
- :size => opts[:size],
19
- :dpi => opts[:dpi]
61
+ # The export operation is performed on a map service resource. The result
62
+ # of this operation is a map image resource. This resource provides information
63
+ # about the exported map image such as its URL, its width and height, extent
64
+ # and scale.
65
+ #
66
+ # Apart from the usual response formats of html and json, users can also
67
+ # request a format called image while performing this operation. When users
68
+ # perform an export with the format of image, the server responds by directly
69
+ # streaming the image bytes to the client. One must note that with this
70
+ # approach you don't get any information associated with the exported map
71
+ # other than the actual image.
72
+ #
73
+ # Note that the extent displayed in the exported map image may not exactly
74
+ # match the extent sent in the bbox parameter when the aspect ratio of the
75
+ # image size does not match the aspect ratio of the bbox. The aspect ratio
76
+ # is the height divided by the width. In these cases the extent is re-sized
77
+ # to prevent map images from appearing stretched. The exported map’s extent
78
+ # is sent along with the json and html responses and may be used in client
79
+ # side calculations. So it is important that the client-side code update its
80
+ # extent based on the response.
81
+ #
82
+ # @param [Hash] params the query parameters to pass to the export operation
83
+ #
84
+ # @option params [String, Symbol] :f (:image) The response format. The default response
85
+ # format is html. If the format is image, the image bytes are directly streamed
86
+ # to the client.
87
+ #
88
+ # # Values: html | json | image | kmz | pjson (pretty json)
89
+ # # Examples:
90
+ # :f => :json
91
+ # :f => 'kmz'
92
+ #
93
+ # @option params [required, String, Array] :bbox The extent (bounding box) of
94
+ # the exported image. Unless the bboxSR parameter has been specified, the
95
+ # bbox is assumed to be in the spatial reference of the map.
96
+ #
97
+ # # Syntax: <xmin>, <ymin>, <xmax>, <ymax>
98
+ # # Examples:
99
+ # :bbox => "-104,35.6,-94.32,41"
100
+ # :bbox => [-104,35.6,-94.32,41]
101
+ #
102
+ # # Note: The bboxcoordinates should always use a period as the decimal separator
103
+ # # even in countries where traditionally a comma is used.
104
+ #
105
+ # @option params [String, Array] :size ([400, 400]) The size (width * height) of the exported
106
+ # image in pixels. If the size is not specified, an image with a default
107
+ # size of 400 * 400 will be exported.
108
+ #
109
+ # # Syntax: <width>, <height>
110
+ # # Examples:
111
+ # :size => "600,550"
112
+ # :size => [600,550]
113
+ #
114
+ # @option params [Integer] :dpi (96) The device resolution of the exported
115
+ # image (dots per inch).
116
+ #
117
+ # # Example:
118
+ # :dpi => 300
119
+ #
120
+ # @option params [Integer] :imageSR The well-known ID of the spatial reference
121
+ # of the exported image. If the imageSR is not specified, the image will
122
+ # be exported in the spatial reference of the map.
123
+ #
124
+ # # Example:
125
+ # :imageSR => 4326
126
+ #
127
+ # @option params [Integer] :bboxSR The well-known ID of the spatial reference
128
+ # of the bbox. If the bboxSR is not specified, the bbox is assumed to be
129
+ # in the spatial reference of the map.
130
+ #
131
+ # # Example:
132
+ # :bboxSR => 4326
133
+ #
134
+ # @option params [String, Symbol] :format (:png) The format of the exported
135
+ # image.
136
+ #
137
+ # # Values: png | png8 | png24 | jpg | pdf | bmp | gif | svg | png32
138
+ # # Examples:
139
+ # :format => :png32
140
+ # :format => 'jpg'
141
+ #
142
+ # # Note: Support for the png32 format was added at 9.3.1. This format is only
143
+ # # available for map services whose supportedImageFormatTypes property includes PNG32
144
+ #
145
+ # @option params [String] :layerDefs Allows you to filter the features of
146
+ # individual layers in the exported map by specifying definition expressions
147
+ # for those layers.
148
+ #
149
+ # # Syntax: layerId1:layerDef1;layerId2:layerDef2
150
+ # # (where layerId1, layerId2 are the layer ids returned by the map service resource)
151
+ # # Example:
152
+ # :layersDefs => "0:POP2000 > 1000000;5:AREA > 100000"
153
+ # :layersDefs => { 0 => "POP2000 > 1000000", 1 => "AREA > 100000" }
154
+ #
155
+ # @option params [String, Hash<Symbol, Array>] layers Determines which layers appear on the exported
156
+ # map. There are four ways to specify which layers are shown:
157
+ #
158
+ # * show: Only the layers specified in this list will be exported.
159
+ # * hide: All layers except those specified in this list will be exported.
160
+ # * include: In addition to the layers exported by default, the layers specified in this list will be exported.
161
+ # * exclude: The layers exported by default excluding those specified in this list will be exported.
162
+ #
163
+ # # Syntax: [show | hide | include | exclude]:layerId1,layerId2
164
+ # # where layerId1, layerId2are the layer ids returned by the map service resource
165
+ # # Examples:
166
+ # :layers => "show:2,4,7"
167
+ # :layers => { :show => [2,4,7] }
168
+ #
169
+ # @option params [true, false] transparent (false) If true, the image will be exported
170
+ # with the background color of the map set as its transparent color. The default
171
+ # is false. Only the png and gif formats support transparency. Internet
172
+ # Explorer 6 does not display transparency correctly for png24 image formats.
173
+ #
174
+ # @example
175
+ # # create a map service
176
+ # map_service = MapServer.new("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer")
177
+ #
178
+ # # Export a map
179
+ # map_service.export(:bbox => "-127.8,15.4,-63.5,60.5")
180
+ #
181
+ # # Export a map and change imageSR to 102004 (USA_Contiguous_Lambert_Conformal_Conic projection)
182
+ # map_service.export(:bbox => "-127.8,15.4,-63.5,60.5", :imageSR => 102004, :f => "html")
183
+ #
184
+ # # Export a map, change imageSR to 102004 (USA_Contiguous_Lambert_Conformal_Conic projection),
185
+ # # set image size to a width and height of 800x600, format to gif, and transparent to true.
186
+ # map_service.export(:bbox => "-115.8,30.4,-85.5,50.5", :size => "800,600", :imageSR => 102004, :format => "gif", :transparent => false, :f => "html")
187
+ #
188
+ # # Export the same map as above but change the output format to pretty json (f=pjson).
189
+ # map_service.export(:bbox => "-115.8,30.4,-85.5,50.5", :size => "800,600", :imageSR => 102004, :format => "gif", :transparent => false, :f => "pjson")
190
+ #
191
+ # @example
192
+ # JSON Response Syntax:
193
+ # {
194
+ # "href" : "<href>",
195
+ # "width" : <width>,
196
+ # "height" : <height>,
197
+ # "extent" : {<envelope>},
198
+ # "scale" : <scale>
199
+ # }
200
+ #
201
+ # JSON Response Example:
202
+ # {
203
+ # "href" : "http://atlantic/arcgisoutput/_ags_map42ef5eae899942a9b564138e184a55c9.png",
204
+ # "width" : 400,
205
+ # "height" : 400,
206
+ # "extent" : {
207
+ # "xmin" : -109.55,
208
+ # "ymin" : 25.76,
209
+ # "xmax" : -86.39,
210
+ # "ymax" : 49.94,
211
+ # "spatialReference" : { "wkid" : 4326 }
212
+ # },
213
+ # "scale" : 2.53E7
214
+ # }
215
+ #
216
+ # @return [HTTParty::Response] the HTTP response
217
+ def export(params = {})
218
+ params = {
219
+ :bbox => params[:bbox],
220
+ :f => params[:f] || :image,
221
+ :format => params[:format] || :png24,
222
+ :transparent => params[:transparent] || true,
223
+ :size => params[:size],
224
+ :dpi => params[:dpi]
20
225
  }
21
- HTTParty.get("#{url}/export", :query => query)
226
+ HTTParty.get("#{url}/export", :query => params)
22
227
  end
23
228
  end
24
229
  end
@@ -2,7 +2,147 @@
2
2
 
3
3
  module ArcServer
4
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.
5
144
  class MapServer < Handsoap::Service
145
+ protected
6
146
  on_create_document do |doc|
7
147
  doc.alias "env", "http://schemas.xmlsoap.org/soap/envelope/"
8
148
  doc.alias "ns", "http://www.esri.com/schemas/ArcGIS/9.3"
@@ -12,16 +152,48 @@ module ArcServer
12
152
  self.class.endpoint(:uri => @soap_url, :version => 1)
13
153
  end
14
154
 
155
+ public
15
156
  def initialize(soap_url, protocol_version=2)
16
157
  @soap_url = soap_url
17
158
  end
18
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.
19
162
  def get_default_map_name
20
163
  response = invoke("ns:GetDefaultMapName")
21
164
  node = response.document.xpath('//tns:GetDefaultMapNameResponse/Result', ns).first
22
165
  parse_default_map_name_result(node)
23
166
  end
24
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
25
197
  def get_legend_info(args = {})
26
198
  image_return_type = args[:image_return_url] ? "esriImageReturnURL" : "esriImageReturnMimeData"
27
199
  response = invoke("ns:GetLegendInfo") do |message|
@@ -37,7 +209,7 @@ module ArcServer
37
209
 
38
210
  private
39
211
  def ns
40
- { 'tns', 'http://www.esri.com/schemas/ArcGIS/9.3' }
212
+ { 'tns' => 'http://www.esri.com/schemas/ArcGIS/9.3' }
41
213
  end
42
214
 
43
215
  # helpers
@@ -2,6 +2,6 @@
2
2
  module ArcServer
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- PATCH = 3
5
+ PATCH = 4
6
6
  VERSION = [MAJOR, MINOR, PATCH].join('.')
7
7
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require File.dirname(__FILE__) + '/../../test_helper'
2
+ require File.expand_path("../../../test_helper", __FILE__)
3
3
  require 'yaml'
4
4
 
5
5
  #ArcServer::SOAP::MapServer.logger = $stdout
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require File.dirname(__FILE__) + '/../test_helper'
2
+ require File.expand_path("../../test_helper", __FILE__)
3
3
 
4
4
  class ArcServer::MapServerTest < Test::Unit::TestCase
5
5
  should "raise an error if the required url is not a map server url" do
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require File.dirname(__FILE__) + '/../test_helper'
2
+ require File.expand_path("../../test_helper", __FILE__)
3
3
 
4
4
  class ArcServer::UrlHelperTest < Test::Unit::TestCase
5
5
  include ArcServer::UrlHelper
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require File.dirname(__FILE__) + '/../../test_helper'
2
+ require File.expand_path("../../../test_helper", __FILE__)
3
3
  require 'RMagick'
4
4
 
5
5
  class ArcServer::Util::LegendImageTest < Test::Unit::TestCase
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 4
9
+ version: 0.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Colin Casey
@@ -117,12 +117,12 @@ dependencies:
117
117
  - !ruby/object:Gem::Version
118
118
  segments:
119
119
  - 2
120
- - 13
121
- - 1
122
- version: 2.13.1
120
+ - 12
121
+ - 0
122
+ version: 2.12.0
123
123
  type: :development
124
124
  version_requirements: *id007
125
- description: arcserver.rb is a utility for accessing ESRI ArcServer REST and SOAP APIs from a unified interface
125
+ description: A library for accessing ESRI ArcServer REST and SOAP APIs from a unified interface
126
126
  email:
127
127
  - casey.colin@gmail.com
128
128
  executables: []
@@ -179,7 +179,7 @@ rubyforge_project:
179
179
  rubygems_version: 1.3.7
180
180
  signing_key:
181
181
  specification_version: 3
182
- summary: Library for accessing ESRI ArcServer REST and SOAP APIs.
182
+ summary: A library for accessing ESRI ArcServer REST and SOAP APIs from a unified interface
183
183
  test_files:
184
184
  - test/functional/soap/map_server_test.rb
185
185
  - test/test_helper.rb