nathanvda / geoserver_migrations Goto Github PK
View Code? Open in Web Editor NEWManage your geoserver configuration similar to ActiveRecord migrations
License: MIT License
Manage your geoserver configuration similar to ActiveRecord migrations
License: MIT License
At the moment we have a rails project which we can deploy for different clients, and obviously the geoserver environment also is not identical. The rails project we solve using configuration files, how do we solve this for the geoserver-migrations?
Ideas:
rails g geoserver_migrations:migrate --platform=platform_name
it will run all default + the specific migrations for that platform, and will assume all current migrations for other platforms as "run"E.g. something like
class AddTrees < GeoserverMigrations::Migration
platform "your-platform-name"
def run
heli_trees_sld = <<-SLD.strip_heredoc
<?xml version="1.0" encoding="UTF-8"?><sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" version="1.0.0">
<sld:NamedLayer>
... snipped for legibility
</sld:NamedLayer>
</sld:StyledLayerDescriptor>
SLD
create_layer :heli_trees do
sld heli_trees_sld
feature_name :topo_features
end
end
end
Additionally I can imagine adding the plural and singular form both, so something like
platform "your-platform"
or
platforms "your-platform1", "your-platform2"
(not sure if we should have square-brackets there or not?)
The DSL does collect a list of actions to generate, so when something fails halfway through, we should be able to pretty easily undo those changes.
E.g. delete styles and layers already created (in reverse order), ignoring errors of course because one of the last operations caused an error (e.g. the SLD is not correct or valid?).
If you have installed the CSS styling extension, can we then use the API to create such layers?
That would be awesome since SLD styles are so verbose.
I have now very simple SLD helpers which allow to build a SLD with a single polygon/icon/line and a filter. Something like the code in spec/fixtures/migrate_examples/migrate_with_icon/06_sld_helpers_tester.rb
class SldHelpersTester < GeoserverMigrations::Migration
def run
add_resource "deer.png"
create_layer :deers do
feature_name :deers
icon_style_with_label "Deers", "deer.png"
end
create_layer :alt_deers do
feature_name :deers
icon_style_with_label "ALT DEERS", "deer_with_hart.png", display_label: "Lieve hertjes", filter: {"active" => "true"}, max_scale_denominator: 15000
end
create_layer :moose do
feature_name :moose
polygon_style "MOOSE", display_label: "ELANDEN", max_scale_denominator: 15000
end
create_layer :alt_moose do
feature_name :moose
polygon_style "ALT MOOSE", display_label: "DOORZICHTIGE ELANDEN", max_scale_denominator: 15000, fill_opacity: "0.4"
end
create_layer :mice do
feature_name :mice
line_style "MICE", display_label: "MUIZEKES", max_scale_denominator: 21000, stroke_colour: "#80ff00", stroke_width: 8
end
create_layer :toads do
feature_name :toads
polygon_style "Toads", display_label: "Padden", max_scale_denominator: 25000, no_fill: true, stroke_colour: "#00ff00", stroke_width: 4, stroke_dasharray: "10.0 10.0"
end
create_layer :blackbirds do
feature_name :blackbirds
line_style "Blackbirds", display_label: "Raven", stroke_colour: "#00ff00", stroke_width: 3, filter: {"label" => "BLACK", "active" => "TRUE"}
end
end
end
This works fine if the SLD's remain as simple, but how do we handle a more difficult example, where we have to colour e.g. a line, based on an attribute?
E.g. something like
line_style "Blackbirds", rules: [
{display_label: "Zwarte Raven", stroke_colour: "#00ff00", stroke_width: 3, filter: {"label" => "BLACK", "active" => "TRUE"}},
{display_label: "Grijze Raven", stroke_colour: "#ffff00", stroke_width: 3, filter: {"label" => "GREY", "active" => "TRUE"}},
{display_label: "Rode Raven", stroke_colour: "#00ffff", stroke_width: 4, filter: {"label" => "RED", "active" => "TRUE"}},
]
So we can add different rules? Or should we still switch to a more dsl-y approach
sld "blackbirds" do
rule "Zwarte Raven" do
line_style "Blackbirds", display_label: "Zwarte Raven", stroke_colour: "#00ff00", stroke_width: 3, filter: {"label" => "BLACK", "active" => "TRUE"}
end
rule "RODE Raven" do
line_style "Blackbirds", display_label: "Rode Raven", stroke_colour: "#00ff00", stroke_width: 3, filter: {"label" => "RED", "active" => "TRUE"}
end
end
I can imagine rules could also be name-less? Not sure why they would have a name
and a display_label
?
Of course, much of this would simply go away if we support css-styles?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.