-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample1-1.html
More file actions
432 lines (363 loc) · 22.6 KB
/
example1-1.html
File metadata and controls
432 lines (363 loc) · 22.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
<!DOCTYPE html>
<html lang="el" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Example 1.1 — MapServer 8.6.2 documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../_static/sphinx.css?v=48f05237" />
<link rel="stylesheet" type="text/css" href="../_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="../_static/sphinx_collapse.css?v=226d88b4" />
<link rel="stylesheet" type="text/css" href="../_static/custom.css?v=dd298242" />
<link rel="stylesheet" type="text/css" href="../_static/ribbon.css?v=ea091bf4" />
<script src="../_static/jquery.js?v=5d32c60e"></script>
<script src="../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../_static/documentation_options.js?v=84745c96"></script>
<script src="../_static/doctools.js?v=fd6eb6e6"></script>
<script src="../_static/sphinx_highlight.js?v=6ffebe34"></script>
<script src="../_static/clipboard.min.js?v=a7894cd8"></script>
<script src="../_static/copybutton.js?v=f281be69"></script>
<script src="../_static/translations.js?v=e109e2be"></script>
<link rel="icon" href="../_static/mapserver.ico"/>
<link rel="author" title="Σχετικά με αυτά τα κείμενα" href="../about.html" />
<link rel="index" title="Ευρετήριο" href="../genindex.html" />
<link rel="search" title="Αναζήτηση" href="../search.html" />
<link rel="copyright" title="Copyright" href="../copyright.html" />
</head><body>
<!-- for main branch only, do not backport this -->
<table width="100%" style="width: 100%; background-color: white;">
<tr>
<td rowspan="2" style="padding: 10px 0px 10px 10px;">
<a href="../index.html" title="Home"><img src="../_static/banner.png" alt="MapServer banner" border="0" /></a>
</td>
<td style="padding: 10px 10px 0px 0px; text-align: right; vertical-align: top;">
<a href="../index.html" title="Home">Home</a> |
<a href="../products.html" title="Products (MapServer core, MapCache, TinyOWS">Products</a> |
<a href="https://github.com/mapserver/mapserver/issues/" title="Issue Tracker (MapServer core)">Issue Tracker</a> |
<a href="../community/service_providers.html" title="Professional Service Providers">Service Providers</a> |
<a href="../faq.html" title="Frequently Asked Questions">FAQ</a> |
<a href="https://fosstodon.org/@mapserver" title="Mastodon" target="_blank">Mastodon</a> |
<a href="../download.html" title="Download Source or Binaries">Download </a> |
<a class="badge" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KRJ2X44N3HA6U&source=url" target="_blank">
<img src="https://img.shields.io/badge/donate-%E2%9D%A4%C2%A0-ff69b4.svg?style=flat" alt="Donate to MapServer">
</a>
</td>
</tr>
<tr>
<td style="padding: 0px 10px 0px 0px; text-align: right; vertical-align: bottom;">
<a href="../../tutorial/example1-1.html"><img src="../_static/flagicons/en.png" alt="en" title="en" border="0" /></a>
<a href="../../ar/tutorial/example1-1.html"><img src="../_static/flagicons/ar.png" alt="ar" title="ar" border="0" /></a>
<a href="../../de/tutorial/example1-1.html"><img src="../_static/flagicons/de.png" alt="de" title="de" border="0" /></a>
<img src="../_static/flagicons/el.png" alt="el" title="el" border="0" width="18px" height="13px"/>
<a href="../../es/tutorial/example1-1.html"><img src="../_static/flagicons/es.png" alt="es" title="es" border="0" /></a>
<a href="../../fr/tutorial/example1-1.html"><img src="../_static/flagicons/fr.png" alt="fr" title="fr" border="0" /></a>
<a href="../../id/tutorial/example1-1.html"><img src="../_static/flagicons/id.png" alt="id" title="id" border="0" /></a>
<a href="../../it/tutorial/example1-1.html"><img src="../_static/flagicons/it.png" alt="it" title="it" border="0" /></a>
<a href="../../ja/tutorial/example1-1.html"><img src="../_static/flagicons/ja.png" alt="ja" title="ja" border="0" /></a>
<a href="../../nl_NL/tutorial/example1-1.html"><img src="../_static/flagicons/nl_NL.png" alt="nl_NL" title="nl_NL" border="0" /></a>
<a href="../../pl/tutorial/example1-1.html"><img src="../_static/flagicons/pl.png" alt="pl" title="pl" border="0" /></a>
<a href="../../ru/tutorial/example1-1.html"><img src="../_static/flagicons/ru.png" alt="ru" title="ru" border="0" /></a>
<a href="../../sq/tutorial/example1-1.html"><img src="../_static/flagicons/sq.png" alt="sq" title="sq" border="0" /></a>
<a href="../../tr/tutorial/example1-1.html"><img src="../_static/flagicons/tr.png" alt="tr" title="tr" border="0" /></a>
</td>
</tr>
</table>
<div class="related" role="navigation" aria-label="Related">
<h3>Πλοήγηση</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="Κεντρικό Ευρετήριοο"
accesskey="I">ευρετήριο</a></li>
<li class="nav-item nav-item-0"><a href="../index.html">Home</a> »</li>
<li class="nav-item nav-item-this"><a href="">Example 1.1</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="example-1-1">
<span id="example1-1"></span><h1>Example 1.1<a class="headerlink" href="#example-1-1" title="Link to this heading">¶</a></h1>
<section id="map-with-a-single-layer">
<h2>Map With A Single Layer<a class="headerlink" href="#map-with-a-single-layer" title="Link to this heading">¶</a></h2>
<img alt="https://demo.mapserver.org/cgi-bin/mapserv?map=/mapserver/apps/tutorial/htdocs/example1-1.map&layer=states&mode=map" src="https://demo.mapserver.org/cgi-bin/mapserv?map=/mapserver/apps/tutorial/htdocs/example1-1.map&layer=states&mode=map" />
<p>MapServer can create an image and dump it to a local directory or send
it directly to the requesting web browser, as in this example. You can
view it without the need for an html page, just enter this URL:
<a class="reference external" href="http://localhost/cgi-bin/mapserv?map=/ms4w/apps/tutorial/htdocs/example1-1.map&layer=states&mode=map">http://localhost/cgi-bin/mapserv?map=/ms4w/apps/tutorial/htdocs/example1-1.map&layer=states&mode=map</a>
. This URL will work if you are on the web server (if not,
«localhost» must be replaced with your web server’s name
(e.g. «demo.mapserver.org») or IP address (e.g. «140.211.15.84»).</p>
<p>This URL can be broken into three parts: the first part,
<a class="reference external" href="http://localhost/cgi-bin/mapserv">http://localhost/cgi-bin/mapserv</a>?, calls the MapServer CGI program. If
you invoke it as is you will get this familiar message:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">No</span> <span class="n">query</span> <span class="n">information</span> <span class="n">to</span> <span class="n">decode</span><span class="o">.</span> <span class="n">QUERY_STRING</span> <span class="ow">is</span> <span class="nb">set</span><span class="p">,</span> <span class="n">but</span> <span class="n">empty</span><span class="o">.</span>
</pre></div>
</div>
<p>The next three parts make up the query string. The query string
contains the CGI parameters (variables and their values), with each
parameter separated by an ampersand (»&»). So, looking at the query
string:</p>
<ul class="simple">
<li><p>The first parameter «map» has a value
«/ms4w/apps/tutorial/htdocs/example1-1.map». This tells the
MapServer CGI program (<strong>mapserv</strong> or <strong>mapserv.exe</strong>) what mapfile
to process/parse.</p></li>
<li><p>The next parameter (<em>layer=states</em>) tells <strong>mapserv</strong> to «turn
on» the states layer. Recall that we named our layer object
«states».</p></li>
<li><p>The last parameter (<em>mode=map</em>) tells <strong>mapserv</strong> what to do
with the output from the mapfile. In this case it tells <strong>mapserv</strong> to
dump the image directly to the web browser (the client), without
first creating a temporary image on the server.</p></li>
</ul>
<p>The MapServer <em>mode</em> CGI variable takes values other
than <em>map</em>. For example if you use <em>mode=browse</em>,
MapServer will dump the image to a temporary directory on the
server. The browse mode will not work now but we’ll come back to it
again later.</p>
<section id="mapfile-structure">
<h3>Mapfile Structure<a class="headerlink" href="#mapfile-structure" title="Link to this heading">¶</a></h3>
<p>This is what the mapfile looks like: <a class="reference internal" href="example1-1-map.html#example1-1-map"><span class="std std-ref">Example1-1.map</span></a>.</p>
<p>The <a class="reference internal" href="../mapfile/index.html#mapfile"><span class="std std-ref">MAPFILE</span></a> is MapServer’s basic configuration
mechanism. It is made up of «objects» and each object can have
keywords or other objects. It has a hierarchical structure such that
some objects fall under other objects… on top of this hierarchy is
the MAP object, all other objects belong to it. This example shows a
very straightforward hierarchy of objects. As you go through each
example, the complexity of these hierarchical trees will increase.</p>
<p>A few quick notes about mapfiles: we define each object in the mapfile
with the object name and we close it with «END» and we precede
comments with a pound (#) sign.</p>
<p>Let’s break «example1-1.map» down by objects. Its structure looks like
this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">MAP</span>
<span class="o">|-</span><span class="n">LAYER</span>
<span class="o">|-</span><span class="n">CLASS</span>
<span class="o">|-</span><span class="n">STYLE</span>
</pre></div>
</div>
<section id="map-object">
<h4>MAP Object<a class="headerlink" href="#map-object" title="Link to this heading">¶</a></h4>
<p>Let’s look at the keywords (parameters) within the MAP object:</p>
<dl>
<dt><strong>MAP</strong></dt><dd><p>Every mapfile must start with the <a class="reference internal" href="../mapfile/map.html#map"><span class="std std-ref">MAP</span></a> object–the
entire mapfile is the MAP object.</p>
</dd>
<dt><strong>IMAGETYPE</strong></dt><dd><p>The keyword IMAGETYPE is used to define which image format the
MapServer CGI program should use for output. In this case we are
using indexed color PNG (similar to GIF). This could be GIF, if we
compiled the GD library with GIF support, WBMP, or JPEG. We can
also specify other output options (PDF, SWF, GeoTIFF) provided that
we compiled support for them and specify them with the OUTPUTFORMAT
object. The OUTPUTFORMAT goes beyond the scope of this tutorial but
you can find out more about by reading through documentations in
the MapServer web site.</p>
</dd>
<dt><strong>EXTENT</strong></dt><dd><p>This parameter specifies the output extent of our map–the bounding
box of our initial map. The EXTENT values are given in this
format:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o"><</span><span class="n">Lower</span> <span class="n">Left</span> <span class="n">X</span><span class="o">></span> <span class="o"><</span><span class="n">Lower</span> <span class="n">Left</span> <span class="n">Y</span><span class="o">></span> <span class="o"><</span><span class="n">Upper</span> <span class="n">Right</span> <span class="n">X</span><span class="o">></span> <span class="o"><</span><span class="n">Upper</span> <span class="n">Right</span> <span class="n">Y</span><span class="o">></span>
</pre></div>
</div>
<p>with spaces separating each value. This needs to be in the same
units as the data or, if specifying a different output projection,
in the same units as the output projection.</p>
<p>In this example our data is in geographic projection so the units
are in decimal degrees. You can use the utility <a class="reference external" href="https://gdal.org/programs/ogrinfo.html">ogrinfo</a>, which is part of the
GDAL/OGR library package, to get the extent of a particular
Shapefile dataset (or other supported vector formats). Here is the
command I used to get the extent for this example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ogrinfo</span> <span class="o">-</span><span class="n">al</span> <span class="o">-</span><span class="n">so</span> <span class="n">states_ugl</span><span class="o">.</span><span class="n">shp</span>
</pre></div>
</div>
<p>This returned the following output:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>INFO: Open of `states_ugl.shp'
using driver `ESRI Shapefile' successful.
Layer name: states_ugl
Metadata:
DBF_DATE_LAST_UPDATE=2002-03-07
Geometry: Polygon
Feature Count: 204
Extent: (-97.238976, 41.619778) - (-82.122902, 49.385620)
Layer SRS WKT:
(unknown)
AREA: Real (12.3)
PERIMETER: Real (12.3)
STATESP020: Integer64 (11.0)
STATE: String (20.0)
STATE_FIPS: String (2.0)
CLASS: String (5.0)
</pre></div>
</div>
<p>You can also use <a class="reference external" href="https://qgis.org">QGIS</a> or other desktop software to
get the extent values.</p>
<p>Feel free to change the values of EXTENT to get a better
understanding of how it changes your map.</p>
</dd>
<dt><strong>SIZE</strong></dt><dd><p>This is the size of the image (the map) that MapServer will
generate, in pixels. So our map is 400 pixels wide by 300 pixels
high. Again, change this to your heart’s content and see how it
affects your map.</p>
</dd>
<dt><strong>SHAPEPATH</strong></dt><dd><p>This is the path to your data layers. You can provide absolute
paths (i.e. «/ms4w/apps/tutorial/data» or
«C:/ms4w/apps/tutorial/data») or paths relative to your mapfile’s
location (in this example, you’d use «../data»). This path doesn’t
have to be web accessible, and probably shouldn’t be unless you
want anyone to download your raw data. It has nothing directly to
do with the web so don’t even think of URLs here. Just make sure
that the user running the web server (usually «nobody» or «apache»
in the *nix world) can READ the data in the SHAPEPATH.</p>
</dd>
<dt><strong>IMAGECOLOR</strong></dt><dd><p>This is the background color of your map. The values are RGB values
so 255 Red, 255 Green, and 255 Blue which results in a white
background. Go ahead and play with this values.</p>
</dd>
</dl>
</section>
<section id="layer-object">
<h4>LAYER Object<a class="headerlink" href="#layer-object" title="Link to this heading">¶</a></h4>
<p>Now let’s look at the LAYER object parameters:</p>
<dl class="simple">
<dt><strong>LAYER</strong></dt><dd><p>Marks the beginning of a <a class="reference internal" href="../mapfile/layer.html#layer"><span class="std std-ref">LAYER</span></a> within the MAP
object. You can specify as many layers as you need (in MapServer
versions < 5, there was a limit that could be changed by editing
the map.h header file and recompiling MapServer; there is no longer
such limit).</p>
</dd>
<dt><strong>NAME</strong></dt><dd><p>This is the layer identifier. MapServer uses this name to toggle
the layer on and off. It won’t work in this example as we have the
layer STATUS set to default. We will get back to this in later
examples.</p>
</dd>
<dt><strong>DATA</strong></dt><dd><p>The name of the data (Shapefile dataset in this case). MapServer
supports vector data formats other than ESRI’s Shapefile format
through the use of OGR library (part of the GDAL software package).
Please visit the GDAL project web site at
<a class="reference external" href="https://gdal.org/">https://gdal.org/</a> and read
<a class="reference external" href="https://gdal.org/drivers/vector/index.html">https://gdal.org/drivers/vector/index.html</a> to learn more about the different
vector formats MapServer supports. In addition, Jeff McKenna and
Tyler Mitchell have written a detailed <a class="reference internal" href="../input/vector/index.html#vector"><span class="std std-ref">guide to using vector
data for MapServer</span></a>.</p>
</dd>
<dt><strong>TYPE</strong></dt><dd><p>What type of data is it? If it’s a vector data, you can specify
whether it is a POLYGON, LINE (you use LINE even if your data is
technically a POLYLINE), or a POINT. You can also specify RASTER, CHART,
or CIRCLE (ANNOTATION layers have been deprecated since MapServer 6.2).
Here we want to display POLYGON.</p>
</dd>
<dt><strong>STATUS</strong></dt><dd><p>Layers are turned on or off based on their STATUS. DEFAULT is
always on. ON or OFF works when the LAYER name is passed as part
of the query string.</p>
</dd>
</dl>
</section>
<section id="class-object">
<h4>CLASS Object<a class="headerlink" href="#class-object" title="Link to this heading">¶</a></h4>
<p>Let’s look at the CLASS object parameters:</p>
<dl class="simple">
<dt><strong>CLASS</strong></dt><dd><p>Marks the beginning of a <a class="reference internal" href="../mapfile/class.html#class"><span class="std std-ref">CLASS</span></a> object within the
LAYER object. You can specify as many classes within a layer as you need (in
MapServer versions < 5, there was a limit that could be changed by
editing the map.h header file and recompiling MapServer; there is no longer
such limit).</p>
</dd>
<dt><strong>NAME</strong></dt><dd><p>The descriptive identifier for this CLASS. LAYER objects can have
multiple classes, just like MAP objects can have multiple layers.
CLASS names are used by MapServer as labels for the legend so make
sure to use an appropriate descriptive name when naming classes.
We will talk about legends later in this tutorial.</p>
</dd>
</dl>
</section>
<section id="style-object">
<h4>STYLE Object<a class="headerlink" href="#style-object" title="Link to this heading">¶</a></h4>
<p>And finally, let’s look at the STYLE object parameters:</p>
<dl class="simple">
<dt><strong>STYLE</strong></dt><dd><p>Marks the beginning of the <a class="reference internal" href="../mapfile/style.html#style"><span class="std std-ref">STYLE</span></a> object. You can
define multiple styles within a class. This is useful when you
want to overlay a style over another.</p>
</dd>
<dt><strong>COLOR</strong></dt><dd><p>This is the fill color of the polygon. In case the TYPE is LINE,
this is the line color. The values are in RGB format.</p>
</dd>
<dt><strong>OUTLINECOLOR</strong></dt><dd><p>This is the outline color of the polygons. The values are in RGB
format. MapServer doesn’t draw polygon outlines by default, so if
you want to see polygon boundaries, you will want to define an
OUTLINECOLOR.</p>
</dd>
</dl>
<p>This ends the first example in this tutorial. You are encouraged to
change the values of the keywords in the mapfile. It will help you
understand what these keywords do.</p>
<hr class="docutils" />
<p><a class="reference internal" href="section1.html#tutorial-section1"><span class="std std-ref">Back to Section 1 index</span></a> | <a class="reference internal" href="example1-2.html#example1-2"><span class="std std-ref">Proceed to Example 1.2</span></a></p>
</section>
</section>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Σύντομη αναζήτηση</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Πάμε" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script><h3>Navigation</h3>
<p>
<a href="../about.html" title="About">About</a><br>
<a href="../products.html" title="Products">Products</a><br>
<a href="../community/index.html" title="Community">Community</a><br>
<a href="../development/index.html" title="Development">Development</a><br>
<a href="../download.html" title="Downloads">Downloads</a><br>
<a href="../documentation.html" title="Documentation">Documentation</a><br>
<a href="../faq.html" title="FAQ">FAQ</a><br>
<a href="../psc.html" title="PSC">PSC</a><br>
<a href="https://fosstodon.org/@mapserver" title="Mastodon">Mastodon</a>
</p>
<h3>Current Table Of Contents</h3>
<ul>
<li><a class="reference internal" href="#">Example 1.1</a><ul>
<li><a class="reference internal" href="#map-with-a-single-layer">Map With A Single Layer</a><ul>
<li><a class="reference internal" href="#mapfile-structure">Mapfile Structure</a><ul>
<li><a class="reference internal" href="#map-object">MAP Object</a></li>
<li><a class="reference internal" href="#layer-object">LAYER Object</a></li>
<li><a class="reference internal" href="#class-object">CLASS Object</a></li>
<li><a class="reference internal" href="#style-object">STYLE Object</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="Related">
<h3>Πλοήγηση</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="Κεντρικό Ευρετήριοο"
>ευρετήριο</a></li>
<li class="nav-item nav-item-0"><a href="../index.html">Home</a> »</li>
<li class="nav-item nav-item-this"><a href="">Example 1.1</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
© <a href="../copyright.html">Copyright</a> 2026, Open Source Geospatial Foundation.
Τελευταία ενημέρωση στις 2026-04-20.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 9.1.0.
</div>
</body>
</html>