gb_mapfish_appserver 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -80,7 +80,7 @@ class ApplicationController < ActionController::Base
80
80
  # lookups:
81
81
 
82
82
 
83
- # For this example, we are simply using token authentication
83
+ # We are using token authentication
84
84
  # via parameters. However, anyone could use Rails's token
85
85
  # authentication features to get the token from a header.
86
86
  def authenticate_user_from_token!
@@ -88,11 +88,11 @@ class ApplicationController < ActionController::Base
88
88
  user = user_token && User.find_by_authentication_token(user_token.to_s)
89
89
 
90
90
  if user
91
- # Notice we are passing store false, so the user is not
91
+ # Notice when passing store false, the user is not
92
92
  # actually stored in the session and a token is needed
93
93
  # for every request. If you want the token to work as a
94
94
  # sign in token, you can simply remove store: false.
95
- sign_in user, :store => false
95
+ sign_in user, :store => true
96
96
  end
97
97
  end
98
98
 
@@ -23,6 +23,11 @@ class AppsController < ApplicationController
23
23
  @selproperty = params['selproperty']
24
24
  @selvalues = params['selvalues'].nil? ? [] : params['selvalues'].split('$')
25
25
 
26
+ @filt_topic = params['filttopic']
27
+ @filt_param = params['filtparam']
28
+ @filt_values = params['filtvalues'].nil? ? [] : params['filtvalues'].split('$')
29
+ @filt_typestring = params['filttypestring'].nil? ? 0 : params['filttypestring']
30
+
26
31
  @redlining = params['redlining'].blank? ? nil : params['redlining']
27
32
  @centermarker = params['centermarker']
28
33
 
@@ -44,6 +44,8 @@ class GeoController < ApplicationController
44
44
  logger.info "#{geo_model.table_name}.update_attributes_from_feature: #{feature.inspect}"
45
45
  if new_feature.update_attributes_from_geojson_feature(feature, current_user)
46
46
  @features << new_feature
47
+ else
48
+ head :unprocessable_entity
47
49
  end
48
50
  end
49
51
 
@@ -208,18 +208,16 @@ class PrintController < ApplicationController
208
208
  def add_sld_body(topic, layer)
209
209
  # add SLD for selection
210
210
  unless layer["customParams"]["SELECTION[LAYER]"].blank?
211
- sld_body = Wms.sld_selection(topic,
212
- layer["customParams"]["SELECTION[LAYER]"],
211
+ sellayer = topic.layers.find_by_name(layer["customParams"]["SELECTION[LAYER]"])
212
+ if sellayer.nil?
213
+ logger.info "Selection layer '#{layer["customParams"]["SELECTION[LAYER]"]}' not found in topic '#{topic.name}'"
214
+ return
215
+ end
216
+ sld_body = Wms.sld_selection(sellayer,
213
217
  layer["customParams"]["SELECTION[PROPERTY]"],
214
218
  layer["customParams"]["SELECTION[VALUES]"].split(',')
215
219
  )
216
-
217
- unless sld_body.nil?
218
- # add serverside SLD for selection
219
- layer["customParams"]["SLD_BODY"] = sld_body
220
- else
221
- logger.info "Selection layer '#{layer["customParams"]["SELECTION[LAYER]"]}' not found in topic '#{topic.name}'"
222
- end
220
+ layer["customParams"]["SLD_BODY"] = sld_body
223
221
 
224
222
  # remove non-WMS params
225
223
  layer["customParams"].delete("SELECTION[LAYER]")
@@ -2,13 +2,26 @@ class SearchController < ApplicationController
2
2
 
3
3
  def index
4
4
  @rule = SEARCHRULES[params[:rule]]
5
- result = @rule.model.query(@rule.fields, params)
6
- @features = result[:features]
7
- @quality = result[:quality]
5
+ if @rule.nil? then
6
+ respond_to do |format|
7
+ format.html # index.html.erb
8
+ format.json { render :json => {:success => false, :quality => -9999, :msg => "ERROR: #{params[:rule]} model missing"} }
9
+ end
10
+ else
11
+ result = @rule.model.query(@rule.fields, params)
12
+ @features = result[:features]
13
+ @quality = result[:quality]
14
+ @success = @quality >= 0
8
15
 
9
- respond_to do |format|
10
- format.html # index.html.erb
11
- format.json { render :json => {:success => true, :features => features_for_json_reader(@features), :quality => @quality} }
16
+ respond_to do |format|
17
+ format.html # index.html.erb
18
+ if @success then
19
+ format.json { render :json => {:success => @success, :features => features_for_json_reader(@features), :quality => @quality} }
20
+ else
21
+ @msg = result[:msg]
22
+ format.json { render :json => {:success => @success, :features => features_for_json_reader(@features), :quality => @quality, :msg => @msg} }
23
+ end
24
+ end
12
25
  end
13
26
  end
14
27
 
@@ -117,47 +117,15 @@ class WmsController < ApplicationController
117
117
  logger.info "Selection layer '#{params[:SELECTION][:LAYER]}' not found in topic '#{topic.name}'"
118
118
  return
119
119
  end
120
- sld_body = sld_selection(layer, params[:SELECTION][:PROPERTY], params[:SELECTION][:VALUES].split(','))
120
+ sld_body = Wms.sld_selection(layer, params[:SELECTION][:PROPERTY], params[:SELECTION][:VALUES].split(','))
121
121
  # Remove non-WMS params
122
122
  request.env["QUERY_STRING"].gsub!(/(^|&)SELECTION.+?(?=(&|$))/, '')
123
+ #params.delete(:SELECTION)
123
124
  # add serverside SLD for selection
124
125
  request.env["QUERY_STRING"] += "&SLD_BODY=" + URI.escape(sld_body)
125
- params.delete[:SELECTION]
126
126
  end
127
127
  end
128
128
 
129
- def sld_selection(layer, filter_property, filter_values)
130
- sld = '<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" version="1.0.0" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">'
131
- sld << "<NamedLayer>"
132
- sld << "<Name>#{layer.name}</Name>"
133
- sld << "<UserStyle>"
134
- sld << "<Name>default</Name>"
135
- sld << "<FeatureTypeStyle>"
136
-
137
- filter_values.each do |value|
138
- # NOTE: use a separate rule for each value as workaround, as combined filter with <ogc:Or> does not work as expected
139
- sld << "<Rule>"
140
- sld << "<Name>show-#{value}</Name>"
141
- sld << '<ogc:Filter>'
142
- sld << "<ogc:PropertyIsEqualTo>"
143
- sld << "<ogc:PropertyName>#{filter_property}</ogc:PropertyName>"
144
- sld << "<ogc:Literal>#{value}</ogc:Literal>"
145
- sld << "</ogc:PropertyIsEqualTo>"
146
- sld << "</ogc:Filter>"
147
- sld << layer.selection_symbolizer
148
- sld << "<MinScaleDenominator>0</MinScaleDenominator>"
149
- sld << "<MaxScaleDenominator>999999999</MaxScaleDenominator>"
150
- sld << "</Rule>"
151
- end
152
-
153
- sld << "</FeatureTypeStyle>"
154
- sld << "</UserStyle>"
155
- sld << "</NamedLayer>"
156
- sld << "</StyledLayerDescriptor>"
157
-
158
- sld
159
- end
160
-
161
129
  def add_filter(topic_name)
162
130
  unless params[:LAYERS].blank?
163
131
  filters = Wms.access_filters(current_ability, current_user, topic_name, params[:LAYERS].split(','))
@@ -84,7 +84,7 @@ class GeoModel < ActiveRecord::Base
84
84
  filter = filter.where("ST_Intersects(#{table_name}.#{connection.quote_column_name(geometry_column_name)}, ST_SetSRID(#{filter_geom}, #{srid}))")
85
85
  end
86
86
 
87
- filter
87
+ filter.limit(1000)
88
88
  end
89
89
 
90
90
  def self.geojson_decode(json)
@@ -111,7 +111,7 @@ class GeoModel < ActiveRecord::Base
111
111
 
112
112
  def update_attributes_from_geojson_feature(feature, user)
113
113
  attr = feature.properties
114
- attr[self.class.geometry_column_name] = feature.geometry
114
+ attr[self.class.geometry_column_name] = feature.geometry unless feature.geometry.nil?
115
115
  ok = update_attributes(attr)
116
116
  modified_by(user)
117
117
  ok
data/app/models/topic.rb CHANGED
@@ -85,7 +85,8 @@ class Topic < ActiveRecord::Base
85
85
  "background_layer" => topic.background_layer,
86
86
  "main_layer" => topic.main_layer,
87
87
  "overlay_layer" => topic.overlay_layer,
88
- "minscale" => topic.minscale
88
+ "minscale" => topic.minscale,
89
+ "gb1_params" => topic.gb1_params #TODO: generalized param for custom viewers
89
90
  }
90
91
  end
91
92
  end
data/app/models/wms.rb CHANGED
@@ -9,6 +9,39 @@ class Wms
9
9
  @name = name
10
10
  end
11
11
 
12
+ # return SLD for selection
13
+ def self.sld_selection(layer, filter_property, filter_values)
14
+ sld = '<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" version="1.0.0" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">'
15
+ sld << "<NamedLayer>"
16
+ sld << "<Name>#{layer.name}</Name>"
17
+ sld << "<UserStyle>"
18
+ sld << "<Name>default</Name>"
19
+ sld << "<FeatureTypeStyle>"
20
+
21
+ filter_values.each do |value|
22
+ # NOTE: use a separate rule for each value as workaround, as combined filter with <ogc:Or> does not work as expected
23
+ sld << "<Rule>"
24
+ sld << "<Name>show-#{value}</Name>"
25
+ sld << '<ogc:Filter>'
26
+ sld << "<ogc:PropertyIsEqualTo>"
27
+ sld << "<ogc:PropertyName>#{filter_property}</ogc:PropertyName>"
28
+ sld << "<ogc:Literal>#{value}</ogc:Literal>"
29
+ sld << "</ogc:PropertyIsEqualTo>"
30
+ sld << "</ogc:Filter>"
31
+ sld << layer.selection_symbolizer
32
+ sld << "<MinScaleDenominator>0</MinScaleDenominator>"
33
+ sld << "<MaxScaleDenominator>999999999</MaxScaleDenominator>"
34
+ sld << "</Rule>"
35
+ end
36
+
37
+ sld << "</FeatureTypeStyle>"
38
+ sld << "</UserStyle>"
39
+ sld << "</NamedLayer>"
40
+ sld << "</StyledLayerDescriptor>"
41
+
42
+ sld
43
+ end
44
+
12
45
  def self.access_filters(ability, user, topic_name, layers)
13
46
  access_filters = {}
14
47
  unless topic_name.blank?
@@ -0,0 +1,35 @@
1
+ #
2
+ # Copyright (C) 2008 Pirmin Kalberer, Sourcepole AG
3
+ #
4
+ # This file is part of MapFish Server
5
+ #
6
+ # MapFish Server is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Lesser General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # MapFish Server is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Lesser General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public License
17
+ # along with MapFish Server. If not, see <http://www.gnu.org/licenses/>.
18
+ #
19
+
20
+ module GbMapfishAppserver
21
+ module Array
22
+
23
+ def to_geojson(options = {})
24
+ geojson = '{"type": "FeatureCollection", "features": ['
25
+ geojson << collect {|e| e.to_geojson(options) }.join(',')
26
+ geojson << ']}'
27
+ geojson
28
+ end
29
+
30
+ end
31
+ end
32
+
33
+ Array.class_eval do
34
+ include GbMapfishAppserver::Array
35
+ end
@@ -1,3 +1,3 @@
1
1
  module GbMapfishAppserver
2
- VERSION = "0.9.4"
2
+ VERSION = "0.9.5"
3
3
  end
@@ -1,4 +1,6 @@
1
1
  require "gb_mapfish_appserver/engine"
2
+ require "gb_mapfish_appserver/core_extensions"
3
+
2
4
 
3
5
  module GbMapfishAppserver
4
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gb_mapfish_appserver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-03 00:00:00.000000000 Z
12
+ date: 2014-07-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &21600120 !ruby/object:Gem::Requirement
16
+ requirement: &13079460 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.2.13
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *21600120
24
+ version_requirements: *13079460
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &21599620 !ruby/object:Gem::Requirement
27
+ requirement: &13091140 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *21599620
35
+ version_requirements: *13091140
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: acts_as_tree
38
- requirement: &21598800 !ruby/object:Gem::Requirement
38
+ requirement: &13088220 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - =
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.2.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *21598800
46
+ version_requirements: *13088220
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: devise
49
- requirement: &21597760 !ruby/object:Gem::Requirement
49
+ requirement: &13102320 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.2.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *21597760
57
+ version_requirements: *13102320
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: cancan
60
- requirement: &21597280 !ruby/object:Gem::Requirement
60
+ requirement: &13099000 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - =
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.6.8
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *21597280
68
+ version_requirements: *13099000
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rails_admin
71
- requirement: &21596760 !ruby/object:Gem::Requirement
71
+ requirement: &13095780 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.4.0
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *21596760
79
+ version_requirements: *13095780
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: fastercsv
82
- requirement: &21596160 !ruby/object:Gem::Requirement
82
+ requirement: &13109120 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *21596160
90
+ version_requirements: *13109120
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: sass
93
- requirement: &21595320 !ruby/object:Gem::Requirement
93
+ requirement: &13106760 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 3.2.12
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *21595320
101
+ version_requirements: *13106760
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: GeoRuby
104
- requirement: &21594500 !ruby/object:Gem::Requirement
104
+ requirement: &12738520 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 0.1.4
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *21594500
112
+ version_requirements: *12738520
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rgeo
115
- requirement: &21593740 !ruby/object:Gem::Requirement
115
+ requirement: &12816320 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 0.3.20
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *21593740
123
+ version_requirements: *12816320
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: rgeo-geojson
126
- requirement: &21593180 !ruby/object:Gem::Requirement
126
+ requirement: &12810900 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ~>
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: 0.2.3
132
132
  type: :runtime
133
133
  prerelease: false
134
- version_requirements: *21593180
134
+ version_requirements: *12810900
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: hpricot
137
- requirement: &21592700 !ruby/object:Gem::Requirement
137
+ requirement: &12829520 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '0'
143
143
  type: :runtime
144
144
  prerelease: false
145
- version_requirements: *21592700
145
+ version_requirements: *12829520
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: pg
148
- requirement: &21592120 !ruby/object:Gem::Requirement
148
+ requirement: &12836620 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ~>
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: 0.14.0
154
154
  type: :runtime
155
155
  prerelease: false
156
- version_requirements: *21592120
156
+ version_requirements: *12836620
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: activerecord-postgis-adapter
159
- requirement: &21591580 !ruby/object:Gem::Requirement
159
+ requirement: &12860020 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - =
@@ -164,7 +164,7 @@ dependencies:
164
164
  version: 0.4.1
165
165
  type: :runtime
166
166
  prerelease: false
167
- version_requirements: *21591580
167
+ version_requirements: *12860020
168
168
  description: Mapfish Appserver is a framework for web mapping applications using OGC
169
169
  standards and the Mapfish protocol.
170
170
  email:
@@ -274,6 +274,7 @@ files:
274
274
  - db/seeds.rb
275
275
  - gb_mapfish_appserver.gemspec
276
276
  - lib/gb_mapfish_appserver.rb
277
+ - lib/gb_mapfish_appserver/core_extensions.rb
277
278
  - lib/gb_mapfish_appserver/engine.rb
278
279
  - lib/gb_mapfish_appserver/version.rb
279
280
  - lib/generators/mapfish/install/install_generator.rb