[Mapserver-users] Anti-Aliasing of lines

Tomas Krecmer tokr at tmapy.cz
Fri Mar 19 02:28:37 EST 2004


This is a multi-part message in MIME format.
--------------060703010707040202050308
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

There is support in MapServer 4.x right now. Use a cartoline symbol. See 
the attached documentation.

Tomas

Alexander Pucher wrote:

> Hi all,
>
> Steve, please excuse if this isn't the right place for this 
> discussion. I checked the GD documentation 
> (http://www.boutell.com/gd/manual2.0.22.html) and found this:
>
> ------------------------------------------
> What's new in version 2.0.12?
>
> [...]
>
> Support for fast drawing of antialiased lines and polygons, by Bright 
> Fulton and Frank Faubert. To learn more about this feature, read about 
> the gdImageSetAntiAliased 
> <http://www.boutell.com/gd/manual2.0.22.html#gdImageSetAntiAliased> 
> function, which is used to set the foreground color for antialiasing, 
> as well as the gdAntiAliased 
> <http://www.boutell.com/gd/manual2.0.22.html#gdAntiAliased> constant, 
> which is passed to line- and polygon-drawing functions in place of a 
> color.
>
> [...]
>
> gdAntiAliasing(CONSTANT)
> Used in place of a color when invoking a line-drawing function such as 
> gdImageLine <http://www.boutell.com/gd/manual2.0.22.html#gdImageLine> 
> or gdImageRectangle 
> <http://www.boutell.com/gd/manual2.0.22.html#gdImageRectangle>. When 
> gdAntiAliased is used as the color, the foreground color set with 
> gdImageSetAntiAliased 
> <http://www.boutell.com/gd/manual2.0.22.html#gdImageSetAntiAliased> is 
> used, with antialiasing mechanisms to minimize any "jagged" 
> appearance. For more information, see gdImageSetAntiAliased 
> <http://www.boutell.com/gd/manual2.0.22.html#gdImageSetAntiAliased>.
>
> [...]
> ------------------------------------------
>
> So, it seems that GD is able to draw anti-aliased lines. Is there a 
> way to let mapserver use these functionality?
>
> Thanks for any input.
> alex.
>
>
>
> Steve Lime wrote:
>
>> Yup, we can do what GD does at this point.
>> Steve
>>
>>  
>>
>>>>> Alexander Pucher <pucher at atlas.gis.univie.ac.at> 3/17/2004 8:12:14
>>>>>       
>>>>
>> AM >>>
>> Hi,
>>
>> what is the recent status of anti-aliasing of lines in MapServer. The 
>> limitation is GD, is this correct?
>>
>> regards,
>> alex.
>>
>> _______________________________________________
>> Mapserver-users mailing list
>> Mapserver-users at lists.gis.umn.edu 
>> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>>
>>
>>  
>>
>

-- 
Tomas Krecmer, tomas.krecmer at tmapy.cz
T-MAPY spol. s r.o., Nezvalova 850, 500 03 Hradec Kralove,
Czech Republic, phone: + 420 49 5513335 , fax + 420 49 5513371


--------------060703010707040202050308
Content-Type: message/rfc822;
 name="Attached Message"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="Attached Message"

Message-ID: <3F28BB2D.7040606 at tmapy.cz>
Date: Thu, 31 Jul 2003 08:46:05 +0200
From: Tomas Krecmer <tomas.krecmer at tmapy.cz>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Steve Lime <steve.lime at dnr.state.mn.us>
CC:  tokr at tmapy.cz
Subject: CartoLine symbol documentation
References: <sf277f3f.091 at co5.dnr.state.mn.us>
In-Reply-To: <sf277f3f.091 at co5.dnr.state.mn.us>
Content-Type: multipart/mixed;
 boundary="------------080608050004080306030101"

This is a multi-part message in MIME format.
--------------080608050004080306030101
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi Steve,

I added a few parts about the Cartoline symbol into the Mapfile 
reference file. Please correct it and put into the documentation. All 
added lines are RED.

Have a nice day
Tomas

-- 
Tomas Krecmer, tomas.krecmer at tmapy.cz
T-MAPY spol. s r.o., Nezvalova 850, 500 03 Hradec Kralove,
Czech Republic, phone: + 420 49 5513335 , fax + 420 49 5513371


--------------080608050004080306030101
Content-Type: text/html;
 name="symbol-cartoline.html"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="symbol-cartoline.html"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type"
 content="text/html; charset=ISO-8859-1">
  <title>MapFile Reference - MapServer 4.0</title>
  <meta name="generator" content="DocBook XSL Stylesheets V1.50.0">
  <script xmlns="http://www.w3.org/TR/xhtml1/transitional"
 language="javascript" src="../javascript/include.js"></script>
</head>
<body bgcolor="white" text="black" link="#0000ff" vlink="#840084"
 alink="#0000ff" marginheight="0" marginwidth="0" style="">
<script xmlns="http://www.w3.org/TR/xhtml1/transitional"
 language="javascript">
  header("doc");
  comment();
  </script>
<div class="article">
<div>
<h3 class="title">Style Object</h3>
<p>This
object holds parameters for symbolization. Multiple styles may be
applied within a class. This object is new in 4.0 and is intended to
seperate logic from looks. The final intent is to have named styles
(Not yet supported) that will be re-usable through the mapfile. This is
the new, preferred way of defining the appearance of an object, notably
a class.</p>
<div class="variablelist">
<dl>
  <dt><span class="term">ANTIALIAS [true|false]</span></dt>
  <dd>
    <p>Should TrueType fonts <span style="color: rgb(255, 0, 0);">and
Cartoline symbols </span>be antialiased. <br>
    </p>
  </dd>
  <dt><span class="term">BACKGROUNDCOLOR [r] [g] [b]</span></dt>
  <dd>
    <p>Color to use for non-transparent symbols.</p>
  </dd>
........................................................<br>
  <br>
  <br>
</dl>
</div>
<h2 class="title"><a name="symbology"></a>Symbology Reference</h2>
</div>
<div class="sect1">
<p>This section explains how to work with and define symbology in
MapServer.</p>
<div class="sect2">
<div class="titlepage">
<div>
<h3 class="title"><a name="d45e1642"></a>Notes</h3>
</div>
</div>
<div class="itemizedlist">
<ul type="disc">
  <li>
    <p>Symbol definitions can be included within the main MapFile or,
more commonly, in a separate file. Symbol definitions in a separate
file are designated using the <a href="#symbolset">SYMBOLSET</a>
keyword, as part of the <a href="#map" title="Map Object">Map Object</a>.
This recommended setup is ideal for re-using symbol definitions across
multiple MapServer applications.</p>
  </li>
  <li>
    <p>There are 3 main types of symbols in MapServer: Markers,
Shadesets, and Lines.</p>
  </li>
  <li>
    <p>Symbol 0 is always the degenerate case for a particular class of
symbol. For points, symbol 0 is a single pixel, for shading (i.e.
filled polygons) symbol 0 is a solid fill, and for lines, symbol 0 is a
single pixel wide line.</p>
  </li>
  <li>
    <p>Symbol definitions contain <span class="emphasis"><em>no</em></span>
color information, colors are set within <a href="#class"
 title="Class Object">CLASS</a> objects.</p>
  </li>
  <li>
    <p>There is a maximum of 64 symbols per file. This can be changed
by editing mapsymbol.h and changing the value of MS_MAXSYMBOLS at the
top of the file.</p>
  </li>
</ul>
</div>
</div>
<div class="sect2">
<div class="titlepage">
<div>
<h3 class="title"><a name="d45e1673"></a>Syntax</h3>
</div>
</div>
<div class="variablelist">
<dl>
  <dt><span class="term">ANTIALIAS [true|false]</span></dt>
  <dd>
    <p>Should TrueType fonts be antialiased.</p>
  </dd>
  <dt><span class="term">CHARACTER [char]</span></dt>
  <dd>
    <p>Character used to reference a particular TrueType font
character. You'll need to figure out the mapping from the keyboard
character to font character.</p>
  </dd>
  <dt><span class="term">FILLED [true|false]</span></dt>
  <dd>
    <p>Sets the symbol to be filled with a user defined color (See the <a
 href="#class" title="Class Object">CLASS</a> object). For marker
symbols, if <a href="#outlinecolor">OUTLINECOLOR</a> was specified
then the symbol is outlined with it.</p>
  </dd>
  <dt><span class="term">FONT [string]</span></dt>
  <dd>
    <p>Name of TrueType font to use as defined in the <a
 href="#fontset">FONTSET</a>.</p>
  </dd>
  <dt><span class="term">GAP [int]</span></dt>
  <dd>
    <p>Given in pixels. This defines a distance between symbols for
TrueType lines.</p>
  </dd>
  <dt><span class="term">IMAGE [string]</span></dt>
  <dd>
    <p>Image (GIF or PNG) to use as a marker or brush for type PIXMAP
symbols.</p>
  </dd>
  <dt><span class="term">NAME [string]</span></dt>
  <dd>
    <p>Alias for this font to be used in CLASS objects</p>
  </dd>
  <dt style="color: rgb(255, 0, 0);"><span class="term">LINECAP
[butt|round|square|triangle]</span></dt>
  <dd style="color: rgb(255, 0, 0);">
    <p>Sets the line cap type for the cartoline symbol. Default is
butt. Works with the CARTOLINE symbol only!<br>
    </p>
  </dd>
  <dt style="color: rgb(255, 0, 0);"><span class="term">LINEJOIN
[round|miter|bevel]</span></dt>
  <dd style="color: rgb(255, 0, 0);">
    <p>Sets the line join type for the cartoline symbol. Default is
"none" - lines will not be joined . Works with the CARTOLINE symbol
only!</p>
  </dd>
  <dt style="color: rgb(255, 0, 0);"><span class="term">LINEJOINMAXSIZE
[num]</span></dt>
  <dd style="color: rgb(255, 0, 0);">
    <p>Sets the max length of the miter line join type. The value
represents a coefficient which multitplies a current symbol size. Default
is 3. Works with the CARTOLINE symbol only!</p>
  </dd>
  <dt><span class="term">POINTS [x y] [x y] ... END<br>
    </span></dt>
  <dd>
    <p>Signifies the start of the definition of points that make up a
vector symbol or that define the x and y radius of an ellipse symbol.
The end of this section is signified with the keyword END. Coordinates
are given in pixels and define the default size of the symbol before
any scaling. You can create non-contiguous paths by inserting negative
coordinates at the appropriate place. For ellipse symbols you provide a
single point that defines the x and y radius of an ellipse. Circles are
created when x and y are equal.</p>
  </dd>
  <dt><span class="term">STYLE [num on] [num off] [num on] ... END</span></dt>
  <dd>
    <p>Defines a dash style or pattern.</p>
  </dd>
  <dt><span class="term">TRANSPARENT [color index]</span></dt>
  <dd>
    <p>Sets a transparent color for the input GIF image for pixmap
symbols, or determines whether all shade symbols should have a
transparent background. For shade symbols it may be desirable to have
background features "show through" a transparent hatching pattern,
creating a more complex map. By default a symbol's background is the
same as the parent image (i.e. color 0). This is user configurable.</p>
  </dd>
  <dt><span class="term">TYPE [vector|ellipse|pixmap|truetype|simple<span
 style="color: rgb(255, 0, 0);">|cartoline</span>]</span></dt>
  <dd>
    <p> </p>
    <div class="itemizedlist">
    <ul type="disc">
      <li>
        <p>vector: a simple drawing is used to define the shape of the
symbol.</p>
      </li>
      <li>
        <p>ellipse: radius values in the x and y directions define an
ellipse.</p>
      </li>
      <li>
        <p>pixmap: a user supplied GIF image will be used as the symbol.</p>
      </li>
      <li>
        <p>truetype: TrueType font to use as defined in the <a
 href="#fontset">FONTSET</a>.</p>
      </li>
    </ul>
    </div>
    <p></p>
  </dd>
</dl>
</div>
</div>
<div class="sect2">
<div class="titlepage">
<div>
<h3 class="title"><a name="examples"></a>Examples</h3>
</div>
</div>
<p>Here are some examples illustrating the various ways to create
symbols in MapServer:</p>
<div class="example">
<p class="title"><b>Example 3. Dashed Line</b></p>
<pre class="programlisting">SYMBOL<br>  NAME 'dashed1'<br>  TYPE ELLIPSE<br>  POINTS 1 1 END<br>  FILLED true<br>  STYLE 10 5 5 10 END<br>END<br></pre>
<p>This creates a dashed line with 10 pixels on, 5 off, 5 on, 10 off ...</p>
</div>
<div class="example">
<p class="title"><b>Example 4. TrueType font marker symbol</b></p>
<pre class="programlisting">SYMBOL<br>  NAME "natcap"<br>  TYPE TRUETYPE<br>  FONT geo<br>  FILLED true<br>  ANTIALIAS true<br>  CHARACTER "&amp;#114;"<br>END<br>					</pre>
<p>This symbol is a star, used to represent the national capital, hence
the name. The font name in defined in the <a href="#fontset">FONTSET</a>
file. The code number "114" varies, you can use MS Windows' character
map to figure it out, or guestimate.</p>
</div>
<div class="example">
<p class="title"><b>Example 5. Vector triangle marker symbol</b></p>
<pre class="programlisting">SYMBOL<br>  NAME "triangle"<br>  TYPE vector<br>  POINTS<br>    0 4<br>    2 0<br>    4 4<br>    0 4<br>  END<br>END<br>				</pre>
<p>This is fairly straight forward. Note that to have 3 sides you need
4 points, hence the first and last points are identical.</p>
</div>
<div class="example">
<p class="title"><b>Example 6. Non-contiguous vector marker symbol
(Cross)</b></p>
<pre class="programlisting">SYMBOL<br>  NAME "cross"<br>  TYPE vector<br>  POINTS<br>    2 0<br>    2 4<br>    -99 -99<br>    0 2<br>    4 2<br>  END <br>END<br>				</pre>
<p>This example draws a cross, that is 2 lines (vectors) that are not
connected end-to-end (Like the triangle in the previous example). The
negative values separate the two.</p>
</div>
<div class="example">
<p class="title"><b>Example 7. Circle vector symbol</b></p>
<pre class="programlisting">SYMBOL<br>  NAME "circle"<br>  TYPE ellipse<br>  FILLED true<br>  POINTS<br>    1 1<br>  END<br>END<br>				</pre>
<p>A simple filled circle. Using non-equal values for the point will
give you an actual ellipse.</p>
</div>
<div class="example">
<p class="title"><b>Example 8. Downward diagonal fill</b></p>
<pre class="programlisting">SYMBOL   <br>  NAME "downwarddiagonalfill"<br>  TYPE vector<br>  TRANSPARENT 0<br>  POINTS<br>    0 1<br>    1 0<br>  END   <br>END<br>			</pre>
<div class="example" style="color: rgb(255, 0, 0);">
<p class="title" style="font-weight: bold;">Example 9. Dashed Cartoline
symbol
</p>
<pre class="programlisting">SYMBOL   <br>  NAME "cartoline"<br>  TYPE cartoline<br>  LINECAP butt<br>  LINEJOIN miter<br>  LINEJOINMAXSIZE 1<br>  STYLE 10 5<br>END<br><br></pre>
This creates a dashed line with 10 pixels on, 5 off,... The line will
have butt caps and short miter joins. For layers with a scaled symbol
(SYMBOLSCALE, MINSIZE, MAXSIZE, ...) will be the STYLE&nbsp; resized to
maintain symbol ratios.<br>
<br>
</div>
</div>
</div>
</div>
</div>
<table xmlns="http://www.w3.org/TR/xhtml1/transitional" align="center"
 width="75%" border="1">
  <tbody>
    <tr>
      <td bgcolor="#ffff66"><a href="javascript:add_comment()"><font
 size="+1">Add a Comment</font></a></td>
    </tr>
<!--#include file=".txt"-->
  </tbody>
</table>
<script xmlns="http://www.w3.org/TR/xhtml1/transitional"
 language="javascript">doc_footer();</script>
</body>
</html>

--------------080608050004080306030101--


--------------060703010707040202050308--



More information about the mapserver-users mailing list