We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Cartography in Mapserver from a user's perspective

00:00

Formal Metadata

Title
Cartography in Mapserver from a user's perspective
Title of Series
Number of Parts
188
Author
License
CC Attribution 3.0 Germany:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Identifiers
Publisher
Release Date
Language
Producer
Production Year2014
Production PlacePortland, Oregon, United States of America

Content Metadata

Subject Area
Genre
Abstract
Setting up a multi-scale styling Web Map Service (WMS) with heterogeneous data from several sources can be a challenge. Various official databases from the Nordic countries have been used. The goal is to produce good looking, readable and efficient cartographic output.Topics that will be covered are as follows: How to choose appropriate content and style for various zoom levels. The Mapserver options to author a WMS service will be discussed. In this case the Scribe tool was chosen and used to carry out the work. The built in capabilities of Mapserver to do cartographic styling of point, line and polygons are exemplified. Heterogeneous data from several countries is discussed and how that affects the abilities to carry labeling for instance. Some shortcomings in the data sources are discussed. Some of these problems are solved by preprocessing data with the GDAL/OGR package. The intended use of the map is also discussed and how that influences feature selection for different zoom levels. Finally the performance tuning options for Mapserver are reviewed. The presentation aims to provide the attendees with enough information so that they can produce their own Mapserver WMS services with beautiful and useful maps.
Keywords
Product (business)Auditory maskingVector spaceSoftware developerPresentation of a groupTexture mappingWindow functionWeb serviceCustomer relationship managementNumberLevel (video gaming)Computing platformSet (mathematics)Computer configurationServer (computing)Line (geometry)Instance (computer science)Graph coloringFlow separationQuicksortProjective planeSoftware testingNumbering schemeStandard deviationMassPredictabilityText editorSubject indexingTable (information)Menu (computing)DatabaseDifferent (Kate Ryan album)Source codeOpen sourceMereologyMappingMultiplication signExpressionSocial classWordNetwork topologyRevision controlPosition operatorNominal numberRight angleScaling (geometry)DialectBookmark (World Wide Web)Slosh dynamicsDiameterPixel1 (number)Point (geometry)Shape (magazine)Field (computer science)Scripting languageProgrammer (hardware)Regular graphRow (database)Process (computing)Classical physicsClient (computing)Integrated development environmentCartesian coordinate systemComputer fileMultiplicationGraph (mathematics)Flow separationPlotterSoftware frameworkCopyright infringementMagnetic stripe cardState of matterWater vaporCryptographyGrass (card game)Electronic mailing listBitFunction (mathematics)Variable (mathematics)Order (biology)WhiteboardColor confinementReal numberWeightArtistic renderingAuthorizationEntire functionInternetworkingTask (computing)Fraction (mathematics)Logic gateMatching (graph theory)Computer-assisted translationPhase transitionFormal languageComputer fontWage labourSymbol tableNatural numberDefault (computer science)Context awarenessDispersion (chemistry)Musical ensembleBlock (periodic table)Moving averageZoom lensCache (computing)Arithmetic meanInformationMaxima and minimaStack (abstract data type)File viewerTesselationTime zonePower (physics)Open setClique-widthGoodness of fitAttribute grammarSpherical capAxiom of choiceComputer programmingTotal S.A.Ferry CorstenPreprocessor
Transcript: English(auto-generated)
Okay, welcome everyone. My name is Lars Schulberg and I'm going to talk about two of my favorite subjects, cartography and map server. And when I can combine them into one talk, it's
just perfect. So a little about my background. I'm living in Stockholm, Sweden. I work for Saab, the airplane manufacturer Saab. I have an MSc in land surveying and my background in open source started already a long time ago. I was an active contributor to the GRASS
project back in the 80s, beginning of the 90s. And that was because I did a PhD in cartography and I used GRASS for that. I started using map server in 2002 and in those days
I used it more like application framework with PHP. Then I came back using GRASS three years ago or so and then GRASS was kind of another product. Now I was setting up a service
with it. I didn't care about the application. I let other people consume my services. So I don't care if it's open layers or if it's a whirlwind client that's using my material. So what I'm going to talk about here is setting up a WMS server with
heterogeneous data. I will talk about authoring tools and options in map server, short comings in the data that I have found, and pre-processing with GDAL and OGR, and
some performance and I have one little tip for you too with map server configuration in the end. So my task was to set up a Nordic map. It was to set it up on intranets.
I had no internet access so I couldn't use ordinary base maps like most projects do from Bing or OSM or wherever you get your base maps. So this is really about making your own base maps. I had to use official data sources and the design requirements
I had was that it had to be fast rendering and nice cartography. Those were basically the demands I had. So the data sources, it's from the different national agencies
in Nordic countries. 1 million data and 250k data from Sweden, 1k data and 500k data and 500k data from Norway, Denmark. I had 500k and 200k data. And Finland, I had
4.5 million data and 1 million. I actually had a data set 250k as well but I never had time to integrate that in a project. So it was a little disperse set of data I had.
And of course for the highest zoom levels, most zoomed out, I used natural earth data as well. So symbols, I've mostly been using the Swedish fonts that were supplied by the
national agency. There are fonts available from Denmark and Norway as well. Norway also have fonts for minority language like the Lapland language. And that's something that I have to consider later on but I haven't taken that yet. And I was considering using
SVG whenever possible but that would come maybe in the next phase. So I started off with natural earth data. I should mention here also that all these are in different
projections of course. But the customer wanted actually EPSG 3633. That's a UTM zone 32 projection. So actually what I did is just natural earth. So I used that for
outside the Nordic countries so you could zoom out a little more. So the map server editing
options. There are I would say two options today. If you're on Windows platform, there's a product called Map Manager. Haven't heard anyone talk about it during this conference but it's really nice product. I can really recommend it. But it's on Windows and I do all my
development under Linux. And it was a little too much clicking in my taste also. But it's more like working in QGIS. Then there's an option that's called Scribe UI
from MapGear Canada. It has progressed but when I started this a little more than a year ago then that was not finished. But I think it's a very nice product today. But I haven't tried it out fully yet. But what it brings to the table is the new syntax,
the Scribe syntax. And that was introduced even earlier. So I skipped the editors and there's different levels that you can do manual editing as well. There is raw editing.
You can adapt. There is a project called Basemap project. I could have adapted that but maybe I saw it as a little too complicated to get started with. But I had second thoughts
afterwards. Maybe I should have gone that way. But I'm very lucky that I went the way I went. I used the Scribe syntax and used it manually. So my choice was then to work a lot of Windows.
You have one window where you run this pre-processing script with Scribe files. And it increased my productivity considerably. I would say that's probably increased my productivity by 50 to 100 percent at least just from writing regular map files.
So you have all up on your desktop a prompt, a couple of editors and even mostly use the built in OpenLayers viewer that's available in map server. So that's my authoring environment.
So it's pretty much the same what you get in the Scribe UI today. So preparing the data since it was all, there was a lot of files, hundreds of files. So I used first the script
that was called shape merger. I merged a lot of files that were too many to get more bigger ones. I did some clipping and that's you do with OGR to OGR.
Then this is a step, I'm not sure if I should have done it or not, but I re-projected everything into the the projection that Norway had. The 32, 633. So all the Swedish
data and Finnish data and Danish data and even a natural earth data. I projected it so I wouldn't have the, I could have gone with the Asta on fly reprojection but I had a design requirement to make it fast so I've re-projected everything. And of course you have to create
this index files with shape tree to increase the speed. If you forget that it's not going to be as fast. So that's something really important that you do on all your files. And then I started to edit country by country. So I started to edit Sweden, here is Finland.
I started to edit Denmark. So I edit every country separately. And now I will come a little to the scribe syntax. It looks almost the same but it's a little different.
This is the main part that you have in the top of a map file. You probably recognize how many people are map server users here in this. Oh great. So if you are a map server user
I'm sure you recognize it but it looks a little different. So you have the main definitions in one file then you can find all the layers that you have and I think this was all the layers and then you edit this kind of layers in a separate file.
Of course they can include more map server layers inside each one of these layers but these are the ones that my scribe script then assembles to total map file in the end.
So let's see. I had nine Natter Earth layers, about 15 Swedish layers, a couple of Norwegian Finnish, Danish, and then since I had cut out by country borders or territorial borders I had to put some layers
back in the end. For instance ferries that runs between countries. Those you have to add in the end otherwise they won't show up. And then I put on a second set of natural borders for
cartographic look in the end on top of everything as well. You define the zoom levels also. So you have one configuration file for the zoom levels. So you don't need to think about
max scale denominator, min scale denominator. You never have to think about that. Because you define your scales and you can think about this as the scales that you have in a WTS
service, tile service. So it's actually the different scales where you render. One thing is also that you define, you have one file where you define all your variables.
And this is one of the very strong features with scribe. For instance the blue block here, I will use that a little later when I come to my layers, I do layer config. And that is I could tell it what group it is, if it's status on or off or default.
I do projection, labor clip and so on. So certain things that I want to have the same in most layers. I can define it up front. Same thing with road style attributes like line cap
and line join. How I define that? So I define it just once here. And I can also predefine any number of colors. So in the end I probably have thousands of colors. So I could have one set of colors for Swedish map, the Swedish portion of the map
and another set for Norwegian and so on if I like. And I did that. So here for instance I reuse, here I'm starting to define a layer. It's a layer that is valid
in zoom scale, zoom level 8 to 16. So this will go into the map file for those max scale, mean scale denominators. And otherwise it's pretty much the same. I use one variable for
layer config. And finally one other feature here that's good. You can then say that between zoom level 8 and 12 I want to use this data set. And between zoom level 13 to 16 I want to use another data source. And that's very handy too that you could define
that. Otherwise in all the way you're writing it you had to do two layer definitions with just one data source in each. So I continue to come down to the class definition.
Here is also that I can make one expression then that is just valid for zoom level 9 to 10. So I have a class item that I run over here. And I do that expression
zoom level 9 to 10. But then when I come down to scale this feature that's it's public roads between road numbers 100 to 499. I would like to have the width on zoom level 9. I would like to have it one pixel wide. In zoom level 10 I would like to have it 1.2 pixels.
So it's very convenient to write it this way. It was a little backwards first but it took me one or two days to get adjusted from writing map files the ordinary way. But I really like it.
It increases your way of writing map files. And when you're done editing your files you just run this small python script scribe.py and what the maps you want to output. And then you run your map file in your viewer if you have made your own little open
viewer or if you use the built-in. So this is one map. It's probably zoom level 8 or 9 or something. One thing that I did was that I did different cartography in the different
countries. And I thought that was a nice feature because you could distinguish them really between the countries. So I tried to follow the official map the colors that Swedish map authority uses in Sweden. I tried to follow the colors that the Norwegian mapping authority
uses in Norway. And my customer liked this idea too so I was glad. So here you see a little closer this is the border between Norway and Sweden. Here is the border between
Denmark and Sweden. Maybe it's a little too little but I also used Swedish style on the
road labels in Sweden and Danish style on the road labels in Denmark. And Norwegian style for instance secondary highways are blue in Sweden. They're yellow in Denmark and they're
white in Norway. So I had different symbology there. One other thing since I have disparate data sets I had different what's called equidistance between the elevation lines but
I don't think that matters so much really. You still get the feeling for I think it's not really bad as long as you're aware that that is from different sources.
But that shows also that since I have different color schemes you can really imagine that it is from different sources. Text handling is maybe the most difficult part always. This is all the labels that were available in Norway and I had a very hard time and
I haven't fully sorted out all the labeling in Norway. I had to talk to some of the Norwegian guys there but somehow I managed to fix it. The Danish data set was a real
map info database that I converted. It had some strange features. You see the bunch of letters crowded in a kind of bow. And it's nice because if you zoom in
it looks like that. Hydrographic features should be set across. But the way that database was set up it had an individual position on each letter. So that was not so good of a database
I think. So you could just use it for one or two zoom levels really. So here comes my little trick that I have found not in the manual but in some old user group posting. For instance when
you have several road labels on the same segment and you would like to stack them some way then you can use expressions. So for instance here I would like to do major interstate road European interstate road E and I start without drawing one of them that is in label one.
And then I look if there is a label two and it also starts with E. Then I can do a offset
of that one and draw it. If there is none it will not be drawn. So that enables you to stack road labels like that. And you can do it with three labels. You can stack them horizontally
or you can stack them vertically or along. If you do a follow line you can stack them along the line. So there's many options how you would like to do the road labels. I found this in some very old posting somewhere. A little power tip. One other problem I had was
the Swedish telling the positioning of names were not in syntax for map server.
They were in this Tjust column. So they were one two three four five six seven eight nine. And actually I managed to do a map server expressions but it became I think 40 50 rows long and took a long time to process. So sometimes don't fight it. So I wrote a small
python program then that added an extra field with a map server. Sometimes you have to simplify your problem a little bit. So wish list for data producers here is that
all data sets should be cut by national or territorial borders. Really it should be useful. All text should actually be connected with some feature and not just have a cartographic
cartographic position. Then they're sometimes very useless. Especially if you work in a multi-scaled environment. And they should not have fixed cartography because map server is very good about handling conflicts with labels and text. So
it's wonderful tool for that. And then source it out automatically with that labeled cache that it has. So what do I have next in my pipe? I will add hillshade to this project.
That's quite easy. There's many good examples. But I will do improvements in the text handling that is more tricky that requires more work. I will try and use more masks in map server. I had some problems with that. But I will continue to investigate that. And I will finally
also work with S57 data seashores. And that's also a little tricky. And no one really knows how to do it. So that was my end of presentation.
You talked about working with masks in the future. Can you explain a little bit more about what you're trying to accomplish there? It was a thought that I shouldn't have to clip the data. So I've been trying to use masks instead for certain things. But it seems like there is some problem with vector masks towards vector data when you do
predictions. But I have to construct an example to send to the users list to sort it out. Because I've been through some of the, what is it called, the testing test data set. And I can see that it's working correctly in the test data set with the vector mask
towards vector mask. But I think that is only done in standard 4326. And when I cut it with different projections, it's not behaving the way I think.
So I have to, I will try and construct an example when it's not working. All right, thanks. Thank you.