atlas_middleware 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,326 @@
1
+ require File.dirname(__FILE__) + '/classes.rb'
2
+ require File.dirname(__FILE__) + '/mapping_registry.rb'
3
+ require 'soap/rpc/driver'
4
+
5
+ module ESRI
6
+ module Soap
7
+ module MapServer
8
+
9
+ class Client < ::SOAP::RPC::Driver
10
+ DefaultEndpointUrl = nil
11
+
12
+ Methods = [
13
+ [ "",
14
+ "getDocumentInfo",
15
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetDocumentInfo"]],
16
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetDocumentInfoResponse"]] ],
17
+ { :request_style => :document, :request_use => :literal,
18
+ :response_style => :document, :response_use => :literal,
19
+ :faults => {} }
20
+ ],
21
+ [ "",
22
+ "getTileImageInfo",
23
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetTileImageInfo"]],
24
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetTileImageInfoResponse"]] ],
25
+ { :request_style => :document, :request_use => :literal,
26
+ :response_style => :document, :response_use => :literal,
27
+ :faults => {} }
28
+ ],
29
+ [ "",
30
+ "queryFeatureData2",
31
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "QueryFeatureData2"]],
32
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "QueryFeatureData2Response"]] ],
33
+ { :request_style => :document, :request_use => :literal,
34
+ :response_style => :document, :response_use => :literal,
35
+ :faults => {} }
36
+ ],
37
+ [ "",
38
+ "getMapName",
39
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetMapName"]],
40
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetMapNameResponse"]] ],
41
+ { :request_style => :document, :request_use => :literal,
42
+ :response_style => :document, :response_use => :literal,
43
+ :faults => {} }
44
+ ],
45
+ [ "",
46
+ "getSQLSyntaxInfo",
47
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetSQLSyntaxInfo"]],
48
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetSQLSyntaxInfoResponse"]] ],
49
+ { :request_style => :document, :request_use => :literal,
50
+ :response_style => :document, :response_use => :literal,
51
+ :faults => {} }
52
+ ],
53
+ [ "",
54
+ "exportScaleBar",
55
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "ExportScaleBar"]],
56
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "ExportScaleBarResponse"]] ],
57
+ { :request_style => :document, :request_use => :literal,
58
+ :response_style => :document, :response_use => :literal,
59
+ :faults => {} }
60
+ ],
61
+ [ "",
62
+ "getVirtualCacheDirectory",
63
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetVirtualCacheDirectory"]],
64
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetVirtualCacheDirectoryResponse"]] ],
65
+ { :request_style => :document, :request_use => :literal,
66
+ :response_style => :document, :response_use => :literal,
67
+ :faults => {} }
68
+ ],
69
+ [ "",
70
+ "computeDistance",
71
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "ComputeDistance"]],
72
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "ComputeDistanceResponse"]] ],
73
+ { :request_style => :document, :request_use => :literal,
74
+ :response_style => :document, :response_use => :literal,
75
+ :faults => {} }
76
+ ],
77
+ [ "",
78
+ "getSupportedImageReturnTypes",
79
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetSupportedImageReturnTypes"]],
80
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetSupportedImageReturnTypesResponse"]] ],
81
+ { :request_style => :document, :request_use => :literal,
82
+ :response_style => :document, :response_use => :literal,
83
+ :faults => {} }
84
+ ],
85
+ [ "",
86
+ "queryFeatureIDs",
87
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "QueryFeatureIDs"]],
88
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "QueryFeatureIDsResponse"]] ],
89
+ { :request_style => :document, :request_use => :literal,
90
+ :response_style => :document, :response_use => :literal,
91
+ :faults => {} }
92
+ ],
93
+ [ "",
94
+ "queryFeatureData",
95
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "QueryFeatureData"]],
96
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "QueryFeatureDataResponse"]] ],
97
+ { :request_style => :document, :request_use => :literal,
98
+ :response_style => :document, :response_use => :literal,
99
+ :faults => {} }
100
+ ],
101
+ [ "",
102
+ "toMapPoints",
103
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "ToMapPoints"]],
104
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "ToMapPointsResponse"]] ],
105
+ { :request_style => :document, :request_use => :literal,
106
+ :response_style => :document, :response_use => :literal,
107
+ :faults => {} }
108
+ ],
109
+ [ "",
110
+ "getTileCacheInfo",
111
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetTileCacheInfo"]],
112
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetTileCacheInfoResponse"]] ],
113
+ { :request_style => :document, :request_use => :literal,
114
+ :response_style => :document, :response_use => :literal,
115
+ :faults => {} }
116
+ ],
117
+ [ "",
118
+ "queryHyperlinks",
119
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "QueryHyperlinks"]],
120
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "QueryHyperlinksResponse"]] ],
121
+ { :request_style => :document, :request_use => :literal,
122
+ :response_style => :document, :response_use => :literal,
123
+ :faults => {} }
124
+ ],
125
+ [ "",
126
+ "hasLayerCache",
127
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "HasLayerCache"]],
128
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "HasLayerCacheResponse"]] ],
129
+ { :request_style => :document, :request_use => :literal,
130
+ :response_style => :document, :response_use => :literal,
131
+ :faults => {} }
132
+ ],
133
+ [ "",
134
+ "queryFeatureIDs2",
135
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "QueryFeatureIDs2"]],
136
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "QueryFeatureIDs2Response"]] ],
137
+ { :request_style => :document, :request_use => :literal,
138
+ :response_style => :document, :response_use => :literal,
139
+ :faults => {} }
140
+ ],
141
+ [ "",
142
+ "getDefaultMapName",
143
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetDefaultMapName"]],
144
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetDefaultMapNameResponse"]] ],
145
+ { :request_style => :document, :request_use => :literal,
146
+ :response_style => :document, :response_use => :literal,
147
+ :faults => {} }
148
+ ],
149
+ [ "",
150
+ "queryFeatureCount2",
151
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "QueryFeatureCount2"]],
152
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "QueryFeatureCount2Response"]] ],
153
+ { :request_style => :document, :request_use => :literal,
154
+ :response_style => :document, :response_use => :literal,
155
+ :faults => {} }
156
+ ],
157
+ [ "",
158
+ "identify",
159
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "Identify"]],
160
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "IdentifyResponse"]] ],
161
+ { :request_style => :document, :request_use => :literal,
162
+ :response_style => :document, :response_use => :literal,
163
+ :faults => {} }
164
+ ],
165
+ [ "",
166
+ "isFixedScaleMap",
167
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "IsFixedScaleMap"]],
168
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "IsFixedScaleMapResponse"]] ],
169
+ { :request_style => :document, :request_use => :literal,
170
+ :response_style => :document, :response_use => :literal,
171
+ :faults => {} }
172
+ ],
173
+ [ "",
174
+ "getLegendInfo",
175
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetLegendInfo"]],
176
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetLegendInfoResponse"]] ],
177
+ { :request_style => :document, :request_use => :literal,
178
+ :response_style => :document, :response_use => :literal,
179
+ :faults => {} }
180
+ ],
181
+ [ "",
182
+ "fromMapPoints",
183
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "FromMapPoints"]],
184
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "FromMapPointsResponse"]] ],
185
+ { :request_style => :document, :request_use => :literal,
186
+ :response_style => :document, :response_use => :literal,
187
+ :faults => {} }
188
+ ],
189
+ [ "",
190
+ "getCacheDescriptionInfo",
191
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetCacheDescriptionInfo"]],
192
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetCacheDescriptionInfoResponse"]] ],
193
+ { :request_style => :document, :request_use => :literal,
194
+ :response_style => :document, :response_use => :literal,
195
+ :faults => {} }
196
+ ],
197
+ [ "",
198
+ "getMapTile",
199
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetMapTile"]],
200
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetMapTileResponse"]] ],
201
+ { :request_style => :document, :request_use => :literal,
202
+ :response_style => :document, :response_use => :literal,
203
+ :faults => {} }
204
+ ],
205
+ [ "",
206
+ "getLayerTile",
207
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetLayerTile"]],
208
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetLayerTileResponse"]] ],
209
+ { :request_style => :document, :request_use => :literal,
210
+ :response_style => :document, :response_use => :literal,
211
+ :faults => {} }
212
+ ],
213
+ [ "",
214
+ "getServerInfo",
215
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetServerInfo"]],
216
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetServerInfoResponse"]] ],
217
+ { :request_style => :document, :request_use => :literal,
218
+ :response_style => :document, :response_use => :literal,
219
+ :faults => {} }
220
+ ],
221
+ [ "",
222
+ "getMapCount",
223
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetMapCount"]],
224
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetMapCountResponse"]] ],
225
+ { :request_style => :document, :request_use => :literal,
226
+ :response_style => :document, :response_use => :literal,
227
+ :faults => {} }
228
+ ],
229
+ [ "",
230
+ "queryFeatureCount",
231
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "QueryFeatureCount"]],
232
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "QueryFeatureCountResponse"]] ],
233
+ { :request_style => :document, :request_use => :literal,
234
+ :response_style => :document, :response_use => :literal,
235
+ :faults => {} }
236
+ ],
237
+ [ "",
238
+ "getServiceConfigurationInfo",
239
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetServiceConfigurationInfo"]],
240
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetServiceConfigurationInfoResponse"]] ],
241
+ { :request_style => :document, :request_use => :literal,
242
+ :response_style => :document, :response_use => :literal,
243
+ :faults => {} }
244
+ ],
245
+ [ "",
246
+ "getCacheControlInfo",
247
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetCacheControlInfo"]],
248
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetCacheControlInfoResponse"]] ],
249
+ { :request_style => :document, :request_use => :literal,
250
+ :response_style => :document, :response_use => :literal,
251
+ :faults => {} }
252
+ ],
253
+ [ "",
254
+ "hasSingleFusedMapCache",
255
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "HasSingleFusedMapCache"]],
256
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "HasSingleFusedMapCacheResponse"]] ],
257
+ { :request_style => :document, :request_use => :literal,
258
+ :response_style => :document, :response_use => :literal,
259
+ :faults => {} }
260
+ ],
261
+ [ "",
262
+ "getCacheName",
263
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetCacheName"]],
264
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "GetCacheNameResponse"]] ],
265
+ { :request_style => :document, :request_use => :literal,
266
+ :response_style => :document, :response_use => :literal,
267
+ :faults => {} }
268
+ ],
269
+ [ "",
270
+ "computeScale",
271
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "ComputeScale"]],
272
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "ComputeScaleResponse"]] ],
273
+ { :request_style => :document, :request_use => :literal,
274
+ :response_style => :document, :response_use => :literal,
275
+ :faults => {} }
276
+ ],
277
+ [ "",
278
+ "find",
279
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "Find"]],
280
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "FindResponse"]] ],
281
+ { :request_style => :document, :request_use => :literal,
282
+ :response_style => :document, :response_use => :literal,
283
+ :faults => {} }
284
+ ],
285
+ [ "",
286
+ "exportMapImage",
287
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "ExportMapImage"]],
288
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.esri.com/schemas/ArcGIS/9.3", "ExportMapImageResponse"]] ],
289
+ { :request_style => :document, :request_use => :literal,
290
+ :response_style => :document, :response_use => :literal,
291
+ :faults => {} }
292
+ ]
293
+ ]
294
+
295
+ def initialize(endpoint_url = nil)
296
+ endpoint_url ||= DefaultEndpointUrl
297
+ super(endpoint_url, nil)
298
+ self.mapping_registry = MappingRegistry::EncodedRegistry
299
+ self.literal_mapping_registry = MappingRegistry::LiteralRegistry
300
+ init_methods
301
+ end
302
+
303
+ private
304
+
305
+ def init_methods
306
+ Methods.each do |definitions|
307
+ opt = definitions.last
308
+ if opt[:request_style] == :document
309
+ add_document_operation(*definitions)
310
+ else
311
+ add_rpc_operation(*definitions)
312
+ qname = definitions[0]
313
+ name = definitions[2]
314
+ if qname.name != name and qname.name.capitalize == name.capitalize
315
+ ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg|
316
+ __send__(name, *arg)
317
+ end
318
+ end
319
+ end
320
+ end
321
+ end
322
+ end
323
+
324
+ end # MapServer
325
+ end # Soap
326
+ end #ESRI
@@ -0,0 +1,39 @@
1
+ gem 'soap4r'
2
+ require 'esri/soap/map_server/client'
3
+
4
+ module ESRI
5
+ module Soap
6
+ module MapServer
7
+ # options:
8
+ # * :image_return_type - :url or :data
9
+ def self.get_legend_info(map_server_soap_url, opts = {})
10
+ soap_client = Client.new(map_server_soap_url)
11
+ soap_client.wiredump_dev = STDOUT
12
+
13
+ image_return_type = opts[:image_return_type] || :url
14
+
15
+ map_name = soap_client.getDefaultMapName({}).result
16
+
17
+ img_type = ImageType.new
18
+ img_type.imageFormat = EsriImageFormat::EsriImagePNG;
19
+ img_type.imageReturnType = image_return_type == :url ?
20
+ EsriImageReturnType::EsriImageReturnURL :
21
+ EsriImageReturnType::EsriImageReturnMimeData
22
+
23
+ legend_patch = MapServerLegendPatch.new
24
+ legend_patch.imageDPI = 96
25
+ legend_patch.height = 24
26
+ legend_patch.width = 24
27
+
28
+ legends = soap_client.getLegendInfo(
29
+ :mapName => map_name,
30
+ :layerIDs => [],
31
+ :legendPatch => legend_patch,
32
+ :imageType => img_type
33
+ ).result
34
+
35
+ legends
36
+ end
37
+ end
38
+ end
39
+ end