gb_mapfish_appserver 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2VlMzQ0NmQzYjJhMTA0ZmYwMWY4OGE4MmUzMTI4ZGFlMDJmZmVhOQ==
4
+ ZjcyMGM2NTljZDgyZjdhZmQ3YzA4MzNiYzFmMGFmM2IwZWY0ZmUzYg==
5
5
  data.tar.gz: !binary |-
6
- NmIxZmI0NGNjMzU5ZDVlOGE3ODE1MTU1ZDNhZmVlMTU3YjU2NWQ2Zg==
6
+ ODFhZGY1NThiOGQ1ODkxMzRhY2U1MDQzZTcyNjUyYjAwYWU5NGFmZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDRiOGFiYzU5Y2I5NGQ4ZGY4NDdjNDllMWViZDAzMGU2MTI0YjJiNzhmOTU3
10
- M2UzNWZlMzc5NGNmZWRiYjdmYTUwNjUzMjBlZDc3ZTAwZjJhYjZlYTkwNWQ2
11
- NjJmMDVlZDdkNDk3ZWExZTdlMWZkM2EyYWZlY2IxNDkxMzkxYTQ=
9
+ OThjMDNmNWIwM2FkODMwN2Y0OTQ0NjZiYjFjN2ViZjRmOTZhM2Q2MGNlOTlk
10
+ M2RjNjliNWYxZDgyYjRjMTRjOTM5NzU1YWMxNDg4YzZhYjg5ZGJhMDFjNWQ5
11
+ YzZmYzNlMGNmYTI5M2NkNDMyYWY1ZjY1NzczOWI1MDBhNTgzYWY=
12
12
  data.tar.gz: !binary |-
13
- YWRmNTBmNjIxMWZhYzk4ZWM2YWE3MWQ4NDc4MmIxY2U4MDYxMWFmMzAxNDg1
14
- MTFlYjM1ZTliM2RmYzYyZmVhNzgwOTE2NGFiMDlhNDQyYzQ2NmY0ZjQyMTdh
15
- MGIwY2Y1NGNlNzExZTE1ZTA5OGM5ZmUwOGM5MjgxNmY1ZDY4MzU=
13
+ MTFjMzlhMzM3MmVlNWQ5NWE5MzFjY2E5OWQ1NmU0NjdiNmIxN2I0MWIyNzkx
14
+ NzYwMzQ3MjFjZGMzZDhjNjg5NjJmNTVjOWMyMGE0MDFlYjliMTk4NWE1Yzli
15
+ MmY1YjAyNmIyNTllNmU0YjY1ODc5MzhlN2Y5ZTAwNjgzOGU3ZDM=
@@ -46,6 +46,7 @@ class GeoController < ApplicationController
46
46
  @features << new_feature
47
47
  else
48
48
  head :unprocessable_entity
49
+ return
49
50
  end
50
51
  end
51
52
 
@@ -53,18 +54,16 @@ class GeoController < ApplicationController
53
54
  end
54
55
 
55
56
  def update
56
- feature = geo_model.geojson_decode(request.raw_post)
57
+ # NOTE: user_filter checks if model is editable
58
+ feature = geo_model.user_filter(current_ability).geojson_decode(request.raw_post)
57
59
  if feature.nil?
58
60
  head :bad_request
59
61
  return
60
62
  end
61
63
 
62
64
  if feature.feature_id.is_a? Integer
63
- @feature = geo_model.user_filter(current_ability).find_by_id(feature.feature_id)
64
- end
65
- if @feature.nil?
66
- head :not_found
67
- return
65
+ # NOTE: user_filter may limit editable features; find raises RecordNotFound if feature cannot be found
66
+ @feature = geo_model.user_filter(current_ability).find(feature.feature_id)
68
67
  end
69
68
 
70
69
  if @feature.update_attributes_from_geojson_feature(feature, current_user)
@@ -84,14 +84,21 @@ class GeoModel < ActiveRecord::Base
84
84
  #end
85
85
 
86
86
  def bbox
87
- box_query = "Box2D(#{connection.quote_column_name(self.class.geometry_column_name)})"
88
- extent = self.class.select("ST_XMin(#{box_query}), ST_YMin(#{box_query}), ST_XMax(#{box_query}), ST_Ymax(#{box_query})").find(id)
89
- [
90
- extent.st_xmin.to_f,
91
- extent.st_ymin.to_f,
92
- extent.st_xmax.to_f,
93
- extent.st_ymax.to_f
94
- ]
87
+ if respond_to?('extent')
88
+ # use extent from select(extent_field)
89
+ envelope = GeoRuby::SimpleFeatures::Geometry.from_hex_ewkb(extent).envelope #TODO: replace with rgeo
90
+ [envelope.lower_corner.x, envelope.lower_corner.y, envelope.upper_corner.x, envelope.upper_corner.y]
91
+ else
92
+ # get Box2D for this feature
93
+ box_query = "Box2D(#{connection.quote_column_name(self.class.geometry_column_name)})"
94
+ extent = self.class.select("ST_XMin(#{box_query}), ST_YMin(#{box_query}), ST_XMax(#{box_query}), ST_Ymax(#{box_query})").find(id)
95
+ [
96
+ extent.st_xmin.to_f,
97
+ extent.st_ymin.to_f,
98
+ extent.st_xmax.to_f,
99
+ extent.st_ymax.to_f
100
+ ]
101
+ end
95
102
  end
96
103
 
97
104
  # based on mapfish_filter
@@ -76,6 +76,16 @@ class Layer < ActiveRecord::Base
76
76
  self.table_name = '#{table}'
77
77
  self.primary_key = '#{pkey}'
78
78
 
79
+ if self.primary_key == 'oid'
80
+ # include oid in attributes
81
+ default_scope select("*").select(self.primary_key)
82
+
83
+ # return oid as id
84
+ def id
85
+ read_attribute(self.class.primary_key)
86
+ end
87
+ end
88
+
79
89
  self
80
90
  end
81
91
  EOS
@@ -1,3 +1,3 @@
1
1
  module GbMapfishAppserver
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gb_mapfish_appserver
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pirmin Kalberer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-17 00:00:00.000000000 Z
11
+ date: 2015-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails