atlas_middleware 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +3 -0
- data/README +3 -0
- data/lib/arc_server_soap.rb +47 -0
- data/lib/atlas_middleware.rb +5 -0
- data/lib/cgns_search.rb +30 -0
- data/lib/esri/soap/map_server/classes.rb +4328 -0
- data/lib/esri/soap/map_server/client.rb +326 -0
- data/lib/esri/soap/map_server/map_server.rb +39 -0
- data/lib/esri/soap/map_server/mapping_registry.rb +4300 -0
- data/lib/map_server_legend_info.rb +17 -0
- data/lib/pdf_template.rb +206 -0
- data/lib/postal_code_lookup.rb +54 -0
- data/lib/print_map/job.rb +49 -0
- data/lib/print_map/legend_images_collector.rb +34 -0
- data/lib/print_map/map_exporter.rb +20 -0
- data/lib/print_map/pdf_generator.rb +146 -0
- data/lib/print_map/worker.rb +71 -0
- data/lib/print_map_service.rb +48 -0
- data/lib/rest_proxy.rb +15 -0
- metadata +113 -0
data/LICENSE
ADDED
data/README
ADDED
@@ -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
|
data/lib/cgns_search.rb
ADDED
@@ -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
|