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            LABEL
41                COLOR 255 0 0
42                FONT "arial-bold"
43                TYPE TRUETYPE
44                SIZE 8
45                POSITION AUTO
46                PARTIALS FALSE
47                BUFFER 2
48                OUTLINECOLOR 255 255 255
49            END
50        END
51        PROJECTION
52            "init=epsg:4326"
53        END
54        GRID
55            LABELFORMAT DD
56        END
57    END

2.2.2. Code modification#

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

Open the file:diff_mfd8_mfa5.html