2.2. Add a graticule#

In order to accurately indicate the location of each place on the earth, people assume a coordinate system for the earth’s surface, which is the latitude and longitude coordinate system.

On maps and globes, we can see thin lines, some horizontal and some vertical, which are the longitude and latitude. The warp and weft are intertwined, much like the squares on a chessboard, forming a warp and weft network.

According to these longitude and latitude lines, the position and direction of any place on the ground can be accurately determined. Using the longitude and latitude marked on it, various locations, regions and various geographic locations on the earth’s surface can be determined. It is useful in military, aviation, navigation, etc. For example, a ship is sailing on the vast sea, and an airplane is flying in the vast sky. No matter where you go, people can use instruments to accurately measure its latitude and longitude to determine its position.

2.2.1. View examples#

In MapServer, latitude and longitude lines can be drawn on the map according to its cartographic capabilities. This feature is a latecomer, originally developed by John Novak in 2003. The drawing of graticules is almost necessary for desktop mapping to facilitate location determination when reading maps; however, it is not necessary for WebGIS. WebGIS enhances the user’s operations on the map, and the latitude and longitude coordinates can be quickly obtained through the spatial query function.

The image below is an example, drawn on a map with latitude and longitude lines, with the longitude and latitude of the longitude lines drawn to the ends of the line.

Here is its Mapfile :

 3    EXTENT -180 -90 180 90
 4    SIZE 600 300
 5    SHAPEPATH "/gdata"
 6    IMAGECOLOR 255 255 255
 7    FONTSET "../fonts/fonts.list"
 8    SYMBOLSET "../symbols/symbols35.sym"
 9    LAYER
10        NAME "topo"
11        DATA "land_shallow_topo_8192.tif"
12        STATUS OFF
13        TYPE RASTER
14        PROCESSING "BANDS=1,2,3"
15        OFFSITE 71 74 65
16    END
17    LAYER
18        NAME "states_line"
19        DATA "wcountry.shp"
20        STATUS OFF
21        TYPE LINE
22        CLASS
23            NAME "State Boundary"
24            STYLE
25                SYMBOL "line5"
26                COLOR 255 255 0
27                SIZE 1
28            END
29        END
30    END
31    LAYER
32        NAME "grid"
33        METADATA
34            "description" "Grid"
35        END
36        TYPE LINE
37        STATUS ON
38        CLASS
39            NAME "Graticule"
40            COLOR 0 0 0
41            LABEL
42                COLOR 255 0 0
43                FONT "arial-bold"
44                TYPE TRUETYPE
45                SIZE 8
46                POSITION AUTO
47                PARTIALS FALSE
48                BUFFER 2
49                OUTLINECOLOR 255 255 255
50            END
51        END
52        PROJECTION
53            "init=epsg:4326"
54        END
55        GRID
56            LABELFORMAT DD
57        END
58    END

2.2.2. Code modification#

Compared with the previously released image map, the code changes are as follows: