Ticket #357 (closed enhancement: wontfix)
RFE: refactor mapserver to load/save map file fragments from/to strings
| Reported by: | sgillies@… | Owned by: | sdlime |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | MapServer C Library | Version: | 4.1 |
| Severity: | minor | Keywords: | |
| Cc: | dgraham@… |
Description
I'd like to propose a change to the manner in which mapfiles
are read and written for 4.1. My proposed changes would enable
us to write and save map file fragments. These enhancements
are primarily aimed at improving MapServer's ability to
serialize/marshal mapping objects.
To start, I'd like to see msLoadMap() refactored so that all
the work is performed by a msLoadMapString() function. Then
we could reduce msLoadMap() to something like the following
pseudocode:
def msLoadMap(filename)
fh = open(filename, 'r')
map_string = fh.read()
return msLoadMapString(map_string)
I'd also like to see this extended to layers, classes, etc.
msLoadMapString would call msLoadLayerString,
msLoadClassString, etc where necessary. These functions also
would be really handy to take an existing map and then
add a layer defined in a string like in this mapscript
layer_string = 'NAME "foo"\nTYPE POLYGON\n' # for example
layerobj = layerObj(mapobj, layer_string)
An msLoadLayerString() function would be used in this new layerObj
constructor.
As well, I'd like to see *writeString() functions for map, layer,
classes, and have msSaveMap() rewritten to call these.
Steve Lime points out that these enhancement would also be useful
for the CGI mapserv:
In addition, this could be considered as a general
replacement for the map_ syntax already supported by the CGI
application. It works well if you only need to make a change or
two but is to clunky for much broader use. Moving to a single
parser that would work for a complete mapfile or just a piece
would really simplify maintenence.
Daniel Morissette adds:
While we're at it, we should create an abstraction layer so that
we can have multiple implementations of the Load...String() and
Write...String() functions. This way if someone wants to implement
a XML mapfile format (did I really write XML? ;) or use whatever
database mechanism to store map compositions then they could do it.
This is a good idea, but I wouldn't want the issues of an XML map file
to distract from this particular feature enhancement.
While we are refactoring, perhaps we could move code into mapobject.c,
layerobject.c, etc and delete mapfile.c?
Change History
Note: See
TracTickets for help on using
tickets.
