[Mapserver-users] MapServer Tutorial 4.0 Example 1.4 no image

Pericles Nacionales nacional at cbs.umn.edu
Mon Feb 2 14:53:53 EST 2004


If I recall correctly, Example 1.4 is the labeling example.  I don't see
any LABEL objects on your mapfile though.  Anyway, other than looking
closely at the mapfile syntax, I'd also recommend checking to make sure
that the fonts (and the fonts directory) are accessible/readable by
everyone.  You might also check Apache's logs--access_log and
error_log--to see if there's anything that goes wrong when running the
MapServer CGI program.

Let me know if your problem doesn't go away.

Good luck!
-Perry

On Mon, 2 Feb 2004, Carol L Heydon wrote:

> I'm trying to work through Tutorial4.0 with MapServer 4.0 on Windows 2000.
>  I made the needed changes to the path information in the html and map
> files.  Everything works fine for Examples 1.1, 1.2, and 1.3, but from 1.4
> on the image does not display.  What's different beginning with example
> 1.4?
>
> data directory:  C:\Program Files\Apache
> Group\Apache2\htdocs\tutorial\data
> mapserv40 located in:  C:\Program Files\Apache
> Group\Apache2\htdocs\cgi-bin
>
> Mapfile:
> MAP
>   IMAGETYPE      PNG
>   EXTENT         201621.496941 -294488.285333 1425518.020722 498254.511514
>   SIZE           400 300
>   SHAPEPATH      "data"
>   IMAGECOLOR     255 255 255
>
>   PROJECTION
>     "proj=laea"
>     "ellps=clrk66"
>     "lat_0=45"
>     "lon_0=-100"
>   #
>   # Alternatively, you can specify an EPSG code.
>   # "init=epsg:2163"
>   #
>   END
>
>   # Start of LAYER DEFINITIONS
> ---------------------------------------------
>   LAYER # States polygon layer begins here
>     NAME         states_poly
>     DATA         states_ugl
>     STATUS       DEFAULT
>     TYPE         POLYGON
>
>     PROJECTION
>       "init=epsg:4326"
>     END
>
>     CLASSITEM    "CLASS"
>     CLASS
>       EXPRESSION 'land'
>        COLOR      232 232 232
>     END
>     CLASS
>       EXPRESSION 'water'
>        COLOR      198 198 255
>     END
>   END # States polygon layer ends here
>
>   LAYER # States line layer begins here
>     NAME         states_line
>     DATA         states_ugl
>     STATUS       DEFAULT
>     TYPE         LINE
>
>     PROJECTION
>       "init=epsg:4326"
>     END
>
>     CLASSITEM    "CLASS"
>     CLASS
>       EXPRESSION 'land'
>       COLOR      32 32 32
>     END
>   END # States line layer ends here
>   # End of LAYER DEFINITIONS -------------------------------
> END # end of map file
>
> html:
> <html>
> <head>
> <title>MapServer 4.0 Tutorial</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> <link type="text/css" rel="stylesheet" href="ms35.css" />
> </head>
>
> <body bgcolor="#FFFFFF" text="#000000">
> <table align="center" width="600" border="0">
> <tr>
> <td>
> <h3 align="center">Example 1.4: Labeling the Map</h3>
>       <div align="center"><img border="1"
> src="/cgi-bin/mapserv40?map=C:/Program Files/Apache
> Group/Apache2/htdocs/tutorial/example1-4.map&mode=map" />
>       </div>
>       <p align="left">We can also add labels to our map.</p>
>       <hr>
>       <p align="left">This is what the mapfile looks like:</p>
>       <pre align="left">MAP
>   IMAGETYPE PNG
>   EXTENT 201621.496941 -294488.285333 1425518.020722 498254.511514
>   SIZE 400 300
>   SHAPEPATH &quot;data&quot;
>   IMAGECOLOR 255 255 255
>   FONTSET &quot;fonts/fonts.list&quot;
>
>   PROJECTION
>     &quot;proj=laea&quot;
>     &quot;ellps=clrk66&quot;
>     &quot;lat_0=45&quot;
>     &quot;lon_0=-100&quot;
>   #
>   # Alternatively, you can specify an EPSG code.
>   # &quot;init=epsg:2163&quot;
>   #
>   END
>
>   # Start of LAYER DEFINITIONS
> ---------------------------------------------
>   LAYER # States polygon layer begins here
>     NAME states_poly
>     DATA states_ugl
>     STATUS DEFAULT
>     TYPE POLYGON
>
>     PROJECTION
>       &quot;init=epsg:4326&quot;
>     END
>
>     CLASSITEM &quot;CLASS&quot;
>     LABELITEM &quot;STATE&quot;
>     CLASS
>       EXPRESSION 'land'
>       COLOR 232 232 232
>       LABEL
>         COLOR 132 31 31
>         SHADOWCOLOR 218 218 218
>         SHADOWSIZE 2 2
>         TYPE TRUETYPE
>         FONT arial-bold
>         SIZE 12
>         ANTIALIAS TRUE
>         POSITION CL
>         PARTIALS FALSE
>         MINDISTANCE 300
>         BUFFER 4
>       END # end of label
>     END
>   END # States polygon layer ends here
>
>   LAYER # States line layer begins here
>     NAME states_line
>     DATA states_ugl
>     STATUS DEFAULT
>     TYPE LINE
>
>     PROJECTION
>       &quot;init=epsg:4326&quot;
>     END
>
>     CLASSITEM &quot;CLASS&quot;
>     CLASS
>       EXPRESSION 'land'
>       COLOR 64 64 64
>     END
>   END # States line layer ends here
>   # End of LAYER DEFINITIONS -------------------------------
> END # end of map file</pre>
>       <hr align="center" width="300">
>       <p>Here we introduce a few more parameters along with the LABEL
> object:</p>
>       <p>FONTSET<br>
>         Here we specify the full path to our truetype fonts list (or font
> set)
>         file. This file lists each of the available fonts. See the file
> itself
>         and the <a
> href="http://mapserver.gis.umn.edu/doc40/fontset.html">MapServer
>         fonset documentation</a> for more info. FONTSET is a parameter of
> the
>         MAP object.</p>
>       <p>LABELITEM<br>
>         This specifies which data attribute to use for labeling, in this
> case
>         &quot;STATE&quot;. LABELITEM is a parameter of the LAYER
> object.</p>
>       <p>LABEL<br>
>         Marks the beginning of the LABEL object. The label object can be
> used
>         under other objects (i.e. the SCALEBAR object).</p>
>       <p> COLOR<br>
>         Within the LABEL object, COLOR specifies the color of the label
> text.</p>
>       <p>SHADOWCOLOR<br>
>         This specifies the shadow color of the label text.</p>
>       <p>SHADOWSIZE<br>
>         Specifies the shadow size. The value corresponds to the X and the
> Y shifts
>         in pixels. So, &quot;2 2&quot; means two pixels wide by two pixels
> high.</p>
>       <p>TYPE<br>
>         Within the LABEL object, TYPE specifies what type of font to use.
> We have
>         the choice of TRUETYPE or BITMAP (the built-in fonts). We choose
> TRUETYPE.</p>
>       <p>FONT<br>
>         If you specify TYPE as TRUETYPE, you need to specify what font to
> use.
>         The value here is the &quot;alias&quot; in the font list file.</p>
>       <p>SIZE<br>
>         If using truetype fonts, the value is size in pixels. If bitmap,
> you can
>         say something like &quot;small&quot; or &quot;large&quot;.</p>
>       <p>ANTIALIAS<br>
>         This turns truetype antialiasing on or off. Remember the value
> isn't on
>         or off but TRUE or FALSE.</p>
>       <p>POSITION<br>
>         Where to position the label text in relation to the label points.
> The
>         value is a combination of vertical and horizontal positions. You
> have
>         the following choices for vertical alignment: C for center, U for
> upper,
>         and L for lower. For horizontal alignment you have the following
> choices:
>         C for center, L for left, and R for right. So, to align the label
> text
>         to the center of label ID you'd use the value &quot;CC&quot;
> (center-center).
>         Or if you'd like it to be on the lower left of the ID, you'd use
> LL. Another
>         way is to let MapServer decide the best position for your labels.
> For
>         this you would use the value &quot;AUTO&quot;.</p>
>       <p>PARTIALS<br>
>         Tells MapServer whether to generate incomplete label texts or not.
> The
>         default here is not to generate fragments of a label text. The
> value is
>         either TRUE or FALSE.</p>
>       <p>MINDISTANCE<br>
>         This is the minimum distance in pixels between duplicate labels.
> See what
>         happens if you increase or decrease this value.</p>
>       <p>BUFFER<br>
>         The padding (in pixels) for each label. This is used to enhance
> readability.
>         A BUFFER of 4 pixels mean that no label will be drawn within four
> pixels
>         of each other. Again, change to see how it works.<br>
>       </p>
>       <hr align="center" width="300">
>       <p>You can also create labels separate from a POLYGON layer. You do
> this
>         with the ANNOTATION data type. Have a look at the file
> &quot;example1-4a.map&quot;
>         to see how you'd implement this kind of labeling. You will notice
> that
>         the CLASS object within the &quot;label&quot; layer has a COLOR
> parameter
>         value of &quot;-1 -1 -1&quot;. The negative number tells MapServer
> to
>         give this CLASS a transparent color (the label IDs don't show up).
> Once
>         again, play with the values to understand how it affects the
> map.</p>
>       <hr>
>       <p class="Small" align="center"><a href="example1-3.html">Back to
> Example
>         1.3</a> | <a href="section1.html">Back to the Section 1</a> | <a
> href="sections.html">Back to the Sections Page</a>
>                 | <a href="example1-5.html">Proceed to Example 1.5</a></p>
>       </td>
> </tr>
> </table>
> </body>
> </html>
>
> image tag as obtained from 'view source':
> <img border="1" src="/cgi-bin/mapserv40?map=C:/Program Files/Apache
> Group/Apache2/htdocs/tutorial/example1-4.map&mode=map" />



More information about the mapserver-users mailing list