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
Here is my layer:
LAYER
NAME fbnd
GROUP "CRS"
TYPE POLYGON
STATUS ON
CONNECTIONTYPE SDE
CONNECTIONTYPE PLUGIN
PLUGIN "d:/ms4w/apache/specialplugins/msplugin_sde_93.dll"
CONNECTION "db-esri,port:5155,cadastre,user,pass"
DATA "CADASTRE.SDEADMIN.VW_FARM_BOUNDARY_SP,SHAPE"
DUMP TRUE
HEADER ../templates/apiaries_query_header.html
TEMPLATE ../templates/apiaries_query_body.html
LABELMAXSCALE 100000
LABELCACHE on
LABELITEM 'key_decision_maker'
MAXSCALE 250000
CLASS
NAME "fbnd"
DEBUG on
STYLE
WIDTH 3
#COLOR 135 206 235
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))]
OUTLINECOLOR 0 255 0
END
LABEL
TYPE truetype
FONT "arial"
SIZE 9
POSITION auto
OUTLINECOLOR 255 255 255 #--Halo
COLOR 76 179 145
MINDISTANCE 50
BUFFER 2
END #LABEL
END #CLASS
Many thanks,
Robert
>>> "Anzel, Phil - Fort Collins, CO" <[email protected]> 7/07/2011 2:11
>>> a.m. >>>
Hi, Robert,
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":
layer
name "mupolygon"
status on
connectiontype plugin
plugin "C:/ms4w/Apache/specialplugins/msplugin_mssql2008.dll"
processing "CLOSE_CONNECTION=DEFER"
connection "server=...;"
projection 'init=epsg:4269' END # NAD83
units DD
DATA "shapeGeometry from soilmu_a_wy721_nad83 using unique shapeID using
SRID=4269"
type polygon
opacity 40
class
name "mupoly"
style
COLOR [convert(varchar(3), (128 + shapeID) % 253) + ' ' +
convert(varchar(3), (200 + shapeID) % 254) + ' ' + convert(varchar(3), (64 +
shapeID) % 255)]
outlinecolor 0 0 0
outlinewidth 1
end
end # of class "mupoly"
end # of layer "mupolygon"
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.
I cannot speak to using data from other data sources. Best of luck with this.
- Phil Anzel
Web Soil Survey developer
Vistronix Inc for USDA/NRCS/ITC
-----Original Message-----
------------------------------
Message: 4
Date: Wed, 06 Jul 2011 09:08:28 +1200
From: "Robert Sanson" <[email protected]>
Subject: [mapserver-users] Random colours for polygon fill?
To: <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
Dear Mapserver users
Just wondering if it is possible to colour a polygon Shape file layer with each
distinct polygon having a different colour?
Many thanks,
Robert Sanson
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.
This message has been scanned for Malware and Viruses by Websense Hosted
Security.
www.websense.com
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users