Changeset 2310

Show
Ignore:
Timestamp:
08/05/03 14:36:13 (5 years ago)
Author:
sean
Message:

Declare mapObj clone(), prepareImage(), draw(), drawScalebar(), drawReferenceMap(), to return new objects using %newobject.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/branch-4-0/mapserver/mapscript/mapscript.i

    r2308 r2310  
    204204  } 
    205205 
     206  %newobject clone; 
    206207  mapObj *clone() { 
    207208    mapObj *dstMap; 
     
    270271  } 
    271272 
     273  %newobject prepareImage; 
    272274  imageObj *prepareImage() { 
    273275    int i, status; 
     
    360362                           MS_NOOVERRIDE, MS_NOOVERRIDE ); 
    361363  } 
    362  
     364   
     365  %newobject draw; 
    363366  imageObj *draw() { 
    364367    return msDrawMap(self); 
    365368  } 
    366369 
     370  %newobject drawQuery; 
    367371  imageObj *drawQuery() { 
    368372    return msDrawQueryMap(self); 
    369373  } 
    370374 
     375  %newobject drawLegend; 
    371376  imageObj *drawLegend() { 
    372377    return msDrawLegend(self); 
    373378  } 
    374379 
     380  %newobject drawScalebar; 
    375381  imageObj *drawScalebar() { 
    376382    return msDrawScalebar(self); 
    377383  } 
    378384 
     385  %newobject drawReferenceMap; 
    379386  imageObj *drawReferenceMap() { 
    380387    return msDrawReferenceMap(self); 
     
    625632  } 
    626633 
    627   /* raise and lower extensions have the same sense as the underlying 
    628    * ms* functions.  'Raise' means to raise the layer within the virtual 
     634  /* promote and demote have the opposite sense as the underlying 
     635   * ms* functions.  'Promote' means to raise the layer within the virtual 
    629636   * stack, and draw it later. 
    630637   */ 
     
    798805    return msDrawLegendIcon(map, layer, self, width, height, dstImage->img.gd, dstX, dstY); 
    799806  } 
    800    
     807  
     808  %newobject createLegendIcon; 
    801809  imageObj *createLegendIcon(mapObj *map, layerObj *layer, int width, int height) { 
    802810    return msCreateLegendIcon(map, layer, self, width, height); 
     
    10331041  }  
    10341042 
    1035   /* 
    1036   int contrain(rectObj *bounds, double overlay) { 
    1037     return msConstrainRect(bounds,self, overlay); 
    1038   } 
    1039   */ 
    1040  
    10411043  int draw(mapObj *map, layerObj *layer, imageObj *image, int classindex, char *text) { 
    10421044    shapeObj shape; 
  • branches/branch-4-0/mapserver/mapscript/python/setup_wnone.py

    r2266 r2310  
    101101                               libraries = libs, 
    102102                               define_macros =  macros, 
    103                                extra_link_args = ["-static", "-lgd"], 
    104103                              ) 
    105104                    ], 
  • branches/branch-4-0/mapserver/mapscript/python/tests/testMapScript.py

    r2303 r2310  
    143143                         self.mapobj1.queryByPoint, p, MS_SINGLE, 1.0) 
    144144 
     145class TestMapCloneTestCase(unittest.TestCase): 
     146    def setUp(self): 
     147        self.mapobj1 = mapObj(testMapfile) 
     148    def tearDown(self): 
     149        self.mapobj1 = None 
     150    def testCloneMap(self): 
     151        mapobj_clone = self.mapobj1.clone() 
     152        assert mapobj_clone.thisown == 1 
     153        assert mapobj_clone.name == self.mapobj1.name 
     154        assert mapobj_clone.numlayers == self.mapobj1.numlayers 
     155        del mapobj_clone 
     156 
    145157# If PIL is available, use it to test the saveToString() method 
    146158 
    147 #have_image = 0 
    148 #try: 
    149 #    import Image 
    150 #    have_image = 1 
    151 #except ImportError: 
    152 #    pass 
    153 #     
    154 #from StringIO import StringIO 
    155 
    156 #class SaveToStringTestCase(unittest.TestCase): 
    157 #    def setUp(self): 
    158 #        self.mapobj1 = mapObj(testMapfile) 
    159 #    def tearDown(self): 
    160 #        self.mapobj1 = None 
    161 #    def testSaveToString(self): 
    162 #        msimg = self.mapobj1.draw() 
    163 #        data = StringIO(msimg.saveToString()) 
    164 #        if have_image: 
    165 #            pyimg = Image.open(data) 
    166 #            assert pyimg.format == 'PNG' 
    167 #            assert pyimg.size == (600, 600) 
    168 #            assert pyimg.mode == 'P' 
    169 #        else: 
    170 #            assert 1 
     159have_image = 0 
     160try: 
     161    from PIL import Image 
     162    have_image = 1 
     163except ImportError: 
     164    pass 
     165     
     166from StringIO import StringIO 
     167 
     168class SaveToStringTestCase(unittest.TestCase): 
     169    def setUp(self): 
     170        self.mapobj1 = mapObj(testMapfile) 
     171    def tearDown(self): 
     172        self.mapobj1 = None 
     173    def testSaveToString(self): 
     174        msimg = self.mapobj1.draw() 
     175        assert msimg.thisown == 1 
     176        data = msimg.saveToString() 
     177        filename = 'testSaveToString.png' 
     178        fh = open(filename, 'wb') 
     179        fh.write(data) 
     180        fh.close() 
     181        if have_image: 
     182            pyimg = Image.open(filename) 
     183            assert pyimg.format == 'PNG' 
     184            assert pyimg.size == (600, 600) 
     185            assert pyimg.mode == 'P' 
     186        else: 
     187            assert 1 
    171188 
    172189class NoFontSetTestCase(unittest.TestCase):