rgeoserver 0.5.9 → 0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -1
- data/Gemfile +1 -7
- data/Gemfile.lock +147 -0
- data/README.rdoc +69 -78
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/bin/batch_load.rb +138 -0
- data/config/defaults.yml +17 -0
- data/examples/batch_demo.rb +170 -0
- data/examples/catalog_migration.rb +2 -2
- data/examples/cluster_demo.rb +1 -1
- data/examples/coverage_stores.rb +42 -0
- data/examples/demo_druid_workspace.rb +6 -0
- data/examples/deploy_dor_layer.rb +19 -0
- data/examples/sql_layer_demo.rb +1 -1
- data/lib/rgeoserver/catalog.rb +83 -86
- data/lib/rgeoserver/config.rb +11 -1
- data/lib/rgeoserver/coverage.rb +43 -15
- data/lib/rgeoserver/coveragestore.rb +46 -11
- data/lib/rgeoserver/datastore.rb +73 -62
- data/lib/rgeoserver/featuretype.rb +134 -71
- data/lib/rgeoserver/geoserver_url_helpers.rb +140 -10
- data/lib/rgeoserver/layer.rb +52 -16
- data/lib/rgeoserver/layergroup.rb +1 -2
- data/lib/rgeoserver/namespace.rb +1 -2
- data/lib/rgeoserver/resource.rb +37 -34
- data/lib/rgeoserver/rest_api_client.rb +33 -14
- data/lib/rgeoserver/style.rb +1 -2
- data/lib/rgeoserver/utils/boundingbox.rb +59 -16
- data/lib/rgeoserver/utils/metadata.rb +21 -0
- data/lib/rgeoserver/version.rb +1 -1
- data/lib/rgeoserver/wmsstore.rb +1 -6
- data/lib/rgeoserver/workspace.rb +23 -8
- data/lib/rgeoserver.rb +31 -38
- data/rgeoserver.gemspec +28 -20
- data/spec/fixtures/load_ex1.yml +45 -0
- data/spec/fixtures/load_ex2.yml +14 -0
- data/spec/functional/catalog_spec.rb +71 -0
- data/spec/functional/rest_api_client_spec.rb +215 -0
- data/spec/integration/geoserver_spec.rb +2 -2
- metadata +120 -66
- data/config/config_defaults.yml +0 -10
- data/examples/batch_example.rb +0 -105
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
rgeoserver (0.7)
|
|
5
|
+
activemodel (~> 3.2.0)
|
|
6
|
+
activesupport (~> 3.2.0)
|
|
7
|
+
confstruct (~> 0.2.0)
|
|
8
|
+
mime-types (~> 2.0)
|
|
9
|
+
nokogiri (~> 1.6.0)
|
|
10
|
+
rest-client (~> 1.6.0)
|
|
11
|
+
rgeo (~> 0.3.0)
|
|
12
|
+
rgeo-shapefile (~> 0.2.0)
|
|
13
|
+
rubyzip (~> 0.9.0)
|
|
14
|
+
|
|
15
|
+
GEM
|
|
16
|
+
remote: https://rubygems.org/
|
|
17
|
+
specs:
|
|
18
|
+
activemodel (3.2.16)
|
|
19
|
+
activesupport (= 3.2.16)
|
|
20
|
+
builder (~> 3.0.0)
|
|
21
|
+
activesupport (3.2.16)
|
|
22
|
+
i18n (~> 0.6, >= 0.6.4)
|
|
23
|
+
multi_json (~> 1.0)
|
|
24
|
+
alias (0.2.3)
|
|
25
|
+
awesome_print (1.2.0)
|
|
26
|
+
binding.repl (0.8.0)
|
|
27
|
+
boson (1.2.4)
|
|
28
|
+
boson-more (0.2.2)
|
|
29
|
+
boson (>= 1.2.0)
|
|
30
|
+
builder (3.0.4)
|
|
31
|
+
childprocess (0.3.9)
|
|
32
|
+
ffi (~> 1.0, >= 1.0.11)
|
|
33
|
+
clipboard (1.0.5)
|
|
34
|
+
coderay (1.1.0)
|
|
35
|
+
columnize (0.3.6)
|
|
36
|
+
confstruct (0.2.5)
|
|
37
|
+
dbf (2.0.7)
|
|
38
|
+
fastercsv (~> 1.5.4)
|
|
39
|
+
debugger (1.6.3)
|
|
40
|
+
columnize (>= 0.3.1)
|
|
41
|
+
debugger-linecache (~> 1.2.0)
|
|
42
|
+
debugger-ruby_core_source (~> 1.2.4)
|
|
43
|
+
debugger-linecache (1.2.0)
|
|
44
|
+
debugger-ruby_core_source (1.2.4)
|
|
45
|
+
diff-lcs (1.2.5)
|
|
46
|
+
equivalent-xml (0.4.0)
|
|
47
|
+
nokogiri (>= 1.4.3)
|
|
48
|
+
every_day_irb (1.5.1)
|
|
49
|
+
fancy_irb (0.7.3)
|
|
50
|
+
paint (>= 0.8.1)
|
|
51
|
+
unicode-display_width (>= 0.1.1)
|
|
52
|
+
fastercsv (1.5.5)
|
|
53
|
+
ffi (1.9.3)
|
|
54
|
+
g (1.7.2)
|
|
55
|
+
hirb (0.7.1)
|
|
56
|
+
i18n (0.6.9)
|
|
57
|
+
interactive_editor (0.0.10)
|
|
58
|
+
spoon (>= 0.0.1)
|
|
59
|
+
irbtools (1.5.1)
|
|
60
|
+
alias (~> 0.2.3)
|
|
61
|
+
awesome_print (~> 1.2.0)
|
|
62
|
+
binding.repl (>= 0.7.0)
|
|
63
|
+
boson (~> 1.2.4)
|
|
64
|
+
boson-more (~> 0.2.2)
|
|
65
|
+
clipboard (~> 1.0.5)
|
|
66
|
+
coderay (~> 1.1.0)
|
|
67
|
+
every_day_irb (>= 1.5.1)
|
|
68
|
+
fancy_irb (>= 0.7.3)
|
|
69
|
+
g (>= 1.7.2)
|
|
70
|
+
hirb (~> 0.7.1)
|
|
71
|
+
interactive_editor (>= 0.0.10)
|
|
72
|
+
method_locator (>= 0.0.4)
|
|
73
|
+
method_source (>= 0.8.2)
|
|
74
|
+
methodfinder (>= 1.2.5)
|
|
75
|
+
ori (~> 0.1.0)
|
|
76
|
+
paint (>= 0.8.6)
|
|
77
|
+
wirb (>= 1.0.2)
|
|
78
|
+
zucker (>= 13.1)
|
|
79
|
+
jettywrapper (1.5.0)
|
|
80
|
+
activesupport (>= 3.0.0)
|
|
81
|
+
childprocess
|
|
82
|
+
i18n
|
|
83
|
+
logger
|
|
84
|
+
mediashelf-loggable
|
|
85
|
+
logger (1.2.8)
|
|
86
|
+
mediashelf-loggable (0.4.9)
|
|
87
|
+
method_locator (0.0.4)
|
|
88
|
+
method_source (0.8.2)
|
|
89
|
+
methodfinder (2.0.0)
|
|
90
|
+
mime-types (2.0)
|
|
91
|
+
mini_portile (0.5.2)
|
|
92
|
+
multi_json (1.8.2)
|
|
93
|
+
nokogiri (1.6.1)
|
|
94
|
+
mini_portile (~> 0.5.0)
|
|
95
|
+
ori (0.1.0)
|
|
96
|
+
paint (0.8.6)
|
|
97
|
+
pry (0.9.12.4)
|
|
98
|
+
coderay (~> 1.0)
|
|
99
|
+
method_source (~> 0.8)
|
|
100
|
+
slop (~> 3.4)
|
|
101
|
+
rake (10.1.0)
|
|
102
|
+
rest-client (1.6.7)
|
|
103
|
+
mime-types (>= 1.16)
|
|
104
|
+
rgeo (0.3.20)
|
|
105
|
+
rgeo-shapefile (0.2.3)
|
|
106
|
+
dbf (>= 1.7.0)
|
|
107
|
+
rgeo (>= 0.3.3)
|
|
108
|
+
rspec (2.14.1)
|
|
109
|
+
rspec-core (~> 2.14.0)
|
|
110
|
+
rspec-expectations (~> 2.14.0)
|
|
111
|
+
rspec-mocks (~> 2.14.0)
|
|
112
|
+
rspec-core (2.14.7)
|
|
113
|
+
rspec-expectations (2.14.4)
|
|
114
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
115
|
+
rspec-mocks (2.14.4)
|
|
116
|
+
rubyzip (0.9.9)
|
|
117
|
+
shoulda (3.5.0)
|
|
118
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
|
119
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
|
120
|
+
shoulda-context (1.1.6)
|
|
121
|
+
shoulda-matchers (2.4.0)
|
|
122
|
+
activesupport (>= 3.0.0)
|
|
123
|
+
slop (3.4.7)
|
|
124
|
+
spoon (0.0.4)
|
|
125
|
+
ffi
|
|
126
|
+
unicode-display_width (0.1.1)
|
|
127
|
+
wirb (1.0.2)
|
|
128
|
+
paint
|
|
129
|
+
yard (0.8.7.3)
|
|
130
|
+
zucker (13.1)
|
|
131
|
+
|
|
132
|
+
PLATFORMS
|
|
133
|
+
ruby
|
|
134
|
+
|
|
135
|
+
DEPENDENCIES
|
|
136
|
+
awesome_print
|
|
137
|
+
bundler (~> 1.0)
|
|
138
|
+
debugger (~> 1.0)
|
|
139
|
+
equivalent-xml
|
|
140
|
+
irbtools
|
|
141
|
+
jettywrapper
|
|
142
|
+
pry
|
|
143
|
+
rake
|
|
144
|
+
rgeoserver!
|
|
145
|
+
rspec
|
|
146
|
+
shoulda
|
|
147
|
+
yard
|
data/README.rdoc
CHANGED
|
@@ -1,35 +1,40 @@
|
|
|
1
|
-
{<img src="https://gemnasium.com/rnz0/rgeoserver.png" alt="Dependency Status" />}[https://gemnasium.com/rnz0/rgeoserver]
|
|
2
|
-
{<img src="https://secure.travis-ci.org/rnz0/rgeoserver.png" />}[http://travis-ci.org/rnz0/rgeoserver]
|
|
3
|
-
|
|
4
1
|
== RGeoServer
|
|
5
2
|
|
|
6
3
|
RGeoServer is a Ruby client for the GeoServer RESTful Configuration interface.
|
|
7
4
|
|
|
5
|
+
Requirements:
|
|
6
|
+
* {GeoServer}[http://geoserver.org] 2.1.3 or later.
|
|
7
|
+
* Ruby 1.9.3
|
|
8
|
+
|
|
8
9
|
It provides primitive Ruby model abstraction.
|
|
9
10
|
|
|
10
11
|
== Documentation
|
|
11
|
-
The GeoServer REST Configuration API Reference can be found here:
|
|
12
12
|
|
|
13
|
-
http://docs.geoserver.org/stable/en/user/rest/index.html
|
|
13
|
+
See the {GeoServer REST Configuration API Reference}[http://docs.geoserver.org/stable/en/user/rest/index.html]
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
== Installation
|
|
17
16
|
|
|
18
17
|
$ gem install rgeoserver
|
|
19
18
|
|
|
20
|
-
|
|
21
19
|
== Example:
|
|
22
20
|
|
|
23
|
-
Sample usage from an irb console
|
|
21
|
+
Sample usage from an irb console, using a GeoServer installation with a topp workspace.
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
>
|
|
23
|
+
$ rake console
|
|
24
|
+
> require 'rgeoserver'
|
|
25
|
+
> catalog = RGeoServer::Catalog.new
|
|
26
|
+
=> Catalog: http://localhost:8080/geoserver/rest
|
|
27
|
+
> w = catalog.get_default_workspace
|
|
28
28
|
=> RGeoServer::Workspace: topp
|
|
29
29
|
> ds = w.data_stores.first
|
|
30
30
|
=> RGeoServer::DataStore: states_shapefile
|
|
31
31
|
> ds.profile
|
|
32
|
-
=> {"name"=>"states_shapefile",
|
|
32
|
+
=> {"name"=>"states_shapefile",
|
|
33
|
+
"enabled"=>"true",
|
|
34
|
+
"connectionParameters"=>{
|
|
35
|
+
"url"=>"file:data/shapefiles/states.shp",
|
|
36
|
+
"namespace"=>"http://www.openplans.org/topp"},
|
|
37
|
+
"featureTypes"=>["states"]}
|
|
33
38
|
> ft = ds.featuretypes.first
|
|
34
39
|
=> RGeoServer::FeatureType: states
|
|
35
40
|
> ft.profile
|
|
@@ -38,101 +43,85 @@ Sample usage from an irb console
|
|
|
38
43
|
> lyr = RGeoServer::Layer.new c, :name => 'Arc_Sample'
|
|
39
44
|
=> RGeoServer::Layer: Arc_Sample
|
|
40
45
|
> lyr.profile
|
|
41
|
-
=> {"name"=>"Arc_Sample",
|
|
46
|
+
=> {"name"=>"Arc_Sample",
|
|
47
|
+
"path"=>"/",
|
|
48
|
+
"defaultstyle"=>"rain",
|
|
49
|
+
"styles"=>["raster"],
|
|
50
|
+
"type"=>"RASTER",
|
|
51
|
+
"enabled"=>"true",
|
|
52
|
+
"attribution"=>{"logoWidth"=>"0", "logoHeight"=>"0"},
|
|
53
|
+
"resource"=>{
|
|
54
|
+
"type"=>"coverage",
|
|
55
|
+
"name"=>"Arc_Sample",
|
|
56
|
+
"store"=>"arcGridSample",
|
|
57
|
+
"workspace"=>"nurc"},
|
|
58
|
+
"metadata"=>{
|
|
59
|
+
"GWC.autoCacheStyles"=>"true",
|
|
60
|
+
"GWC.metaTilingX"=>"4",
|
|
61
|
+
"GWC.metaTilingY"=>"4",
|
|
62
|
+
"GWC.gutter"=>"0",
|
|
63
|
+
"GWC.cachedNonDefaultStyles"=>"raster",
|
|
64
|
+
"GWC.enabled"=>"true",
|
|
65
|
+
"GWC.cacheFormats"=>"image/jpeg,image/png",
|
|
66
|
+
"GWC.gridSets"=>"EPSG:4326,EPSG:900913"}}
|
|
42
67
|
> sld = lyr.styles.first
|
|
43
68
|
=> RGeoServer::Style: raster
|
|
44
69
|
> sld.profile
|
|
45
|
-
=> {"name"=>"raster",
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
require 'rgeoserver'
|
|
51
|
-
|
|
52
|
-
layers = {
|
|
53
|
-
'south_america_1787' => {
|
|
54
|
-
'url' => 'file:///geo_data/rumsey/g0411047.tif',
|
|
55
|
-
'description' => "Map of South America by D'Anville",
|
|
56
|
-
'type' => 'GeoTIFF'
|
|
57
|
-
},
|
|
58
|
-
'city_of_san_francisco_1859' => {
|
|
59
|
-
'url' => 'file:///geo_data/rumsey/g1030000alpha.tif',
|
|
60
|
-
'description' => 'Map of San Francisco by the U.S. Coast Survey, with detail of the unsettled lands',
|
|
61
|
-
'type' => 'GeoTIFF'
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
(1..7).each do |cat_id|
|
|
66
|
-
cat = RGeoServer::Catalog.new :user=>'admin', :url => "http://geoserver-app#{cat_id}/rest", :password => "osgeo!"
|
|
67
|
-
ws = cat.get_default_workspace
|
|
68
|
-
cat.list(RGeoServer::CoverageStore, layers.keys, :workspace => ws) do |cs|
|
|
69
|
-
cs.url = layers[cs.name]['url']
|
|
70
|
-
cs.data_type = layers[cs.name]['type']
|
|
71
|
-
cs.enabled = 'true'
|
|
72
|
-
cs.save
|
|
73
|
-
# Create the corresponding layer
|
|
74
|
-
c = RGeoServer::Coverage.new cat, :workspace => ws, :coverage_store => cs, :name => cs.name
|
|
75
|
-
c.title = cs_name.gsub('_',' ').titleize
|
|
76
|
-
c.abstract = layers[cs.name]['description']
|
|
77
|
-
c.save
|
|
78
|
-
# Seed the tile cache
|
|
79
|
-
l = RGeoServer::Layer.new cat, :name => cs.name
|
|
80
|
-
l.seed :issue, {
|
|
81
|
-
:srs => {
|
|
82
|
-
:number => 4326
|
|
83
|
-
},
|
|
84
|
-
:zoomStart => 1,
|
|
85
|
-
:zoomStop => 10,
|
|
86
|
-
:format => 'image/png',
|
|
87
|
-
:threadCount => 1
|
|
88
|
-
}
|
|
89
|
-
end
|
|
90
|
-
end
|
|
70
|
+
=> {"name"=>"raster",
|
|
71
|
+
"sld_version"=>"1.0.0",
|
|
72
|
+
"filename"=>"raster.sld",
|
|
73
|
+
"sld"=>{"sld_name"=>"raster", "sld_title"=>"Default Raster"}}
|
|
91
74
|
|
|
92
75
|
|
|
76
|
+
See *examples* directory for more examples.
|
|
77
|
+
|
|
93
78
|
== Testing
|
|
79
|
+
|
|
94
80
|
We use {jettywrapper}[https://github.com/projecthydra/jettywrapper] to wrap a test instance of GeoServer. In theory, you should be able to point to any other local installation. Suppose that you download the binary stable version 2.1.3 binary from {here}[http://sourceforge.net/project/downloading.php?groupname=geoserver&filename=geoserver-2.1.3-bin.zip&use_mirror=softlayer], then unzip it under say, /tmp/geoserver-2.1.3. The integration tests are executed as follows:
|
|
95
|
-
|
|
81
|
+
|
|
82
|
+
$ rake integration
|
|
96
83
|
|
|
97
84
|
If you have the test instance running already on port 8080, you can run the tests simply with:
|
|
98
85
|
|
|
99
86
|
$ rake
|
|
100
87
|
|
|
101
88
|
To generate the documentation run:
|
|
89
|
+
|
|
102
90
|
$ rake yard
|
|
103
91
|
|
|
104
|
-
To enter into an irb console with all
|
|
92
|
+
To enter into an irb console with all classes loaded:
|
|
93
|
+
|
|
105
94
|
$ rake console
|
|
106
95
|
|
|
107
96
|
== Logging
|
|
108
|
-
For now we use {RestClient's}[https://github.com/archiloque/rest-client] base logger. It can be enabled by setting:
|
|
109
97
|
|
|
110
|
-
|
|
98
|
+
To enable logging from {RestClient's}[https://github.com/archiloque/rest-client] base logger, add an entry in your `config.yml` for stdout/stderr or a file:
|
|
99
|
+
|
|
100
|
+
geoserver:
|
|
101
|
+
logfile: stderr
|
|
111
102
|
|
|
112
|
-
or
|
|
103
|
+
or
|
|
113
104
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
# => 200 OK | application/xml 662 bytes
|
|
117
|
-
RestClient.get "http://localhost:8080/geoserver/rest/workspaces/cite/coveragestores/city_of_san_francisco_1859.xml", "Accept"=>"application/xml", "Accept-Encoding"=>"gzip, deflate", "Content-Type"=>"application/xml"
|
|
118
|
-
# => 404 NotFound | text/plain 73 bytes
|
|
119
|
-
RestClient.post "http://localhost:8080/geoserver/rest/workspaces/cite/coveragestores", "<?xml version=\"1.0\"?>\n<coverageStore>\n <name>city_of_san_francisco_1859</name>\n <workspace>\n <name>cite</name>\n </workspace>\n <enabled>true</enabled>\n <type>GeoTIFF</type>\n <description>Map of San Francisco by the U.S. Coast Survey, with detail of the unsettled lands</description>\n <url>file:///geo_data/rumsey/g1030000alpha.tif</url>\n</coverageStore>\n", "Accept"=>"application/xml", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"363", "Content-Type"=>"application/xml"
|
|
120
|
-
# => 201 Created | 0 bytes
|
|
105
|
+
geoserver:
|
|
106
|
+
logfile: 'rgeoserver.log'
|
|
121
107
|
|
|
122
108
|
|
|
123
109
|
== Related Resources
|
|
110
|
+
|
|
124
111
|
* {OSGeo The Open Source Geospatial Foundation}[http://www.osgeo.org]
|
|
125
|
-
* {GeoServer
|
|
126
|
-
* {
|
|
112
|
+
* {GeoServer}[http://geoserver.org]
|
|
113
|
+
* {Catalog design}[http://bit.ly/JrX1J8]
|
|
127
114
|
* {GeoTools}[http://geotools.org/]
|
|
128
115
|
* Implementation in other languages:
|
|
129
116
|
* Python: {gsconfig.py}[https://github.com/dwins/gsconfig.py]
|
|
130
117
|
|
|
131
118
|
== Release History
|
|
132
119
|
|
|
120
|
+
- <b>v0.7</b> - Major update with keywords, YAML config, REST API, unit testing and cleanup
|
|
133
121
|
- <b>v0.5</b> - Initial alpha release
|
|
134
122
|
|
|
135
123
|
== TODO
|
|
124
|
+
|
|
136
125
|
- Complete data stores and coverages functionality and data upload.
|
|
137
126
|
- Complete updating data in objects. On failure, objects should roll back.
|
|
138
127
|
- Complete documentation.
|
|
@@ -143,12 +132,12 @@ or set an environment variable, for example:
|
|
|
143
132
|
- Provide more examples:
|
|
144
133
|
- Customize configuration.
|
|
145
134
|
- Connect under SSL.
|
|
146
|
-
- Batch processing.
|
|
147
135
|
- Migrate base HTTP client to {Faraday}[https://github.com/technoweenie/faraday]?
|
|
148
136
|
- Curlify operations: To provide optional log/output of the curl command that would produce the same
|
|
149
137
|
result as the ResourceInfo#save method.
|
|
150
138
|
|
|
151
139
|
== Contributing with Patches and Pull requests checklist
|
|
140
|
+
|
|
152
141
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
|
153
142
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
|
154
143
|
* Fork the project
|
|
@@ -159,17 +148,19 @@ result as the ResourceInfo#save method.
|
|
|
159
148
|
|
|
160
149
|
|
|
161
150
|
== Acknowledgements
|
|
151
|
+
|
|
162
152
|
Inspired on the {Rubydora}[https://github.com/cbeer/rubydora] gem. Followed somewhat closely to {gsconfig.py}[https://github.com/dwins/gsconfig.py]
|
|
163
153
|
|
|
164
154
|
== Contributors
|
|
155
|
+
|
|
165
156
|
This package is supported and maintained by Stanford University Libraries.
|
|
166
157
|
|
|
167
|
-
|
|
158
|
+
* Renzo Sanchez-Silva <renzo.sanchez.silva@gmail.com> (Original Author)
|
|
159
|
+
* Bess Sadler <bess@stanford.edu>
|
|
160
|
+
* Darren Hardy <drh@stanford.edu>
|
|
168
161
|
|
|
169
162
|
== License
|
|
170
163
|
|
|
171
|
-
Copyright (c) 2012 Stanford University
|
|
172
|
-
|
|
173
|
-
Author: Renzo Sanchez-Silva <renzo.sanchez.silva@gmail.com>.
|
|
164
|
+
Copyright (c) 2012-2013 Stanford University
|
|
174
165
|
|
|
175
166
|
Licensed under the Apache License, Version 2.0
|
data/Rakefile
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
2
|
require 'bundler'
|
|
3
3
|
require 'bundler/gem_tasks'
|
|
4
|
+
# require 'version_bumper'
|
|
4
5
|
|
|
5
6
|
begin
|
|
6
7
|
Bundler.setup(:default, :development)
|
|
@@ -29,7 +30,7 @@ end
|
|
|
29
30
|
|
|
30
31
|
desc "Open an irb session preloaded with this library"
|
|
31
32
|
task :console do
|
|
32
|
-
sh "irb -rubygems -I lib -r rgeoserver.rb"
|
|
33
|
+
sh "irb --simple-prompt -rubygems -I lib -r rgeoserver.rb"
|
|
33
34
|
end
|
|
34
35
|
|
|
35
36
|
desc "Execute integration tests"
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.7
|
data/bin/batch_load.rb
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# -*- encoding : utf-8 -*-
|
|
3
|
+
#
|
|
4
|
+
# RGeoServer Batch load layers (batch_demo.rb)
|
|
5
|
+
# Usage: #{File.basename(__FILE__)} [input.yml]
|
|
6
|
+
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
require 'yaml'
|
|
9
|
+
require 'rgeoserver'
|
|
10
|
+
require 'awesome_print'
|
|
11
|
+
require 'optparse'
|
|
12
|
+
|
|
13
|
+
#= Input data. *See DATA section at end of file*
|
|
14
|
+
# The input file is in YAML syntax with each record is a Hash with keys:
|
|
15
|
+
# - layername
|
|
16
|
+
# - filename
|
|
17
|
+
# - format
|
|
18
|
+
# - title
|
|
19
|
+
# and optionally
|
|
20
|
+
# - description
|
|
21
|
+
# - keywords
|
|
22
|
+
# - metadata_links
|
|
23
|
+
|
|
24
|
+
#= Configuration constants
|
|
25
|
+
WORKSPACE_NAME = 'rgeoserver'
|
|
26
|
+
NAMESPACE = 'urn:rgeoserver'
|
|
27
|
+
|
|
28
|
+
# GeoWebCache configuration
|
|
29
|
+
SEED = true
|
|
30
|
+
SEED_OPTIONS = {
|
|
31
|
+
:srs => {
|
|
32
|
+
:number => 4326
|
|
33
|
+
},
|
|
34
|
+
:zoomStart => 1,
|
|
35
|
+
:zoomStop => 8,
|
|
36
|
+
:format => 'image/png',
|
|
37
|
+
:threadCount => 1
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
def main layers, flags = {}
|
|
41
|
+
return unless layers
|
|
42
|
+
datadir = flags[:datadir]
|
|
43
|
+
# Connect to the GeoServer catalog
|
|
44
|
+
cat = RGeoServer::Catalog.new
|
|
45
|
+
|
|
46
|
+
# Obtain a handle to the workspace and clean it up.
|
|
47
|
+
ws = RGeoServer::Workspace.new cat, :name => WORKSPACE_NAME
|
|
48
|
+
ws.delete :recurse => true if flags[:delete] and not ws.new?
|
|
49
|
+
ws.save if ws.new?
|
|
50
|
+
|
|
51
|
+
# Iterate over all records in YAML file and create stores in the catalog
|
|
52
|
+
layers.each do |k, v|
|
|
53
|
+
['layername', 'format', 'filename', 'title'].each do |id|
|
|
54
|
+
raise ArgumentError, "Layer is missing #{id}" unless v.include?(id)
|
|
55
|
+
end
|
|
56
|
+
ap v
|
|
57
|
+
|
|
58
|
+
layername = v['layername'].strip
|
|
59
|
+
format = v['format'].strip
|
|
60
|
+
|
|
61
|
+
ap "Layer: #{layername} #{format}"
|
|
62
|
+
if format == 'GeoTIFF'
|
|
63
|
+
# Create of a coverage store
|
|
64
|
+
cs = RGeoServer::CoverageStore.new cat, :workspace => ws, :name => layername
|
|
65
|
+
cs.url = File.join(datadir, v['filename'])
|
|
66
|
+
cs.description = v['description']
|
|
67
|
+
cs.enabled = 'true'
|
|
68
|
+
cs.data_type = format
|
|
69
|
+
cs.save
|
|
70
|
+
|
|
71
|
+
# Now create the actual coverage
|
|
72
|
+
cv = RGeoServer::Coverage.new cat, :workspace => ws, :coverage_store => cs, :name => layername
|
|
73
|
+
cv.title = v['title']
|
|
74
|
+
cv.keywords = v['keywords']
|
|
75
|
+
cv.metadata_links = v['metadata_links']
|
|
76
|
+
cv.save
|
|
77
|
+
|
|
78
|
+
elsif format == 'Shapefile'
|
|
79
|
+
# Create data stores for shapefiles
|
|
80
|
+
ds = RGeoServer::DataStore.new cat, :workspace => ws, :name => layername
|
|
81
|
+
ds.description = v['description']
|
|
82
|
+
ds.connection_parameters = {
|
|
83
|
+
"url" => File.join(datadir, v['filename']),
|
|
84
|
+
"namespace" => NAMESPACE
|
|
85
|
+
}
|
|
86
|
+
ds.enabled = 'true'
|
|
87
|
+
ds.save
|
|
88
|
+
|
|
89
|
+
ft = RGeoServer::FeatureType.new cat, :workspace => ws, :data_store => ds, :name => layername
|
|
90
|
+
ft.title = v['title']
|
|
91
|
+
ft.abstract = v['description']
|
|
92
|
+
ft.keywords = v['keywords']
|
|
93
|
+
ft.metadata_links = v['metadata_links']
|
|
94
|
+
ft.save
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Check if a layer has been created, extract some metadata
|
|
98
|
+
lyr = RGeoServer::Layer.new cat, :name => layername
|
|
99
|
+
if not lyr.new? and SEED
|
|
100
|
+
lyr.seed :issue, SEED_OPTIONS
|
|
101
|
+
else
|
|
102
|
+
raise NotImplementedError, "Unsupported format #{format}"
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
begin
|
|
108
|
+
flags = {
|
|
109
|
+
:delete => true,
|
|
110
|
+
:verbose => false,
|
|
111
|
+
:datadir => 'file:///data'
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
OptionParser.new do |opts|
|
|
115
|
+
opts.banner = "Usage: #{File.basename(__FILE__)} [-v] [--delete] [input.yml ...]"
|
|
116
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
|
117
|
+
flags[:verbose] = v
|
|
118
|
+
end
|
|
119
|
+
opts.on(nil, "--[no-]delete", "Delete workspaces recursively") do |v|
|
|
120
|
+
flags[:delete] = v
|
|
121
|
+
end
|
|
122
|
+
opts.on("-d DIR", "--datadir DIR", "Data directory on GeoServer (default: file:///data)") do |v|
|
|
123
|
+
flags[:datadir] = v
|
|
124
|
+
end
|
|
125
|
+
end.parse!
|
|
126
|
+
ap flags
|
|
127
|
+
|
|
128
|
+
if ARGV.size > 0
|
|
129
|
+
ARGV.each do |fn|
|
|
130
|
+
main(YAML::load_file(fn), flags)
|
|
131
|
+
end
|
|
132
|
+
else
|
|
133
|
+
main(YAML::load($stdin), flags)
|
|
134
|
+
end
|
|
135
|
+
rescue SystemCallError => e
|
|
136
|
+
$stderr.puts "ERROR: #{e.message}"
|
|
137
|
+
exit(-1)
|
|
138
|
+
end
|
data/config/defaults.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
geoserver:
|
|
2
|
+
# Set to the REST API for the GeoServer
|
|
3
|
+
url: "http://localhost:8080/geoserver/rest"
|
|
4
|
+
# Optional user/password, set to false to disable
|
|
5
|
+
user: "admin"
|
|
6
|
+
password: "admin"
|
|
7
|
+
# Set to your GWC server, or "builtin" for the one bundled with GeoServer
|
|
8
|
+
geowebcache_url: "builtin"
|
|
9
|
+
|
|
10
|
+
# RestClient:
|
|
11
|
+
restclient:
|
|
12
|
+
# Set to false to disable or stdout/stderr or 'filename.out'
|
|
13
|
+
logfile: 'rgeoserver.log' #stdout
|
|
14
|
+
# Timeout (in seconds)
|
|
15
|
+
timeout: 300
|
|
16
|
+
# Open Timeout (in seconds)
|
|
17
|
+
open_timeout: 60
|