Coverage for gws-app/gws/lib/mapserver/__init__.py: 100%
2 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-24 12:46 +0200
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-24 12:46 +0200
1"""MapServer support.
3This module dynamically creates and renders MapServer maps.
5To render a map, create a map object with `new_map`, add layers to it using ``add_`` methods
6and invoke ``draw``.
8Reference: MapServer documentation (https://mapserver.org/documentation.html)
10Example usage::
12 import gws
13 import gws.lib.mapserver as ms
15 # create a new map
16 map = ms.new_map()
18 # add a raster layer from an image file
19 map.add_layer(
20 gws.MapServerLayerOptions(
21 type=gws.MapServerLayerType.raster,
22 path='/path/to/image.tif',
23 )
24 )
26 # add a layer using a configuration string
27 map.add_layer_from_config('''
28 LAYER
29 TYPE LINE
30 STATUS ON
31 FEATURE
32 POINTS
33 751539 6669003
34 751539 6672326
35 755559 6672326
36 END
37 END
38 CLASS
39 STYLE
40 COLOR 0 255 0
41 WIDTH 5
42 END
43 END
44 END
45 ''')
47 # draw the map into an Image object
48 img = map.draw(
49 bounds=gws.Bounds(
50 extent=[738040, 6653804, 765743, 6683686],
51 crs=gws.lib.crs.WEBMERCATOR,
52 ),
53 size=(800, 600),
54 )
56 # save the image to a file
57 img.to_path('/path/to/output.png')
60"""
62from .core import version, Error, new_map, Map
63from . import util