Ticket #99 (new enhancement)

Opened 7 weeks ago

Last modified 25 hours ago

Ability to load mapnik xml from string

Reported by: springmeyer Owned by: artem
Milestone: 1.0.0 Component: Boost.Python Binding
Version: SVN Trunk Severity: Enhancement
Keywords: xml from string, mapfile Cc: dane.springmeyer@…

Description

It could be useful to be able to store a mapnik xml mapfile within a python script and (after potentially manipulating the xml in memory) then load the configuration.

There could be a mapnik.map_from_string() function or mapnik.load_map() could accept xml string so that you could say:

mapfile = '''<Map bgcolor="steelblue" srs="+proj=latlong +datum=WGS84">
  <Style name="My Style">
    <Rule>
      <PolygonSymbolizer>
        <CssParameter name="fill">#f2eff9</CssParameter>
      </PolygonSymbolizer>
      <LineSymbolizer>
        <CssParameter name="stroke">rgb(50%,50%,50%)</CssParameter>
        <CssParameter name="stroke-width">0.1</CssParameter>
      </LineSymbolizer>
    </Rule>
  </Style>
  <Layer name="world">
    <StyleName>My Style</StyleName>
    <Datasource>
      <Parameter name="type">shape</Parameter>
      <Parameter name="file">../data/world_borders</Parameter>
    </Datasource>
  </Layer>
</Map>'''

from mapnik import *
m = Map(600, 300)
load_map(m, mapfile)
[...]

Change History

Changed 7 weeks ago by springmeyer

  • type changed from defect to enhancement
  • severity changed from Normal to Enhancement

Changed 25 hours ago by lwu

While XML is great, I'd love a DSL in the spirit of what the Ruby community tends to do.

This feature might not be too hard to do, but I haven't looked at the issue deeply.

Note: See TracTickets for help on using tickets.