MapServer / MapServer-import

3 stars 2 forks source link

expose hash tables like metadata and fonts to mapscript #439

Closed tbonfort closed 12 years ago

tbonfort commented 12 years ago

Reporter: sgillies@frii.com Date: 2003/09/26 - 17:06

We need to overcome the issues between MapServer and SWIG that currently prevent
us from exposing hash tables like metadata and fonts to mapscript.  Then
implement methods that will let us access the hash table objects as though
they were dictionaries or associative arrays, and a keys() method to get a
list or array of all hash keys.

This means in Perl that you could do:

   $metadata = $layerobj->{metadata};
   $layerobj->{metadata}->{'WMS_TITLE'} = 'Foo';

   for $key in $metadata->keys() {
       print $key, $metadata->{$key};
   }

Or in Python:

   layerobj.metadata['WMS_TITLE'] = 'Foo'

   for key in layerobj.metadata.keys():
       print key, layerobj.metadata[key]
tbonfort commented 12 years ago

Author: sgillies@frii.com Date: 2004/03/15 - 18:28

The metadata issue is resolved in bug 434.

For fonts, I am following suit.  There's no real need to use the font filenames
attached to names, but nice to be able to know what fonts are in a map.

Have extended fontSetObj with getFirstFont and getNextFont methods.  Below is
a test case that shows the usage.

# fontset tests
class FontSetTestCase(MapTestCase):
    def testGetFontSetFile(self):
        file = self.mapobj1.fontset.filename
        assert file == 'fonts.txt', file
    def testFontSetFonts(self):
        fonts = []
        font = None
        while 1:
            font = self.mapobj1.fontset.getNextFont(font)
            if not font:
                break
            fonts.append(font)
        assert fonts == ['LucidaSansRegular', 'LucidaSansDemiBold'], fonts