rgeoserver 0.5.8.1 → 0.5.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.8.1
1
+ 0.5.8.2
@@ -0,0 +1,98 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ # RGeoServer Catalog Migration example (catalog_migration.rb)
4
+
5
+ # require rubygems
6
+ require 'rgeoserver'
7
+
8
+ # The source catalog is a GeoServer instance version 2.1.0
9
+ $source_gs = RGeoServer::Catalog.new :url=> 'https://oldgeodata.example.com/geoserver/rest', :user=>'admin', :password=>'changeme'
10
+
11
+ # The target catalog is a GeoServer instance version 2.1.3
12
+ $target_gs = RGeoServer::Catalog.new :url=> 'http://newgeodata.example.com/geoserver/rest', :user=> 'admin', :password => 'geoserver'
13
+
14
+ # We don't migrate all workspaces except the following:
15
+ $workspaces_to_migrate = [
16
+ 'orbis',
17
+ 'barrington',
18
+ 'authorial_london',
19
+ 'rhine',
20
+ 'Operas'
21
+ ]
22
+
23
+ # Cleanup target. Comment out if this runs in succesive trials
24
+ $target_gs.get_workspaces.each do |w| w.delete :recurse=> true end
25
+
26
+ # Migrate styles
27
+ $source_gs.get_styles.each do |s_s|
28
+ s_t = RGeoServer::Style.new $target_gs, :name => s_s.name
29
+ s_t.sld_doc = s_s.sld_doc
30
+ begin
31
+ s_t.save
32
+ rescue Exception => e
33
+ puts "Error creating style #{s_s.name}:\n #{e}"
34
+ end
35
+ end
36
+
37
+ # Migrate workspaces
38
+ $source_gs.get_workspaces.each do |ws_s|
39
+ next unless $workspaces_to_migrate.include? ws_s.name
40
+ ws_t = RGeoServer::Workspace.new $target_gs, :name => ws_s.name
41
+ if ws_t.new?
42
+ puts "Creating workspace #{ws_s.name} in #{$target_gs}"
43
+ ws_t.save
44
+ # Synchronize namespaces
45
+ ns_s = RGeoServer::Namespace.new $source_gs, :name => ws_t.name
46
+ ns_t = RGeoServer::Namespace.new $target_gs, :name => ns_s.name, :uri => ns_s.uri
47
+ ns_t.save
48
+ end
49
+
50
+ # Migrate data stores per workspace
51
+ ws_s.data_stores.each do |ds_s|
52
+ ds_t = RGeoServer::DataStore.new $target_gs, :name => ds_s.name, :workspace => ws_s
53
+ puts "Creating datastore #{ds_s.name} in #{$target_gs}/workspaces/#{ws_s.name}"
54
+ ds_t.connection_parameters = ds_s.connection_parameters
55
+ ds_t.enabled = ds_s.enabled
56
+ begin
57
+ ds_t.save
58
+ rescue Exception => e
59
+ puts "Error creating data store #{ds_s.name}, workspace #{ws_s.name}:\n #{e}"
60
+ end
61
+ # Migrate feature types
62
+ ds_s.featuretypes.each do |ft_s|
63
+ ft_t = RGeoServer::FeatureType.new $target_gs, :name => ft_s.name, :workspace => ws_s, :data_store => ds_t
64
+ begin
65
+ ft_t.save
66
+ rescue Exception => e
67
+ puts "Error creating feature type #{ft_s.name}, workspace #{ws_s.name}, datastore #{ds_t.name}:\n #{e}"
68
+ end
69
+ end
70
+ end
71
+
72
+ # Coverage stores
73
+ ws_s.coverage_stores.each do |cs_s|
74
+ cs_t = RGeoServer::CoverageStore.new $target_gs, :name => cs_s.name, :workspace => ws_s
75
+ cs_t.description = cs_s.description
76
+ cs_t.enabled = cs_s.enabled
77
+ cs_t.data_type = cs_s.data_type
78
+ cs_t.url = cs_s.url
79
+ begin
80
+ cs_t.save
81
+ puts "Coverage store #{cs_s.name}, workspace #{ws_s.name} was successfully created"
82
+ rescue Exception => e
83
+ puts "Error creating coverage store #{cs_s.name}, workspace #{ws_s.name}:\n #{e}"
84
+ end
85
+ # Coverages
86
+ cs_s.coverages.each do |c_s|
87
+ c_t = RGeoServer::Coverage.new $target_gs, :name => c_s.name, :workspace => ws_s, :coverage_store => cs_t
88
+ c_t.title = c_s.title
89
+ begin
90
+ c_t.save
91
+ puts "Coverage layer #{c_s.name}, workspace #{ws_s.name} was successfully created"
92
+ rescue Exception => e
93
+ puts "Error creating coverage layer #{c_s.name}, workspace #{ws_s.name}:\n #{e}, coveragestore #{cs_t.name}"
94
+ end
95
+ end
96
+ end
97
+
98
+ end
@@ -0,0 +1,90 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ # RGeoServer Example for creating a layer with a database store
4
+ # Tested with GeoServer version 2.1.3 and PosgreSQL 9.1.1. with Postgis 2.0
5
+
6
+ require 'rgeoserver'
7
+
8
+ $catalog = RGeoServer::Catalog.new :url => 'http://localhost:8080/geoserver/rest', :user => 'admin', :password => 'geoserver'
9
+
10
+ # 1. Register a POSTGIS database as data store in GeoServer
11
+ connection_parameters = {
12
+ "Connection timeout" => "20",
13
+ "port" => "5432",
14
+ "database" => "geodata",
15
+ "schema" => "public",
16
+ "user" => "geouser",
17
+ "passwd" => "geopass",
18
+ "dbtype" => "postgis",
19
+ "host" => "localhost",
20
+ "validate connections" => "false",
21
+ "max connections" => "10",
22
+ "namespace" => "rhine",
23
+ "Loose bbox" => "true",
24
+ "Expose primary keys" => "true",
25
+ "Max open prepared statements" => "50",
26
+ "fetch size" => "1000",
27
+ "preparedStatements" => "false",
28
+ "Estimated extends" => "true",
29
+ "min connections" => "1"
30
+ }
31
+
32
+
33
+ ds = RGeoServer::DataStore.new $catalog, :name => 'sql_example', :workspace => nil
34
+ ds.connection_parameters = connection_parameters
35
+ ds.enabled = 'true'
36
+
37
+ if ds.new?
38
+ puts "Creating datastore #{ds.name} in #{$catalog}/workspaces/default"
39
+ ds.save
40
+ end
41
+
42
+ # 2. We create a feature type to point to an actual table in the database.
43
+ # Make sure the user has privileges to access the table otherwise you will get a remote
44
+ # java.io.IOException: Error looking up primary key
45
+ # ...
46
+ # Caused by: org.postgresql.util.PSQLException: ERROR: permission denied for relation gnis_populated_places
47
+ # ...
48
+ # Caused by: org.postgresql.util.PSQLException: ERROR: permission denied for relation geometry_columns
49
+
50
+ ft = RGeoServer::FeatureType.new $catalog, :name => 'gnis_populated_places', :worskpace => nil, :data_store => ds
51
+ ft.save if ft.new?
52
+
53
+
54
+ # 3. Now we verify that a layer was created
55
+
56
+ lyr = RGeoServer::Layer.new $catalog, :name => 'gnis_populated_places'
57
+
58
+ # We test the layer has the right profile.
59
+ # This is not too honest since the profile was looked up first.
60
+ expected_profile = {
61
+ "name" => "gnis_populated_places",
62
+ "path" => "",
63
+ "default_style" => "point",
64
+ "alternate_styles" => [],
65
+ "type" => "VECTOR",
66
+ "enabled" => "true",
67
+ "queryable" => "",
68
+ "attribution" => {
69
+ "title" => "",
70
+ "logo_width" => "0",
71
+ "logo_height" => "0"
72
+ },
73
+ "resource" => {
74
+ "type" => "featureType",
75
+ "name" => "gnis_populated_places",
76
+ "store" => "sql_example",
77
+ "workspace" => "it.geosolutions"
78
+ },
79
+ "metadata" => {
80
+ "GWC.metaTilingX" => "4",
81
+ "GWC.autoCacheStyles" => "true",
82
+ "GWC.metaTilingY" => "4",
83
+ "GWC.gutter" => "0",
84
+ "GWC.enabled" => "true",
85
+ "GWC.gridSets"=> "EPSG:4326,EPSG:900913",
86
+ "GWC.cacheFormats" => "image/png,image/jpeg"
87
+ }
88
+ }
89
+ raise "Unexpected profile for layer" if lyr.profile != expected_profile
90
+
@@ -3,8 +3,24 @@ module RGeoServer
3
3
  # A coverage is a raster based data set which originates from a coverage store.
4
4
  class Coverage < ResourceInfo
5
5
 
6
- OBJ_ATTRIBUTES = {:catalog => "catalog", :workspace => "workspace", :coverage_store => "coverage_store", :name => "name", :title => "title", :abstract => "abstract", :metadata_links => "metadataLinks" }
7
- OBJ_DEFAULT_ATTRIBUTES = {:catalog => nil, :workspace => nil, :coverage_store => nil, :name => nil, :title => nil, :abstract => nil, :metadata_links => [] }
6
+ OBJ_ATTRIBUTES = {
7
+ :catalog => "catalog",
8
+ :workspace => "workspace",
9
+ :coverage_store => "coverage_store",
10
+ :name => "name",
11
+ :title => "title",
12
+ :abstract => "abstract",
13
+ :metadata_links => "metadataLinks"
14
+ }
15
+ OBJ_DEFAULT_ATTRIBUTES = {
16
+ :catalog => nil,
17
+ :workspace => nil,
18
+ :coverage_store => nil,
19
+ :name => nil,
20
+ :title => nil,
21
+ :abstract => nil,
22
+ :metadata_links => []
23
+ }
8
24
 
9
25
  define_attribute_methods OBJ_ATTRIBUTES.keys
10
26
  update_attribute_accessors OBJ_ATTRIBUTES
@@ -76,7 +92,6 @@ module RGeoServer
76
92
  end
77
93
 
78
94
  @name = options[:name]
79
- @title = options[:title]
80
95
  @enabled = options[:enabled] || true
81
96
  @route = route
82
97
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgeoserver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8.1
4
+ version: 0.5.8.2
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: 2012-06-14 00:00:00.000000000 Z
12
+ date: 2012-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
16
- requirement: &2151936520 !ruby/object:Gem::Requirement
16
+ requirement: &2168525160 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2151936520
24
+ version_requirements: *2168525160
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &2155991260 !ruby/object:Gem::Requirement
27
+ requirement: &2168523780 !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: *2155991260
35
+ version_requirements: *2168523780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: mime-types
38
- requirement: &2155988260 !ruby/object:Gem::Requirement
38
+ requirement: &2168522560 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2155988260
46
+ version_requirements: *2168522560
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: activesupport
49
- requirement: &2155986300 !ruby/object:Gem::Requirement
49
+ requirement: &2168521620 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2155986300
57
+ version_requirements: *2168521620
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: activemodel
60
- requirement: &2155984220 !ruby/object:Gem::Requirement
60
+ requirement: &2168520480 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2155984220
68
+ version_requirements: *2168520480
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: confstruct
71
- requirement: &2155993900 !ruby/object:Gem::Requirement
71
+ requirement: &2168519740 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *2155993900
79
+ version_requirements: *2168519740
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rake
82
- requirement: &2155992460 !ruby/object:Gem::Requirement
82
+ requirement: &2168518980 !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: :development
89
89
  prerelease: false
90
- version_requirements: *2155992460
90
+ version_requirements: *2168518980
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: shoulda
93
- requirement: &2156006540 !ruby/object:Gem::Requirement
93
+ requirement: &2168518360 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2156006540
101
+ version_requirements: *2168518360
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: bundler
104
- requirement: &2156005180 !ruby/object:Gem::Requirement
104
+ requirement: &2168517680 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 1.0.14
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *2156005180
112
+ version_requirements: *2168517680
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rspec
115
- requirement: &2156003480 !ruby/object:Gem::Requirement
115
+ requirement: &2152028760 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *2156003480
123
+ version_requirements: *2152028760
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: yard
126
- requirement: &2156001180 !ruby/object:Gem::Requirement
126
+ requirement: &2152026840 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *2156001180
134
+ version_requirements: *2152026840
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: equivalent-xml
137
- requirement: &2156015680 !ruby/object:Gem::Requirement
137
+ requirement: &2152026080 !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: :development
144
144
  prerelease: false
145
- version_requirements: *2156015680
145
+ version_requirements: *2152026080
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: jettywrapper
148
- requirement: &2156013180 !ruby/object:Gem::Requirement
148
+ requirement: &2152025360 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,7 +153,7 @@ dependencies:
153
153
  version: '0'
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *2156013180
156
+ version_requirements: *2152025360
157
157
  description: ! 'GeoServer REST API Ruby library : Requires GeoServer 2.1.3+'
158
158
  email:
159
159
  - renzo.sanchez.silva@gmail.com
@@ -169,7 +169,9 @@ files:
169
169
  - VERSION
170
170
  - config/config_defaults.yml
171
171
  - examples/batch_example.rb
172
+ - examples/catalog_migration.rb
172
173
  - examples/cluster_demo.rb
174
+ - examples/sql_layer_demo.rb
173
175
  - lib/rgeoserver.rb
174
176
  - lib/rgeoserver/catalog.rb
175
177
  - lib/rgeoserver/config.rb
@@ -232,7 +234,9 @@ specification_version: 3
232
234
  summary: GeoServer REST API ruby library
233
235
  test_files:
234
236
  - examples/batch_example.rb
237
+ - examples/catalog_migration.rb
235
238
  - examples/cluster_demo.rb
239
+ - examples/sql_layer_demo.rb
236
240
  - spec/fixtures/datasets/raster/test.tif
237
241
  - spec/fixtures/datasets/vector/granules.dbf
238
242
  - spec/fixtures/datasets/vector/granules.prj