FOSS4G 2015, Seoul 14 th -19 th September 2015

advertisement
Mapping in GeoServer
with SLD and CSS
Ing. Andrea Aime
GeoSolutions
GeoSolutions

Founded in Italy in late 2006

Expertise



•
Image Processing, GeoSpatial Data Fusion
•
Java, Java Enterprise, C++, Python
•
JPEG2000, JPIP, Advanced 2D visualization
Supporting/Developing FOSS4G projects

GeoServer, MapStore

GeoNetwork, GeoNode, Ckan
Clients

Public Agencies

Private Companies
http://www.geo-solutions.it
FOSS4G 2015, Seoul
14th-19th September 2015
SLD vs CSS


Styled Layer Descriptor

OGC standard

XML based, verbose, hard to hand edit

Only showing relevant bits of the SLD
GeoCSS

CSS with extensions for map rendering

Simple, Compact, designed for human beings

Not a standard (several incompatible variants for
mapping, GeoServer one has nothing to do with
CartoDB/MapBox one)
FOSS4G 2015, Seoul
14th-19th September 2015
Point styling
FOSS4G 2015, Seoul
14th-19th September 2015
Simple symbol
* {
mark: symbol(triangle);
}
:mark {
fill: maroon;
}
FOSS4G 2015, Seoul
14th-19th September 2015
One symbol per point class (SLD)
• We want a
different symbol
per landmark
type
• 600 lines of XML
for 6 different
points types
• Too much
repetition
FOSS4G 2015, Seoul
14th-19th September 2015
One symbol per point class (css)
• Still an excerpt
• But 70 lines total
• Power of cascading
FOSS4G 2015, Seoul
14th-19th September 2015
Embedding attribute in url (css)
• Moved the image name in
the feature attributes
• Down to 15 lines
• The style is all here
FOSS4G 2015, Seoul
14th-19th September 2015
Using TTF fonts as marks
FOSS4G 2015, Seoul
14th-19th September 2015
Wind barbs mark
Full example available online in the GeoSolutions ND training material
FOSS4G 2015, Seoul
14th-19th September 2015
Filling polygons
FOSS4G-EU 2015, Como
14th-17th July 2015
Solid filling
* {
fill: lightgrey;
stroke: black;
stroke-width: 0.5;
}
FOSS4G-EU 2015, Como
14th-17th July 2015
Filling with repeating images
fill
FOSS4G-EU 2015, Como
14th-17th July 2015
Marks for Hatches
shape://vertiline
shape://horline
shape://slash
shape://backslash
shape://plus
shape://times
FOSS4G-EU 2015, Como
14th-17th July 2015
Filling with hatch marks
FOSS4G-EU 2015, Como
14th-17th July 2015
Using TTF fonts as marks
8
8
FOSS4G-EU 2015, Como
14th-17th July 2015
Painting lines
FOSS4G-EU 2015, Como
14th-17th July 2015
Solid lines
* {
stroke: darkOrange;
stroke-width: 5;
}
FOSS4G-EU 2015, Como
14th-17th July 2015
Dashes
FOSS4G-EU 2015, Como
14th-17th July 2015
Dashes with marks (SLD)
FOSS4G-EU 2015, Como
14th-17th July 2015
Dashes with marks (CSS)
* {
stroke: darkRed, symbol('circle');
stroke-dasharray: 10 14, 6 18;
stroke-dashoffset: 14, 0;
}
:stroke {
fill: darkRed;
size: 6;
}
FOSS4G-EU 2015, Como
14th-17th July 2015
Labeling
FOSS4G-EU 2015, Como
14th-17th July 2015
Vendor options
FOSS4G-EU 2015, Como
14th-17th July 2015
Point labels
FOSS4G-EU 2015, Como
14th-17th July 2015
Line labels
FOSS4G-EU 2015, Como
14th-17th July 2015
Polygon labels
FOSS4G-EU 2015, Como
14th-17th July 2015
Label Obstacles
FOSS4G-EU 2015, Como
14th-17th July 2015
Support for pre-laid-out labels
FOSS4G-EU 2015, Como
14th-17th July 2015
Raster styling
FOSS4G 2015, Seoul
14th-19th September 2015
A DEM and a color map

SRTM from USGS

Standard color map

No-data natively
transparent in 2.8.x thanks
to JAI-EXT
CSS:
http://docs.geoserver.org/latest/en/user/extensions/css/cookbook/raster.html
FOSS4G 2015, Seoul
14th-19th September 2015
Expressions in ColorMap



Standard ColorMapEntry
accepts only static values
Not anymore (GS 2.8.0)
Useful with env function,
picking values from the
GetMap
http://host:8080/geoserver/wms?REQUEST=GetMap&VERSION=1.0.0&...
...&ENV=low:10;medium:100;high:500
FOSS4G 2015, Seoul
14th-19th September 2015
Hillshading incoming


The only part of SLD 1.0 we have never had support for
In the works, scheduled for GeoServer 2.9.0 (might be
backported sooner)
raster-channels: auto;
raster-color-map:
color-map-entry(darkBlue, 0)
color-map-entry(darkGreen, 1)
color-map-entry(green, 300)
color-map-entry(yellow, 1800)
color-map-entry(maroon, 4000)
color-map-entry(white, 5000);
raster-relief-factor: 20;
raster-relief-brightness-only: false;
FOSS4G 2015, Seoul
14th-19th September 2015
Contrast enhancement
<sld:RasterSymbolizer>
<sld:ContrastEnhancement>
<sld:Normalize>
<sld:VendorOption name="algorithm">
StretchToMinimumMaximum
</sld:VendorOption>
<sld:VendorOption name="minValue">50</sld:VendorOption>
<sld:VendorOption name="maxValue">800</sld:VendorOption>
</sld:Normalize>
</sld:ContrastEnhancement>
</sld:RasterSymbolizer>
http://docs.geoserver.org/latest/en/user/styling/sldreference/rastersymbolizer.html#contrastenhancement
FOSS4G 2015, Seoul
14th-19th September 2015
Transformations
FOSS4G-EU 2015, Como
14th-17th July 2015
Geometry transformations
FOSS4G-EU 2015, Como
14th-17th July 2015
Rendering transformations
CSS
FOSS4G-EU 2015, Como
14th-17th July 2015
RT: from raster to wind barbs
CSS
FOSS4G-EU 2015, Como
14th-17th July 2015
Color blending and compositing
FOSS4G-EU 2015, Como
14th-17th July 2015
Color blending and compositing
composite: multiply, 0.5;
http://docs.geoserver.org/stable/user/styling/sld-extensions/composite-blend/index.html
FOSS4G-EU 2015, Como
14th-17th July 2015
Alpha compositing examples
FOSS4G-EU 2015, Como
14th-17th July 2015
Masking via alpha compositing
destination-in
FOSS4G-EU 2015, Como
14th-17th July 2015
Color blending examples
FOSS4G-EU 2015, Como
14th-17th July 2015
Z-ordering
FOSS4G-EU 2015, Como
14th-17th July 2015
Z ordering
FOSS4G-EU 2015, Como
14th-17th July 2015
CSS example
[class = 'motorways'] {
stroke: #990000;
stroke-width: 8;
z-index: 0;
}
[class = 'railways'] {
stroke: #333333;
stroke-width: 3;
z-index: 2;
}
[class = 'railways'] {
stroke: #ffffff;
stroke-width: 1.5;
stroke-dasharray: 5, 5;
z-index: 3;
}
[class = 'motorways'] {
stroke: #ff6666;
stroke-width: 6;
stroke-linecap: round;
z-index: 3;
}
* {
sort-by: "z_order";
sort-by-group: "roadsGroup";
}
http://docs.geoserver.org/latest/en/user/styling/sldextensions/z-order/example.html
FOSS4G-EU 2015, Como
14th-17th July 2015
That’s all folks!
Questions?
info@geo-solutions.it
FOSS4G-EU 2015, Como
14th-17th July 2015
Hidden bonus section ;-)
FOSS4G-EU 2015, Como
14th-17th July 2015
Dynamic arrow mark
FOSS4G 2015, Seoul
14th-19th September 2015
Plates (SLD)
FOSS4G-EU 2015, Como
14th-17th July 2015
Plates (CSS)
FOSS4G-EU 2015, Como
14th-17th July 2015
Download