[mapserver-users] dynamic layer classification

Rahkonen Jukka Jukka.Rahkonen at mmmtike.fi
Fri Aug 26 17:38:03 EDT 2011


Hi,

There is naturally also the SLD_BODY way. Looks ugly but works.

http://188.64.1.61/cgi-bin/mapserv?map=/usr/map/osm-mapserver_i.map&REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&WIDTH=469&HEIGHT=354&LAYERS=roadsfar_01&TRANSPARENT=TRUE&FORMAT=image/png&BBOX=252097.87225892936,6798498.983050847,526331.9582495452,7005490.169491526&SRS=EPSG:3067&STYLES=&SLD_BODY=%3CStyledLayerDescriptor%20version%3D%221.0.0%22%20xmlns%3D%22http%3A%2F%2Fwww.opengis.net%2Fsld%22%20xmlns%3Agml%3D%22http%3A%2F%2Fwww.opengis.net%2Fgml%22%20xmlns%3Aogc%3D%22http%3A%2F%2Fwww.opengis.net%2Fogc%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xsi%3AschemaLocation%3D%22http%3A%2F%2Fwww.opengis.net%2Fsld%20http%3A%2F%2Fschemas.opengis.net%2Fsld%2F1.0.0%2FStyledLayerDescriptor.xsd%22%3E%20%3CNamedLayer%3E%20%3CName%3Eroadsfar_01%3C%2FName%3E%20%3CUserStyle%3E%20%3CFeatureTypeStyle%3E%20%3CRule%3E%20%3Cogc%3AFilter%3E%3Cogc%3APropertyIsEqualTo%3E%3Cogc%3APropertyName%3Ehighway%3C%2Fogc%3APropertyName%3E%3Cogc%3ALiteral%3Etrunk%3C%2Fogc%3ALiteral%3E%3C%2Fogc%3APropertyIsEqualTo%3E%3C%2Fogc%3AFilter%3E%20%3CMinScaleDenominator%3E1000010.000000%3C%2FMinScaleDenominator%3E%20%3CMaxScaleDenominator%3E2500010.000000%3C%2FMaxScaleDenominator%3E%20%3CLineSymbolizer%3E%20%3CStroke%3E%20%3CCssParameter%20name%3D%22stroke%22%3E%2300ff00%3C%2FCssParameter%3E%20%3CCssParameter%20name%3D%22stroke-opacity%22%3E1.00%3C%2FCssParameter%3E%20%3CCssParameter%20name%3D%22stroke-width%22%3E3.00%3C%2FCssParameter%3E%20%3C%2FStroke%3E%20%3C%2FLineSymbolizer%3E%20%3CTextSymbolizer%3E%20%3CLabel%3Eref%3C%2FLabel%3E%20%3CFont%3E%20%3CCssParameter%20name%3D%22font-family%22%3Escb%3C%2FCssParameter%3E%20%3CCssParameter%20name%3D%22font-size%22%3E16.00%3C%2FCssParameter%3E%20%3C%2FFont%3E%20%3CLabelPlacement%3E%20%3CPointPlacement%3E%20%3CAnchorPoint%3E%20%3CAnchorPointX%3E0.5%3C%2FAnchorPointX%3E%20%3CAnchorPointY%3E0.5%3C%2FAnchorPointY%3E%20%3C%2FAnchorPoint%3E%20%3C%2FPointPlacement%3E%20%3C%2FLabelPlacement%3E%20%3CFill%3E%20%3CCssParameter%20name%3D%22fill%22%3E%23000000%3C%2FCssParameter%3E%20%3C%2FFill%3E%20%3C%2FTextSymbolizer%3E%20%3C%2FRule%3E%20%3CRule%3E%20%3Cogc%3AFilter%3E%3Cogc%3APropertyIsEqualTo%3E%3Cogc%3APropertyName%3Ehighway%3C%2Fogc%3APropertyName%3E%3Cogc%3ALiteral%3Eprimary%3C%2Fogc%3ALiteral%3E%3C%2Fogc%3APropertyIsEqualTo%3E%3C%2Fogc%3AFilter%3E%20%3CMinScaleDenominator%3E1000010.000000%3C%2FMinScaleDenominator%3E%20%3CMaxScaleDenominator%3E2500010.000000%3C%2FMaxScaleDenominator%3E%20%3CLineSymbolizer%3E%20%3CStroke%3E%20%3CCssParameter%20name%3D%22stroke%22%3E%23ff0000%3C%2FCssParameter%3E%20%3CCssParameter%20name%3D%22stroke-opacity%22%3E1.00%3C%2FCssParameter%3E%20%3CCssParameter%20name%3D%22stroke-width%22%3E3.00%3C%2FCssParameter%3E%20%3C%2FStroke%3E%20%3C%2FLineSymbolizer%3E%20%3CTextSymbolizer%3E%20%3CLabel%3Eref%3C%2FLabel%3E%20%3CFont%3E%20%3CCssParameter%20name%3D%22font-family%22%3Escb%3C%2FCssParameter%3E%20%3CCssParameter%20name%3D%22font-size%22%3E16.00%3C%2FCssParameter%3E%20%3C%2FFont%3E%20%3CLabelPlacement%3E%20%3CPointPlacement%3E%20%3CAnchorPoint%3E%20%3CAnchorPointX%3E0.5%3C%2FAnchorPointX%3E%20%3CAnchorPointY%3E0.5%3C%2FAnchorPointY%3E%20%3C%2FAnchorPoint%3E%20%3C%2FPointPlacement%3E%20%3C%2FLabelPlacement%3E%20%3CFill%3E%20%3CCssParameter%20name%3D%22fill%22%3E%230000ff%3C%2FCssParameter%3E%20%3C%2FFill%3E%20%3C%2FTextSymbolizer%3E%20%3C%2FRule%3E%20%3C%2FFeatureTypeStyle%3E%20%3C%2FUserStyle%3E%20%3C%2FNamedLayer%3E%20%3C%2FStyledLayerDescriptor%3E

SLD_BODY written out

<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
<NamedLayer>
<Name>roadsfar_01</Name>
<UserStyle>
<FeatureTypeStyle>
<Rule>
<ogc:Filter><ogc:PropertyIsEqualTo><ogc:PropertyName>highway</ogc:PropertyName><ogc:Literal>trunk</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>
<MinScaleDenominator>1000010.000000</MinScaleDenominator>
<MaxScaleDenominator>2500010.000000</MaxScaleDenominator>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">#00ff00</CssParameter>
<CssParameter name="stroke-opacity">1.00</CssParameter>
<CssParameter name="stroke-width">3.00</CssParameter>
</Stroke>
</LineSymbolizer>
<TextSymbolizer>
<Label>ref</Label>
<Font>
<CssParameter name="font-family">scb</CssParameter>
<CssParameter name="font-size">16.00</CssParameter>
</Font>
<LabelPlacement>
<PointPlacement>
<AnchorPoint>
<AnchorPointX>0.5</AnchorPointX>
<AnchorPointY>0.5</AnchorPointY>
</AnchorPoint>
</PointPlacement>
</LabelPlacement>
<Fill>
<CssParameter name="fill">#000000</CssParameter>
</Fill>
</TextSymbolizer>
</Rule>
<Rule>
<ogc:Filter><ogc:PropertyIsEqualTo><ogc:PropertyName>highway</ogc:PropertyName><ogc:Literal>primary</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>
<MinScaleDenominator>1000010.000000</MinScaleDenominator>
<MaxScaleDenominator>2500010.000000</MaxScaleDenominator>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">#ff0000</CssParameter>
<CssParameter name="stroke-opacity">1.00</CssParameter>
<CssParameter name="stroke-width">3.00</CssParameter>
</Stroke>
</LineSymbolizer>
<TextSymbolizer>
<Label>ref</Label>
<Font>
<CssParameter name="font-family">scb</CssParameter>
<CssParameter name="font-size">16.00</CssParameter>
</Font>
<LabelPlacement>
<PointPlacement>
<AnchorPoint>
<AnchorPointX>0.5</AnchorPointX>
<AnchorPointY>0.5</AnchorPointY>
</AnchorPoint>
</PointPlacement>
</LabelPlacement>
<Fill>
<CssParameter name="fill">#0000ff</CssParameter>
</Fill>
</TextSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>

-Jukka Rahkonen-
________________________________________
Lähettäjä: mapserver-users-bounces at lists.osgeo.org [mapserver-users-bounces at lists.osgeo.org] k&#228;ytt&#228;j&#228;n Mr. Puneet Kishor [punk.kish at gmail.com] puolesta
Lähetetty: 26. elokuuta 2011 20:50
Vastaanottaja: Brent Fraser
Kopio: MapServer
Aihe: Re: [mapserver-users] dynamic layer classification

On Aug 26, 2011, at 12:39 PM, Brent Fraser wrote:

> Puneet,
>
>  I think currently the short answer is Mapscript.
>
>  I had a similar need last year (http://lists.osgeo.org/pipermail/mapserver-users/2010-March/065050.html) where I needed to have the symbology stored in the database and the classes varied over  time (users created new class defs in the database via a web page).
>
>  Steve Lime suggested an enahancement where classes were defined by a SLD file or url:
>
> LAYER
>  NAME 'extreme-symbology'
>  DATA ...
>  CONNECTION ...
>  SLD 'some flle' or 'some url'
>  ...
> END
>
> which is an elegant solution, but currently not implemented...


Yes, that would be a very nice solution, precisely the kind of thing I am looking for. In fact, even better would be

LAYER
 ..
 SLD 'some expression'

where 'some expression' could be stored in a file, or retrieve via a URL, or from a db query.

But, until that comes along, I could and will use MapScript. I compiled MS 6.0.1 yesterday, and discovered, much to my delight, that MapScript in my favorite programming language (the one that begins with P) is alive and doing well.

So, how would I go about implementing this in MapScript? I would have to create the layer definition on the fly, no? Any pointers?



>
> Best Regards,
> Brent Fraser
>
>
> On 8/26/2011 8:35 AM, Mr. Puneet Kishor wrote:
>> hola,
>>
>> I need some guidance on this (and my MapServer foo is severely rusted). My immediate need is to color a polygon layer (held in PostGIS) based on an attribute in a separate table. The number of CLASSes is considerable, more than 80 or so. This leads to a longer term need --
>>
>> The coloring of these polys is a crucial and universal need in my field of work, and it horrendously complicated determining the correct color, and the calculations for the appropriate color keep on changing from time to time. In other words, many different applications need this ability to classify polys based on certain attributes. So, I am creating a web app that does nothing but tell what color to use -- you give it a set of attributes, and the web app replies with the color. It would be a RESTful app, sending the color information back as JSON. How could I use this information with MapServer?
>>
>> In an ideal scenario, MapServer would query the data source, then, for each class in the layer, it would send a query to this color app, and the color app would tell MapServer what color to use to render the poly. The same app would be used by other apps, be they MapServer, OL, Polymaps, or even non-mapping apps such as R, etc.
>>
>> Suggestions on how to proceed?
>>
>> --
>> Puneet Kishor
>> _______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
>

_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users


More information about the mapserver-users mailing list