Advanced Cartographic Map Rendering In GeoServer
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Title of Series | ||
Number of Parts | 95 | |
Author | ||
License | CC Attribution - ShareAlike 3.0 Unported: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this | |
Identifiers | 10.5446/15507 (DOI) | |
Publisher | ||
Release Date | ||
Language | ||
Production Place | Nottingham |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
|
FOSS4G Nottingham 20137 / 95
17
25
29
31
32
34
48
50
56
58
68
69
70
82
89
91
00:00
MappingTransformation (genetics)Rule of inferenceScale (map)Raster graphicsPoint (geometry)Projective planePresentation of a groupMetropolitan area networkExtension (kinesiology)XMLUML
00:35
Cascading Style SheetsStandard deviationNP-hardCompact spaceExtension (kinesiology)Artistic renderingMappingCross-site scriptingTexture mappingExistenceWebsiteMereologyMultiplication signSign (mathematics)Presentation of a groupBuildingQuicksortTexture mappingPairwise comparisonMappingRepresentation (politics)Slide ruleJSONUML
02:09
MappingMappingScaling (geometry)Communications protocolState of matterElement (mathematics)Raster graphicsContent (media)Scalar fieldJSONUMLEngineering drawing
02:32
Raster graphicsMappingStandard deviationDiscrete element methodCross-site scriptingAmsterdam Ordnance DatumProcess (computing)ConcentricAreaCASE <Informatik>Point (geometry)Social classPressurePhysicalismRight angleType theoryInterpolationElectronic visual displayRepresentation (politics)ExpressionSatelliteOrder (biology)Physical lawGraph coloringSolid geometryElectronic mailing listLimit (category theory)MappingRaster graphicsComputer animation
04:16
Scale (map)Rule of inferenceMeta elementKey (cryptography)MappingArtistic renderingVector spaceRaster graphicsRule of inferenceTexture mappingMultiplication signMappingDifferent (Kate Ryan album)Web 2.0Image resolutionCASE <Informatik>Electronic visual displayArithmetic progressionDynamical systemMetropolitan area networkQueue (abstract data type)Right angleOpen setProfil (magazine)HypercubeComputer animationJSONXMLUML
05:33
CASE <Informatik>Scaling (geometry)Point (geometry)Electronic visual displayBuildingCodeArithmetic progressionMathematicsVideo gameSingle-precision floating-point formatComputer animation
06:25
GeometryRoundingScale (map)Artistic renderingRule of inferenceParameter (computer programming)WeightMaxima and minimaComputer fontScaling (geometry)Single-precision floating-point formatMereologyRule of inferenceArtistic renderingMaxima and minimaCASE <Informatik>Fraction (mathematics)Arithmetic meanState of matterComputer programmingElement (mathematics)Cue sportsCodeMultilaterationElectronic visual displayIdentity managementVideo gameComputer animation
07:23
SineScale (map)Hand fanGeometryRule of inferenceMaxima and minimaMetrePointer (computer programming)Parameter (computer programming)Interior (topology)Arithmetic logic unitRoundingDisplacement MappingRoundness (object)Scaling (geometry)CASE <Informatik>Arithmetic meanFraction (mathematics)PixelSingle-precision floating-point formatMaxima and minimaElectronic visual displayProper mapParameter (computer programming)Rule of inferenceMultiplication signProgrammer (hardware)Basis <Mathematik>State of matterMathematicsQuicksortVideo gameBit rate
09:48
GeometryAreaFAQLevel (video gaming)PolygonServer (computing)Library (computing)MereologyElectronic visual displaySpacetimeGenetic programmingMarginal distributionCodeCASE <Informatik>Different (Kate Ryan album)Computer fontMedical imagingGenetic programmingState of matterPoint (geometry)Multiplication signRight angleWebsiteArithmetic meanSolid geometryExtension (kinesiology)Boss CorporationPhysical systemComputer animationXML
11:42
EstimationGraph (mathematics)Multiplication signGraph coloringPattern languageMultiplication signCodeExtension (kinesiology)Genetic programmingGenetic programmingResultantQuicksortWebsiteSpecial unitary groupAreaBookmark (World Wide Web)CircleCuboid
13:06
Quantum stateUniform resource nameRepetitionComputer-assisted translationSineSigma-algebraSession Initiation ProtocolVenn diagramGeometryRoundingSquare numberCross-site scriptingCircleMereologyRepresentation (politics)Extension (kinesiology)Computer iconSpacetimeRectangleComputer configurationGenetic programmingMarginal distributionAsynchronous Transfer ModeEquivalence relationResultantPixelSet (mathematics)Pattern languageGUI widgetGenetic programmingMultiplication signProcess (computing)Latent heatPresentation of a groupUniformer RaumCASE <Informatik>Volume (thermodynamics)Electronic visual display
16:33
User-generated contentArtificial neural networkCategory of beingState diagramGraph (mathematics)Escape characterFile formatPoint (geometry)Type theoryDifferent (Kate Ryan album)Digital filterInfinityData typeCircleMatching (graph theory)ResultantMereologyCodeGenetic programmingUniform resource locatorNatural numberQuicksortPoint (geometry)Slide ruleMappingVideo gameBuildingArithmetic meanPhysical systemMultiplication sign
18:41
Computer-generated imageryTable (information)Set (mathematics)Medical imagingComputer iconFilter <Stochastik>Extension (kinesiology)Attribute grammarHypermediaPhysical systemSource codeJSON
19:06
Proper mapRouter (computing)Genetic programmingAerodynamicsSimulationCross-site scriptingTrailResultantCausalityMedical imagingMereologyExtension (kinesiology)Parameter (computer programming)Rule of inferenceAttribute grammarComputer animation
19:42
Computer fontNumber theoryComputer configurationCASE <Informatik>Parameter (computer programming)RoundingActive contour modelWide area networkMaxima and minimaMoving averageInterior (topology)State diagramEmulatorCategory of beingPersonal area networkDuality (mathematics)Quantum stateRadiusPolygonFermat's Last TheoremInfinityLengthMaxima and minimaFitness functionMultiplication signSpacetimePolygonGoodness of fitMappingComputer configurationCASE <Informatik>Displacement MappingParameter (computer programming)Physical systemFigurate numberGroup actionPixelEquivalence relationRevision controlBitPoint (geometry)Set (mathematics)MultiplicationTournament (medieval)Beat (acoustics)Level (video gaming)Video gameRight angleInsertion lossElectronic visual display
22:59
Interior (topology)Uniform resource nameState diagramNumber theoryData typeSign (mathematics)EmulationGraphical user interfaceGraph (mathematics)Local area networkExt functorPoint (geometry)Genetic programmingGenetic programmingCase moddingStructural loadProgram flowchart
23:39
GeometryTransformation (genetics)Quantum stateMaxima and minimaCross-site scriptingFunction (mathematics)Execution unitTransformation (genetics)Functional (mathematics)Presentation of a groupNumberPoint (geometry)Process (computing)AngleRevision controlAreaVideo gameRotationMathematicsCellular automatonArrow of timeGeometryBitArtistic renderingElectronic visual displaySound effectComputer animation
25:22
Function (mathematics)FunktorUser-generated contentActive contour modelImage resolutionAreaSet (mathematics)Transformation (genetics)NumberProcess (computing)Representation (politics)Electronic data processingFrustrationCASE <Informatik>File formatMapping
26:21
Configuration spaceSlide rulePresentation of a groupTouchscreenDirectory serviceComputer configurationBlogDemosceneMusical ensembleInternetworkingUML
27:02
Transformation (genetics)Computer fontPolygonState diagramGame theoryNumberExpressionPoint (geometry)Moment (mathematics)Office suiteDatabaseUser interface
Transcript: English(auto-generated)
00:01
Hello everybody. For those that weren't here before, my name is Andrea. I work for GeoSolutions, which is an Italian basic company contributing to GeoTools, GeoServer, and a number of other projects. In this presentation, I'm going to show you some examples of how to use GeoServer XLD and
00:23
GeoServer CSS, which is a new extension, to solve common cartographic issues when drawing maps. All the examples, or almost all of the examples,
00:41
will show both the SLD syntax and the CSS syntax, just so that you can have a quick comparison of them. For the SLD, I'm going to only show the important part of the stylesheet because the stylesheets are always very long, so I'm going to focus only on the part that I wanted to show you.
01:00
The equivalent CSS is always shown in full instead because it's so compact that I can always, besides one slide, stick it into the slide fully. SLD and CSS have their pros and cons. As I said, CSS is very compact, is very expressive, but it's not a standard, SLD is.
01:21
So, if you go for an interoperable approach, you go for SLD. If you want quickly make maps, you probably want to go with the CSS instead. So, I have an example map which is a real world map. I'm going to show you some pictures of this map.
01:40
So, we start up with some digital elevation model and the city borders. We start showing up the roads, then more details about the roads and so on, the buildings, then the parcels, and so on. As you can see also the styling of the roads changed
02:02
as I switched representation. So, this is kind of what you would expect from a multi-resolution map. That is, never fill it with too much information and change the styling of the various element,
02:23
hide and show depending on the current scale, so that you have appropriate content for the scalar where you're looking at the map. So, the first thing I'm going to talk about is raster styling. Raster styling is generally pretty easy.
02:42
You either have an RGB aerial or satellite image, which you have to show as is, and you basically don't have to do anything, or you have a digital elevation model or any kind of other geophysical parameter, pressure, temperature, whatever, concentration of pollutant, and then you have to set up a color map.
03:01
A color map in SOD 1.0 is a list of color map entries, where you map a color with an eventful opacity, in this case, opacity zero means transparent, and to a quantity, and then you provide a list of values with a list of colors, and you serve linearly interpolates between the various combinations.
03:22
So, you basically are giving it tie points, and any value in between is interpolated linearly between two colors that you gave for those tie points. The CSS expression is just slightly more compact. This is one case where CSS and SOD are similar. I just switched the kind of representation.
03:42
Instead of having it display the linear interpolation between the tie points, in this case, I modified the type of approach to intervals. In this case, it's solid color between one tie point and the other. So, you get basically polygon representation
04:01
instead of continuous display, which makes sense in case, I don't know, you have a pollutant and you only want to show the areas where the concentration is above certain limit. Then, as I said, scale-dependent rules are the basics.
04:22
The one thing that you really have to master the day you want to start making mapping. All layers, too often forgotten, or later used, yet very important. Data exposed on the web is multi-resolution. It's not your old paper map that has a fixed resolution
04:40
and you decide on a display and that's it. A web map is about showing data, different resolutions, and at different resolutions you want to show data in a different way or you want to show different data. So, the styles need to take that into account and progressively show details
05:01
because otherwise the map gets too crowded and nobody can actually read it. Also, for performance reasons, you don't want it to have to display 100 million lines in a tiny map, which would just result in a black blob, right? But it would also take a lot of time to do that.
05:24
So, this is one case where the same tool gives you at the same time a good-looking map and a high-performance one. This is an example of scale dependencies. As you can see, I progressively show more and more detail
05:41
and I end up hiding the layers. Sorry. So, we start with the digital elevation model showing that at some point we turn it off because the grid style of digital elevation model
06:01
gets unsuitable for a high-resolution display. They are two cores. And I keep on adding data first. The highways, then the roads, then the buildings, as I zoom in, and also the display of the roads goes from single line to a case line.
06:20
And again, I do it when I change the scale, when it makes sense to actually change the display. So, they'll turn, okay. So, in SLD, this is controlled by two elements, mean scale denominator and max scale denominator.
06:41
In CSS, there is a property, a pseudo property, that you can filter on for a rule. So, this part is actually a filter and it says, well, when the scale, actually the scale denominator, is below 75,000, then apply this, which applies a labeling, which I would otherwise not show
07:01
at one to 1,000, for example. And the SLD does the equivalent thing. Another thing that you might want to do is alternative rendering. So, I don't hide the data, but I change the way in which I display it. And as you see, as I zoom in, I change the way I display the roads
07:21
from single line to case line. In the case of SLD, I'm playing with both mean and max scale denominator to turn on and off the rules. And same here, I do play with the max scale denominator, so that I turn off the case line display,
07:42
whilst this one goes from 10,000 to 75,000. So, single line goes from 10,000 to 75,000. When I'm above 10,000, then I display a case line. And this is just some chunks of the full style.
08:01
This is instead the full style in CSS. So, again, when the scale is between 10,000 and 75,000, you can almost read it. I can use a gray line, two pixels wide. And look at this one, this is cascading. The ability of CSS to combine rules
08:24
that are active at the same time, which SLD doesn't have. So, basically, for any road when the scale is less than, the scale denominator is less than one to 75,000, then I apply labeling, where I pick the label from an attribute, label name.
08:46
And I apply some parameters that I'm going to talk about later when we talk about styling. When the scale is less than 10,000, instead, I go for the case of display, which is done by specifying the stroke more times than one.
09:03
So, I say first gray, then white, outer line, inner line. The stroke width, 17 pixels, and then 12 pixels. So, the gray one will be 17 pixels, the white one will be 12 pixels. And then I apply the z-index so that all the gray lines are painted first,
09:21
and then all the white lines are painted second. This is important to get the proper display crossings. And I ask for a round line cap, a round line joint. So, as you can see, this is very compact and allows me to change the display depending on the scale without having to repeat the labeling portion,
09:43
which is common between the two styles. Another thing that it's often missing or misused is the use of hatches, patterns, dashes, and plates. So, in both SLD and CSS,
10:02
you can fill polygons with the solid color, and that's, I mean, something that you can do easily. Or you can fill polygons by repeating symbols, piling them so that we have a different kind of display like this. In the case of SLD, we have this very long-winded syntax
10:22
to say, oh, okay, use this little image to fill me the polygon. In CSS, it's actually, this is the full style, this is just part of it, where I say, oh, okay, when the MPFCC attribute, which is a classification attribute, is this value, which matches cemeteries,
10:41
which is also in the SLD, but it was so long that I had to cut it, then use this mark, this image, to fill it. So, as you can see, two lines, it's done. We can also fill with the TrueType fonts. If you come from an Esri background, it's common to have lots of symbol libraries
11:02
as TrueType fonts. Your server can refer to them. What I'm doing here, if the code is, again, the one of the cemeteries, paint me a light green background, plus apply this symbol, I'm referring to the font
11:21
and I'm giving the code of the character, plus I'm saying, oh, okay, while you're at it, please add an eight-pixel margin around the symbol to space it out a bit, so that all the crosses don't get touching each other, which is an extension. It's also available for SLD, of course.
11:45
Hatches are supported by extended well-known names in SLD. SLD provides the notion of well-known marks, which are five or six names like circle,
12:00
square, cross, and so on. GeoServer has extended the concept and we have the ability to add new kinds of markers by code. One of them is called times, which is a cross, and that's how you do it in CSS.
12:22
I'm saying, oh, okay, fill me with the times symbol. Now, there's a catch. When I'm filling with a graphic symbol like a mark, I also have to specify the color of the stroke and how do I fill it if it's an area. To do that in CSS,
12:40
we have to say something like this. Column fill, which means inside that fill, please use this stroke, which is this color, and give me a size of eight. The bigger the size, the coarser the pattern gets, because the X becomes bigger. This is some of the other symbols that we support built in.
13:01
You can add more, so you have the basic catches there. Then you can have dashes, that is the ability to display a dotted line or a dot line, whatever, support.
13:23
In CSS, you would say, oh, okay, give me a dash array of two, which means two pixels pen down, two pixels pen up, two pixels pen down, two pixels pen up, and repeat, and so on. You can have more than one value. If you wanted to have a dot line, you would say two pixels down, 10 pixels up,
13:41
10 pixels down, and 10 pixels up again, and then repeat from the beginning, and that would give you a dot line representation. Again, the CSS representation is quite compact for this. One twist that GeoServer adds, which is not fully part of the specification,
14:01
not the sld1o, and it's more flexible than what the sld1o1 supports, is the ability to use a mark and repeat it along the line, but also specify a dash array for it. So the idea is that I'm repeating a circle along the line,
14:21
but I'm using the dash array to space it so that it's repeated with some space within, and then I use another line, which is also a dashed line, and I'm using the dash offset to synchronize the two patterns so that they don't overlap with each other, but they are alternate with each other. The ability to use a dash array with a symbol
14:43
to be repeated is unique to GeoServer. Sld1o1 has the idea of a gap between the symbols, but it would be a uniform one. GeoServer allows you to do non-uniform stuff because it uses the dash array, which can have more than one number.
15:03
Plates, rod plates. The idea is that I wanted to put a label on a map, and I wanted to have maybe a rectangle, maybe an icon below it, and maybe adapt it to the sides of the label. In this case, GeoServer has an extension
15:22
on top of the basic Sld, which allows you to put a graphic element into a text symbolizer, which is something that you normally wouldn't be allowed to do. And I'm basically saying, oh, okay, for this label, please use a mark.
15:41
I didn't specify the name of the mark, but it's a square. And then there is another set of options that say, oh, okay, with the mark, please resize it to match the proportions of the label. So I'm resizing, stretching it.
16:01
So it's no more a square, but it's a rectangle. And I'm also adding a graphic margin that is some spacing between the label and the rectangle. And that's the result. Now, this is a very long style, and this is the equivalent in CSS. When I'm doing basically the same thing, in CSS, the graphic is called shield,
16:22
and I'm saying, oh, use me a square, and I'm setting the recite mode and the margin here. So this is how you do it in CSS. When it comes to point symbology, I have to do the same thing with this.
16:48
So here I have some sort of thematic map made with points. I have points which represent the locations, and I wanted to display each one with a different symbol depending on the nature of the location. Some are shopping centers, or there are schools,
17:02
or there are government buildings, and so on. And I have, again, them categorized by that MTFCC code. I have to put together a quite long-winded filter to specify the shopping centers, because they are something like,
17:22
oh, MTFCC line is C3081, and then in the name of the thing, there has to be shopping inside. And then I choose this particular icon, and I have to repeat this like 16 times, resulting 600, no, sorry, for six times,
17:41
resulting in 600 lines of SLD to create the value symbol and specify a label for them. When I do it with CSS, this is the only one where I could not fit the CSS in the slide. It's 70 lines, but the idea is that,
18:01
again, I'm using the power of cascading. I'm saying, for any that star means match any, for any of those points, please use this label. Full name, and if I don't say you otherwise, please use a black circle to display it.
18:21
But if I'm matching a shopping center, then use this icon instead. So I'm basically setting the basics and then overriding them only in the parts that I need to override, result that 600 lines of SLD becomes only 70 lines of CSS.
18:41
And then if I'm willing to modify my data, I can shrink it farther. The idea is that why do I have to set up all these filters in the SLD? Maybe I could put the name of the icon that I want to use directly in the data and pick it from the attribute instead. So this is some SQL that I run to do that. I basically added a new attribute
19:01
and I'm sticking it to the data, the image that I want to use. This is, again, the GeoServer extension where I'm basically, instead of using the full path as before, I have this parameter dollar image where I'm saying, okay, this last part of the path, you pick from the image attribute.
19:21
So I only have to display one, sorry, to prepare one rule instead of six. And this works, of course, also in CSS and reduces the overall styles to 15 lines. So much more compact. And this is the result that I get.
19:43
When it comes to labeling, GeoServer has a lot and lots of vendor options to control how the labels are displayed. Just to make you some examples, this road is following the line, this, sorry, not this road, it is labeled. And this one is actually being wrapped on two lines.
20:05
And this is a set of vendor options that control this. In this case, for line labeling, I'm saying vendor option name, follow line, true, that is curved labels, repeat the label every 250 pixels. So if I have a very long line,
20:21
I display it multiple times. I'm grouping the labels because most of the time, this Mapleton avenue is actually made of one feature and another feature and another and another and another and another, because they are broken at crossings. But for the sake of display, I would like to have the whole line instead. And this group vendor option makes GeoServer figure out
20:45
which lines have the same label and it fuses them. And then there is max displacement that allows the system to move the label along the line a bit in case the place where he wanted to put it is already busy with another label to avoid conflicts, visual conflicts.
21:03
The equivalent, the fully equivalent style in CSS, we already saw. The only thing to point out here is how we specify the vendor options, which is here, same as above. Point labels, for point labels,
21:20
we don't need to do much, but some of them are very, very long. And when I'm labeling a line, it's fitting in a sense that the line is long. So I have a long label along it, right? But when it comes to a point, I don't want a point to have a label that takes off of the map. I can have GeoServer automatically wrap it
21:42
to a certain length. So this is a vendor option named auto wrap at 100 pixels. So if the label goes beyond 100 pixels, GeoServer wraps it up for me automatically in one or more lines to satisfy the maximum length.
22:01
For polygon labels, again, we are using auto wrap to have the label be packed in a small space. We are applying the max displacement, and then there is one parameter which is probably not very well known even to long time GeoServer users,
22:22
which is the goodness of fit. Basically, GeoServer want to try to display a label if the label is much bigger than the polygon itself. So basically, GeoServer is trying to compute how big the label is compared to the polygon. And the label is going to be displayed if 70% of it, by default, fits into the polygon.
22:45
So we allow the label to go a bit outside, but not much. With 0.9, I'm actually allowing 90% of the label to go outside the polygon, because in this map I actually wanted the labels to be visible even if the polygon was small.
23:01
We can also apply the concept of label obstacles, which is the idea that some polygons, some lines, and some points should not be overlapping labels. So I'm basically saying that any of these symbols is a label obstacle so that I don't have this kind of situation where Boulder County label
23:22
overlaps with this symbol. And here we go, I have city all showing, but the Boulder County one is not, because that point has been marked as a label obstacle.
23:40
Transformations, we have two kinds of transformation in GeoServer, geometry transformation and rendering transformation. Rendering transformation I talked about a bit in the presentation before. The idea is that before rendering the map, I might want to apply some change to the geometry that I'm displaying, or some change to the whole layer that I'm displaying. The idea of geometry transformation is that I take
24:04
the geometry and apply an offset function on top of it to offset it a bit, to do what? Generate a simple shadow effect. So I'm moving the geometry, painting it with a darker color, and then on top of it I painted a normal geometry.
24:21
There is a very large number of functions that can be applied to geometries to extract vertices, to extract the beginning and ending of a line and so on. Here is the CSS version of the same style. See how much easier it is to apply the offset. This one you can actually read,
24:40
the offset of the attribute, which is called DJOM by these offsets. This is another example in a cell of geometry transformation. In this case, I'm extracting the end of lines, because I want to add an arrow at the end of lines. And I'm actually doing some magic,
25:02
which is probably, oh yeah, the angle. The rotation of the arrow has to be aligned to the end of the line. I'm applying another function which is called endAngle to get the ending angle of that line, and use it as the rotation of the arrow so that the arrow aligns with the end of the line.
25:22
Then we have rendering transformation, which is the concept of applying some spatial data processing on the fly to provide a different representation of the data. In this case, I'm calling the GSContourWPS process on the fly, extracting a number of ISO lines that I'm then displaying on the map.
25:43
This is the only one feature that is missing from CSS. In CSS, to date, you cannot express a rendering transformation yet. There is some work going on to add the syntax for this. And this is very powerful because, as I said before,
26:01
this kind of transformation are applied only on the area that I'm looking at and only at the resolution I'm looking at so that they are actually very fast because they are not processing the whole data set, they are not processing the data set at its native resolution, they are processing it at the resolution I'm looking at.
26:23
Looking for our blog on the internet, in a few days, I'm going to share the presentation material and a GeoServer data directory that has all the SLD styles, all the CSS styles, and the data that you have seen on the screen. And this is it.
26:56
Yes? With the labeling context, is there some way to give priority to some labels?
27:01
Oh yeah, the option was always there, but I never actually talked about it. But see here, SLD priority, and I'm giving it a number. The higher the number, the higher the priority for that label. Yes, that can be an expression. You can pick it from the database if you want, yes.
27:24
Anything else? Please. Using CSS, not at the moment. You have to do it within the GeoServer user interface.
27:44
But we are moving towards making CSS and SLD peers. At the moment, CSS is actually turned on the fly in SLD before GeoServer uses it. We are working towards making them interchangeable. And at that point, you will be able to upload under CSS.