Skip to content

Commit 7be01c8

Browse files
authored
Merge pull request #182 from gtt-project/ftr/rotate-map
Ftr/rotate map
2 parents 4f692df + 616cc3f commit 7be01c8

File tree

18 files changed

+69
-18
lines changed

18 files changed

+69
-18
lines changed

app/controllers/.keep

Whitespace-only changes.

app/helpers/.keep

Whitespace-only changes.

app/helpers/gtt_map_helper.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22

33
module GttMapHelper
44

5-
def map_form_field(form, map, field: :geojson, bounds: nil, edit_mode: nil, upload: true)
5+
def map_form_field(form, map, field: :geojson, bounds: nil, edit_mode: nil, upload: true, rotation: 0)
66
safe_join [
77
form.hidden_field(field, id: 'geom'),
8-
map_tag(map: map, bounds: bounds, edit: edit_mode, upload: upload)
8+
map_tag(map: map, bounds: bounds, edit: edit_mode, upload: upload, rotation: rotation)
99
]
1010
end
1111

1212
def map_tag(map: nil, layers: map&.layers,
1313
geom: map.json, bounds: map.bounds,
1414
edit: nil, popup: nil, upload: true,
15-
collapsed: false)
15+
collapsed: false, rotation: map&.rotation)
1616

1717
data = {
18-
geom: geom.is_a?(String) ? geom : geom.to_json
18+
geom: geom.is_a?(String) ? geom : geom.to_json,
19+
rotation: rotation
1920
}
2021

2122
if layers

app/models/.keep

Whitespace-only changes.

app/models/gtt_configuration.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
class GttConfiguration
22
include ActiveModel::Model
33

4-
attr_accessor :project, :geojson, :gtt_tile_source_ids
4+
attr_accessor :project, :geojson, :gtt_tile_source_ids, :map_rotation
55

66
def self.for(project)
77
new(
88
project: project,
99
geojson: project.geojson,
10+
map_rotation: project.map_rotation,
1011
gtt_tile_source_ids: project.gtt_tile_source_ids
1112
)
1213
end
1314

1415
def self.from_params(params)
1516
new geojson: params[:geojson],
17+
map_rotation: params[:map_rotation],
1618
gtt_tile_source_ids: params[:gtt_tile_source_ids]
1719
end
1820

1921
def map
20-
GttMap.new json: geojson, layers: project.gtt_tile_sources.sorted
22+
GttMap.new json: geojson, layers: project.gtt_tile_sources.sorted, rotation: project.map_rotation
2123
end
2224

2325
end

app/models/gtt_map.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
class GttMap
22

3-
attr_reader :layers, :json, :bounds
3+
attr_reader :layers, :json, :bounds, :rotation
44

5-
def initialize(geom: nil, json: nil, layers:, bounds: nil)
5+
def initialize(geom: nil, json: nil, layers:, bounds: nil, rotation: nil)
66
unless @json = json
77
@json = RedmineGtt::Conversions.geom_to_json geom if geom
88
end
99

10+
@rotation = rotation || 0
1011
@bounds = bounds || @json
1112
@layers = layers
1213
end

app/views/issues/index/_map.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<legend class="<%= "icon " + (collapsed ? "icon-collapsed" : "icon-expended") %>"><%= l(:field_location) %></legend>
55

66
<%= map_tag map: @project.map, geom: (Issue.array_to_geojson(@issues, include_properties: { only: %i(id subject tracker_id status_id) }) if @issues),
7-
popup: { href: '/issues/[id]' }, collapsed: collapsed %>
7+
popup: { href: '/issues/[id]' }, collapsed: collapsed, rotation: @project.map_rotation %>
88
</fieldset>
99

1010
<% end %>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<% if @project.nil? or @project.module_enabled?(:gtt) %>
2-
<%= map_tag map: @issue.map, geom: (@issue.as_geojson(include_properties: { only: %i(tracker_id status_id) }) if @issue) %>
2+
<%= map_tag map: @issue.map, geom: (@issue.as_geojson(include_properties: { only: %i(tracker_id status_id) }) if @issue), rotation: @project.map_rotation %>
33
<% end %>

app/views/projects/index.api.rsb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ api.array :projects, api_meta(:total_count => @project_count, :offset => @offset
88
api.parent(:id => project.parent.id, :name => project.parent.name) if project.parent && project.parent.visible?
99
api.status project.status
1010
api.is_public project.is_public?
11+
api.rotation project.map_rotation
1112

1213
if @include_geometry
1314
if project.geom

app/views/projects/settings/_gtt.html.erb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@
1212
{}, { multiple: true, size: 5 } %>
1313
<br /><em><%= t :gtt_tile_sources_info %></em>
1414
</p>
15+
<p>
16+
<%= content_tag(:label, l(:gtt_map_rotate_label)) %>
17+
<%= number_field_tag('gtt_configuration[map_rotation]', @project.map_rotation, min: 0, max: 359, size: 10 ) %>
18+
<br /><em><%= t :gtt_map_rotate_info_html %></em>
19+
</p>
1520
</div>
1621

1722
<div class="box">
18-
<%= map_form_field f, @form.map, bounds: nil, edit_mode: 'Polygon' %>
23+
<%= map_form_field f, @form.map, bounds: nil, edit_mode: 'Polygon', rotation: @project.map_rotation %>
1924
</div>
2025

21-
2226
<%= submit_tag l(:button_save) %>
2327

2428
<% end %>

0 commit comments

Comments
 (0)