Skip to content

Tweaking Map Styles

Jacolin edited this page Aug 10, 2018 · 2 revisions

Please see https://mapserver.org/basemaps/

Table of Contents

Introduction

This page contains information about the way to tweak map styles using the mapserver/basemaps project.

Prior to using this version of mapserver/basemaps, you have to import OSM map data into a postgis database using the imposm tool.

Generating a mapfile

The mapfile called osm-_STYLE_.map is generated by executing the 'make' command based on the settings at the top of the Makefile.

Makefile

The following parameters are configurable at the top of the Makefile:

  • OSM_PREFIX: the prefix of the table names in the postgis database
  • OSM_SRID: EPSG code of the mapfile's output projection (common values are 4326 for lon,lat and 900913 for the Google Mercator projection)
  • OSM_UNITS: MapServer units corresponding to the OSM_SRID (common values: DD or METERS)
  • OSM_EXTENT: Default extents to use in the generated mapfile (in the same coordinate system as OSM_SRID)
  • STYLE: Name of the map style to generate. Three styles are available to choose from by default: default, google and bing

The generate_style.py script

The generate_style.py script contains the value of all configurable style parameters.

At the top of the file, the _vars_ array defines the default values of all configurable parameters. Those values are used by the _default_ style.

Then the _style_ array that follows can be used to define custom styles. A custom style inherits the settings of the default style (from the vars array), and then all values set for that style in the _styles_ array override default values. Two sample custom styles are provided as examples: the _google_ and _bing_ styles.

Structure of parameters in generate_style.py

For each configurable style parameter, the value can either be a single value applicable to all map scales (map scales are defined at the top of the file), or an associative array of values where the key is the corresponding scale, and the value is the value applicable to this scale and all scales that follow up to the next entry in the array.

e.g.

   'stream_clr': '"#B3C6D4"',
   'stream_font': "sc",

In this example, _stream_clr_ and _stream_font_ have values of "#B3C6D4" and "sc" respectively for all scales.

   'stream_width': {
      0:0,
      10:0.5,
      12:1,
      14:2
   },

In this case _stream_width_ has a value of 0 for scales 0 to 9, 0.5 for scales 10-11, 1 for scales 12-13, and 2 for scales 14 and up.