atlas_middleware 0.0.1

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.
data/LICENSE ADDED
@@ -0,0 +1,3 @@
1
+ == AtlasRack
2
+
3
+ Put appropriate LICENSE for your project here.
data/README ADDED
@@ -0,0 +1,3 @@
1
+ == AtlasRack
2
+
3
+ You should document your project here.
@@ -0,0 +1,47 @@
1
+ gem 'soap4r'
2
+ require File.dirname(__FILE__) + '/esri/soap/map_server/client.rb'
3
+
4
+ class ArcServerSoap
5
+ def call(env)
6
+ request = Rack::Request.new(env)
7
+
8
+ headers = { "Content-Type" => "application/json" }
9
+ r = Rack::Response # shorthand
10
+ response = r.new(call_soap_service(request), 200, headers) # rescue r.new(500, headers, '')
11
+ #response.max_age = 1.month
12
+
13
+ response.to_a
14
+ end
15
+
16
+ def call_soap_service(request)
17
+ endpoint = rest_url_to_soap_service(request.params['rest_url'])
18
+ soap_client = ESRI::Soap::MapServer::Client.new(endpoint)
19
+ #soap_client.wiredump_dev = STDOUT
20
+ #soap_client.options['protocol.http.receive_timeout'] = 360
21
+
22
+ map_name = soap_client.getDefaultMapName({}).result
23
+
24
+ img_type = ESRI::Soap::MapServer::ImageType.new
25
+ img_type.imageFormat = ESRI::Soap::MapServer::EsriImageFormat::EsriImagePNG;
26
+ img_type.imageReturnType = ESRI::Soap::MapServer::EsriImageReturnType::EsriImageReturnURL;
27
+
28
+ legend_patch = ESRI::Soap::MapServer::MapServerLegendPatch.new
29
+ legend_patch.imageDPI = 96
30
+ legend_patch.height = 24
31
+ legend_patch.width = 24
32
+
33
+ legends = soap_client.getLegendInfo(
34
+ :mapName => map_name,
35
+ :layerIDs => [],
36
+ :legendPatch => legend_patch,
37
+ :imageType => img_type
38
+ ).result
39
+
40
+ legends.to_json
41
+ end
42
+
43
+ def rest_url_to_soap_service(rest_url)
44
+ rest_url.sub('ArcGIS/rest', 'ArcGIS')
45
+ end
46
+
47
+ end
@@ -0,0 +1,5 @@
1
+ require 'rack'
2
+ #require 'rack/cache'
3
+ require 'activesupport'
4
+ require 'json'
5
+ require 'json/add/rails'
@@ -0,0 +1,30 @@
1
+ require 'rack'
2
+ #require 'rack/cache'
3
+ require 'activesupport'
4
+ require 'httparty'
5
+
6
+ class CgnsSearch
7
+ include HTTParty
8
+ base_uri "gnss.nrcan.gc.ca"
9
+ default_params :output => 'xml', :regionCode => 13
10
+ format :xml
11
+
12
+ def call(env)
13
+ request = Rack::Request.new(env)
14
+
15
+ headers = { "Content-Type" => "application/json" }
16
+ r = Rack::Response
17
+ begin
18
+ response = r.new(find(request.params), 200, headers)
19
+ rescue Exception => e
20
+ response = r.new(e.message, 500, headers)
21
+ end
22
+ #response.max_age = 1.month
23
+
24
+ response.to_a
25
+ end
26
+
27
+ def find(query = {})
28
+ CgnsSearch.get('/gnss-srt/api', { :query => query }).to_json
29
+ end
30
+ end