Skip to content

Commit adbba9b

Browse files
committed
supported osm base map printing
1 parent 4988a97 commit adbba9b

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

app/controllers/gtt_print_jobs_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def create
1414
job.issue = @issue
1515
job.issues = @issues
1616
if job.valid?
17-
@result = RedmineGttPrint.mapfish.print job
17+
@result = RedmineGttPrint.mapfish.print job, request.referer, request.user_agent
1818
render status: (@result&.success? ? :created : 422)
1919
else
2020
render status: 422

lib/redmine_gtt_print/issue_to_json.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def self.map_data(center, features, scale, basemap_url)
178178
type: "geojson"
179179
},
180180
{
181-
baseURL: "https://cyberjapandata.gsi.go.jp/xyz/std",
181+
baseURL: basemap_url.sub(/\/{z}\/{x}\/{y}.png/,''),
182182
imageExtension: "png",
183183
type: "osm"
184184
}

lib/redmine_gtt_print/mapfish.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def get_capabilities(print_config)
3131
end
3232
end
3333

34-
def print(job)
35-
if ref = request_print(job.json, job.print_config, job.format)
34+
def print(job, referer, user_agent)
35+
if ref = request_print(job.json, job.print_config, job.format, referer, user_agent)
3636
CreateJobResult.new success: true, ref: ref
3737
else
3838
CreateJobResult.new
@@ -63,13 +63,17 @@ def get_print(ref)
6363

6464
private
6565

66-
def request_print(json, print_config, format)
66+
def request_print(json, print_config, format, referer, user_agent)
6767
str = URI.escape(print_config)
6868
url = "#{@host}/print/#{str}/report.#{format}"
6969
if Rails.env.development?
7070
(File.open(Rails.root.join("tmp/mapfish.json"), "wb") << json).close
7171
end
72-
r = HTTParty.post url, body: json, headers: { 'Content-Type' => 'application/json' }
72+
r = HTTParty.post url, body: json, headers: {
73+
'Content-Type' => 'application/json',
74+
'Referer' => referer,
75+
'User-Agent' => user_agent
76+
}
7377
if r.success?
7478
json = JSON.parse r.body
7579
json['ref']

0 commit comments

Comments
 (0)