Openstreetmap-carto: How to: Performance optimization

Created on 27 Nov 2017  路  9Comments  路  Source: gravitystorm/openstreetmap-carto

Hello,

can someone explain how to improve this CSS to be as fast as possible while still being able to display basic shapes like parks, buildings or streets (everything without labels and information) for a game.
I know a way to start is to remove all the extra information the css saves and receives from postgres, but since this CSS is really big, it is kind of difficult to sort everything out correctly.
Is there another CSS to use for this case which needs less editing and works with osm2pgsql ?

Thanks in advance,

Erik

customization performance

Most helpful comment

Because of the explicit usage of this CSS in the tutorial if fear that changing to a different CSS
may scramble things up

No, it won't. The people who maintain the switch2osm site (which includes me) actually discussed internally whether to have it use this style or a simpler one for both technical and ease of maintenance reasons, and it was a fairly borderline decision to have it use this style. If you just want a simple map style I really wouldn't start from OSM Carto as it is now.

Also, it's definitely worth trying to have this discussion somewhere a bit less offtopic, since it's not really anything to do with this map style as such. https://help.openstreetmap.org/questions/ is one possibility.

All 9 comments

A quick hack is to edit https://github.com/gravitystorm/openstreetmap-carto/blob/master/project.mml and under Stylesheet remove the files you don't need. A second step is to drop the layers you don't need from the same style.

As this is not a bug or feature request, I'll mark this issue as closed.

Thank you for your fast response!
What about the lua script? Do I need these extra informations if I don't use labels?

I'm not convinced that it's really a question for this repository (perhaps the "tile serving" mailing list or the help site might be better), but I'll have a go:

  • Ask yourself what you're actually trying to optimise (disk space? rendering speed? something else?)
  • Remove what you don't need from the .mml file and the corresponding layers
  • Remove detail that you don't need from the remaining layers

Actually, I'd probably start with a simpler style altogether (maybe OSM Bright?).

The tutorial for building up a tile server on https://switch2osm.org/ is explained using this CSS. Since I am not a map expert altogether, editing gets quite complicated.
I am on my way to use Kosmetk to change the style to fit my needs, but I wonder because the tutorial explains to add information right into the database
osm2pgsql -d gis --create --slim -G --hstore --tag-transform-script ~/src/openstreetmap-carto/openstreetmap-carto.lua -C 2500 --number-processes 1 -S ~/src/openstreetmap-carto/openstreetmap-carto.style ~/data/azerbaijan-latest.osm.pbf

If I am up to a really simple map which has only the basic shapes as explained above and with this a very fast rendering speed and disc usage, I wonder which steps for using this CSS can be left out.

Edit: Because of the explicit usage of this CSS in the tutorial I fear that changing to a different CSS may scramble things up (which I also belive will happen if I start to remove script files and information from the db without knowing what I am doing - this is why I am looking for help.

Feeding database is only about getting all the data and it might be hard to get it right, but it's just one time activity (unless you update it). The main performance bottleneck is reading from database, which is done from the layers triggered by individual stylesheets (MSS files), so I would start by switching off one by one and looking if the map still contains what you want. The names are more or less self descriptive:

https://github.com/gravitystorm/openstreetmap-carto/blob/2dab34c11ca33da44d62c72148d52221b9053023/project.mml#L38-L55

Because of the explicit usage of this CSS in the tutorial if fear that changing to a different CSS
may scramble things up

No, it won't. The people who maintain the switch2osm site (which includes me) actually discussed internally whether to have it use this style or a simpler one for both technical and ease of maintenance reasons, and it was a fairly borderline decision to have it use this style. If you just want a simple map style I really wouldn't start from OSM Carto as it is now.

Also, it's definitely worth trying to have this discussion somewhere a bit less offtopic, since it's not really anything to do with this map style as such. https://help.openstreetmap.org/questions/ is one possibility.

Look for example here:

http://osm-liberty.lukasmartinelli.ch
https://github.com/lukasmartinelli/osm-liberty

It's light and vector-based, so you can see 3D buildings and rotate it.

But maybe old OSM Bright might be better for you (I have no demo site to show you):

https://github.com/mapbox/osm-bright

Thank you all for your quick and detailed help; I figured out now, that the style is seperated from the database - the tutorial with the command line mentioned above made me belive otherwise.
Since I understood that, I can switch to another style and generate my mapnik.xml to fit my needs.

Thanks for the awesome work and for sharing everything!

Just be aware, that database format can be a bit different for each style (for example osm-carto v4 uses different database format than osm-carto v3), so start with reading given style documentation first.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

meased picture meased  路  3Comments

HolgerJeromin picture HolgerJeromin  路  3Comments

wielandb picture wielandb  路  3Comments

FTno picture FTno  路  4Comments

matkoniecz picture matkoniecz  路  5Comments