[mapserver-users] RE: refactoring STYLEs ?

Clément MONIER Clement.MONIER at v-trafic.com
Fri Aug 20 08:28:09 PDT 2010


It works great !
Thanks a lot

De : Lime, Steve D (DNR) [mailto:Steve.Lime at state.mn.us]
Envoyé : vendredi 20 août 2010 17:25
À : Clément MONIER; 'mapserver-users at lists.osgeo.org'
Objet : RE: refactoring STYLEs ?

There's a draft RFC floating around to support this but it hasn't gotten much love... You can use INCLUDEs to do something similar:

Main mapfile:

LAYER
  NAME layer1
  CLASS
INCLUDE 'style1.map'
  END
END

LAYER
  NAME layer2
  CLASS
                INCLUDE 'style1.map'
  END
END

style1.map:

STYLE
  COLOR 0 0 0
  WIDTH 1
END

Ideally you'd be able to extend a base style which is what the RFC proposes. You can also do that with the INCLUDEs if you store just the style properties but not the block, eg.:

CLASS
  STYLE
    INCLUDE 'style1.map'
    COLOR 255 0 0 # override color
  END
END

and style1.map contains:

COLOR 0 0 0
WIDTH 1

Steve

From: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Clément MONIER
Sent: Friday, August 20, 2010 6:49 AM
To: 'mapserver-users at lists.osgeo.org'
Subject: [mapserver-users] refactoring STYLEs ?

Hi,

Is it possible to add a style definition (inside a mapfile or elsewhere ) so that it wouldn't be necessary to repeat it for each layer ?

For instance :

2 layers with the same display style

LAYER
  NAME layer1
  CLASS
STYLE
COLOR 0 0 0
WIDTH 1
END
  END
END

LAYER
  NAME layer2
  CLASS
STYLE
COLOR 0 0 0
WIDTH 1
END
  END
END

==>

STYLE 'style1'
STYLE
COLOR 0 0 0
WIDTH 1
END
END

LAYER
  NAME layer1
  CLASS
STYLE
'Style 1'
END
  END
END

LAYER
  NAME layer2
  CLASS
STYLE
'Style 1'
END
  END
END

Thanks & Regards

Clement

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20100820/3510e2f1/attachment.htm>


More information about the MapServer-users mailing list