MapServer / MapServer-import

3 stars 2 forks source link

new functions numMetaData and keyMetaData to retrieve number and keys of metadata entries #434

Closed tbonfort closed 12 years ago

tbonfort commented 12 years ago

Reporter: m.spring@gmx.de Date: 2003/09/22 - 10:29

Mapscript currently has no methods to retrieve existing metadata without knowing
its keys.

The new method 'numMetaData' gets the number of metadata entries (like
map->numlayers), and 'keyMetaData(pos)' gets the key of the metadata entry on
position 'pos'.

To achieve this functionality patching of maphash.c, maphash.h and mapscript.i
is necessary.
The patches are context-diffed against the mapserver cvs-version of sunday,
sept. 21, 2003 and can be downloaded from

http://dream.lrrl.arch.tu-muenchen.de/~springm/mapserver/maphash_patches/maphash.c.patch
http://dream.lrrl.arch.tu-muenchen.de/~springm/mapserver/maphash_patches/maphash.h.patch
http://dream.lrrl.arch.tu-muenchen.de/~springm/mapserver/maphash_patches/mapscript.i.patch

I hope this patch can be included in the current and future versions of mapserver.
tbonfort commented 12 years ago

Author: sgillies@frii.com Date: 2003/09/22 - 16:05

Sean Gillies added
tbonfort commented 12 years ago

Author: sgillies@frii.com Date: 2004/03/15 - 17:54

Been a long time, but have finally resolved this bug.

We are not going to use the provided patch, but using new 
msFirstKeyFromHashTable and msNextKeyFromHashTable functions written
by Frank Warmerdam.

These give us an opaque iterator over metadata keys that we can use
like this:

    keys = []
    key = mapobj.getFirstMetaDataKey()
    if key is not None: 
        keys.append(key)
        while 1:
            key = mapobj.getNextMetaDataKey(key)
            if not key:
                break
            keys.append(key)

and keys contains all the metadata keys.  One could create a dictionary
from the metadata in a similar fashion.