<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman","serif";
mso-believe-normal-left:yes;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><![if mso 9]><style>p.MsoNormal
{margin-left:3.0pt;}
</style><![endif]><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple" style="margin-left:3.0pt;margin-top:3.0pt;margin-right:3.0pt;margin-bottom:.75pt">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Robert,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">It may be that the SDE plugin does not allow insertion of the Sql fragment from the COLOR to be executed by the provider. In such a case the solution provided
under separate cover by B. Heath Robinson might provide guidance. I do not know if the ArcGIS Server lets you use a view as a data source; if so you could add a calculated column to yield the RGB string (either as a hexadecimal valye as suggested by Heath)
or as a string with space-delimited R, G and B values.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">FWIW the approach I had suggested worked in MapServer 5.6.2 against Sql Server 2008; beyond that I’ve not tried it.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- Phil<o:p></o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin:0in;margin-bottom:.0001pt"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Robert Sanson [mailto:Robert.Sanson@asurequality.com]
<br>
<b>Sent:</b> Wednesday, July 06, 2011 4:48 PM<br>
<b>To:</b> Anzel, Phil - Fort Collins, CO; mapserver-users@lists.osgeo.org<br>
<b>Subject:</b> RE: Random colours for polygon fill?<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin:0in;margin-bottom:.0001pt">Looks an interesting approach. I tried it with my layer in ArcGIS Server (stored in MS-SQL v 2005) and couldn't get it to work. I am using Mapserver 5.4.2<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin:0in;margin-bottom:.0001pt"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin:0in;margin-bottom:.0001pt">Here is my layer:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin:0in;margin-bottom:.0001pt"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin:0in;margin-bottom:.0001pt">LAYER<br>
NAME fbnd<br>
GROUP "CRS"<br>
TYPE POLYGON<br>
STATUS ON<br>
CONNECTIONTYPE SDE<br>
CONNECTIONTYPE PLUGIN<br>
PLUGIN "d:/ms4w/apache/specialplugins/msplugin_sde_93.dll"<br>
CONNECTION "db-esri,port:5155,cadastre,user,pass"<br>
DATA "CADASTRE.SDEADMIN.VW_FARM_BOUNDARY_SP,SHAPE"<br>
DUMP TRUE<br>
HEADER ../templates/apiaries_query_header.html<br>
TEMPLATE ../templates/apiaries_query_body.html<br>
LABELMAXSCALE 100000<br>
LABELCACHE on<br>
LABELITEM 'key_decision_maker'<br>
MAXSCALE 250000<br>
CLASS<br>
NAME "fbnd"<br>
DEBUG on<br>
STYLE<br>
WIDTH 3<br>
#COLOR 135 206 235<br>
COLOR [convert(varchar(3), ((128 + convert(int,env_min_x)) % 253)) + " " + convert(varchar(3), ((200 + convert(int,env_min_x)) % 254)) + " " + convert(varchar(3), ((64 + convert(int,env_min_x)) % 255))]<br>
OUTLINECOLOR 0 255 0<br>
END<br>
LABEL<br>
TYPE truetype<br>
FONT "arial"<br>
SIZE 9<br>
POSITION auto<br>
OUTLINECOLOR 255 255 255 #--Halo<br>
COLOR 76 179 145 <br>
MINDISTANCE 50<br>
BUFFER 2<br>
END #LABEL<br>
END #CLASS<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin:0in;margin-bottom:.0001pt">Many thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin:0in;margin-bottom:.0001pt"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin:0in;margin-bottom:.0001pt">Robert<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in">
<br>
>>> "Anzel, Phil - Fort Collins, CO" <Phil.Anzel@ftc.usda.gov> 7/07/2011 2:11 a.m. >>><br>
Hi, Robert,<br>
<br>
A simple approach would be to generate a pseudo-random color based upon a value unique to each record in your source data. For example, in the following example the source data, pulled from a Microsoft Sql Server database, has an integer column named "ShapeID":<br>
<br>
layer<br>
name "mupolygon"<br>
status on<br>
connectiontype plugin<br>
plugin "C:/ms4w/Apache/specialplugins/msplugin_mssql2008.dll"<br>
processing "CLOSE_CONNECTION=DEFER"<br>
connection "server=...;"<br>
projection 'init=epsg:4269' END # NAD83<br>
units DD<br>
DATA "shapeGeometry from soilmu_a_wy721_nad83 using unique shapeID using SRID=4269"<br>
type polygon<br>
opacity 40<br>
class<br>
name "mupoly"<br>
style<br>
COLOR [convert(varchar(3), (128 + shapeID) % 253) + ' ' + convert(varchar(3), (200 + shapeID) % 254) + ' ' + convert(varchar(3), (64 + shapeID) % 255)]<br>
outlinecolor 0 0 0<br>
outlinewidth 1<br>
end<br>
end # of class "mupoly"<br>
end # of layer "mupolygon"<br>
<br>
In the context used above, the content of COLOR's specification (everything between the square brackets) is passed on as part of the SQL statement generated and transmitted to the database engine. Many variations are possible. Note that this approach does not
provide any protection against the unlikely case where adjacent polygons display the same color.<br>
<br>
I cannot speak to using data from other data sources. Best of luck with this.<br>
<br>
- Phil Anzel<br>
Web Soil Survey developer<br>
Vistronix Inc for USDA/NRCS/ITC<br>
<br>
<br>
-----Original Message-----<br>
<br>
------------------------------<br>
<br>
Message: 4<br>
Date: Wed, 06 Jul 2011 09:08:28 +1200<br>
From: "Robert Sanson" <Robert.Sanson@asurequality.com><br>
Subject: [mapserver-users] Random colours for polygon fill?<br>
To: <mapserver-users@lists.osgeo.org><br>
Message-ID: <4E14260B.379F.0037.1@asurequality.com><br>
Content-Type: text/plain; charset="us-ascii"<br>
<br>
Dear Mapserver users<br>
<br>
Just wondering if it is possible to colour a polygon Shape file layer with each distinct polygon having a different colour?<br>
<br>
Many thanks,<br>
<br>
Robert Sanson<o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in">
<o:p> </o:p></p>
<p align="center" style="text-align:center"><span style="background:white">This email and any attachments are confidential and intended solely for the addressee(s). If you are not the intended recipient, please notify us immediately and then delete this email
from your system.</span><o:p></o:p></p>
<p align="center" style="text-align:center"><span style="background:white">This message has been scanned for Malware and Viruses by Websense Hosted Security.
</span><a href="http://www.websense.com/"><span style="color:black;background:white">www.websense.com</span></a><o:p></o:p></p>
</div>
</body>
</html>