Skip to content

Commit

Permalink
Fix broken symbol tests, remove GD as default renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
geographika committed Oct 10, 2018
1 parent ce97bc8 commit f3edb87
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
15 changes: 8 additions & 7 deletions mapscript/python/tests/cases/symbol_test.py
Expand Up @@ -38,17 +38,16 @@ def testConstructor(self):
assert symbol.name == 'test' assert symbol.name == 'test'
assert symbol.thisown == 1 assert symbol.thisown == 1


def xtestConstructorImage(self): def testConstructorImage(self):
"""create new instance of symbolObj from an image""" """create new instance of symbolObj from an image"""
symbol = mapscript.symbolObj('xmarks', XMARKS_IMAGE) symbol = mapscript.symbolObj('xmarks', XMARKS_IMAGE)
assert symbol.name == 'xmarks' assert symbol.name == 'xmarks'
assert symbol.type == mapscript.MS_SYMBOL_VECTOR # was MS_SYMBOL_PIXMAP! assert symbol.type == mapscript.MS_SYMBOL_VECTOR # was MS_SYMBOL_PIXMAP!
format = mapscript.outputFormatObj('AGG/PNG') format = mapscript.outputFormatObj('AGG/PNG')
img = symbol.getImage(format) img = symbol.getImage(format)
img.save('sym-%s.%s' % (symbol.name, img.format.extension)) img.save('sym-%s.%s' % (symbol.name, img.format.extension))




# TODO creating mapscript.imageObj objects throw errors
class DynamicGraphicSymbolTestCase(): class DynamicGraphicSymbolTestCase():


def setUp(self): def setUp(self):
Expand Down Expand Up @@ -110,7 +109,7 @@ def testDrawSetRGBAImage(self):


class MapSymbolTestCase(MapTestCase): class MapSymbolTestCase(MapTestCase):


def xtestGetPoints(self): def testGetPoints(self):
"""get symbol points as line and test coords""" """get symbol points as line and test coords"""
symbol = self.map.symbolset.getSymbol(1) symbol = self.map.symbolset.getSymbol(1)
assert symbol.name == 'circle' assert symbol.name == 'circle'
Expand All @@ -133,11 +132,13 @@ def testSetPoints(self):
pt = self.getPointFromLine(line, 1) pt = self.getPointFromLine(line, 1)
self.assertPointsEqual(pt, mapscript.pointObj(3.0, 3.0)) self.assertPointsEqual(pt, mapscript.pointObj(3.0, 3.0))


def xtestSetStyle(self): def testSetStyle(self):
"""expect success after setting an existing symbol's style""" """expect success after setting an existing symbol's style"""
symbol = self.map.symbolset.getSymbol(1) symbol = self.map.symbolset.getSymbol(1)
# TODO setPattern is no longer a method # default MapScript API setPattern has been extended to allow lists
assert symbol.setPattern(0, 1) == mapscript.MS_SUCCESS # assert symbol.setPattern(0, 1) == mapscript.MS_SUCCESS
symbol.pattern = [0, 1]
assert symbol.pattern == [0, 1]


def testRGBASymbolInPNG24(self): def testRGBASymbolInPNG24(self):
"""draw a RGBA PNG pixmap on PNG canvas""" """draw a RGBA PNG pixmap on PNG canvas"""
Expand Down
32 changes: 10 additions & 22 deletions mapscript/swiginc/symbol.i
Expand Up @@ -53,26 +53,26 @@


~symbolObj() ~symbolObj()
{ {
if (self) { if (self) {
if (msFreeSymbol(self)==MS_SUCCESS) { if (msFreeSymbol(self)==MS_SUCCESS) {
free(self); free(self);
self=NULL; self=NULL;
} }
} }
} }


int setImagepath(const char *imagefile) { int setImagepath(const char *imagefile) {
return msLoadImageSymbol(self, imagefile); return msLoadImageSymbol(self, imagefile);
} }


int setPoints(lineObj *line) { int setPoints(lineObj *line) {
int i; int i;
self->sizex = 0; self->sizex = 0;
self->sizey = 0; self->sizey = 0;
for (i=0; i<line->numpoints; i++) { for (i=0; i<line->numpoints; i++) {
MS_COPYPOINT(&(self->points[i]), &(line->point[i])); MS_COPYPOINT(&(self->points[i]), &(line->point[i]));
self->sizex = MS_MAX(self->sizex, self->points[i].x); self->sizex = MS_MAX(self->sizex, self->points[i].x);
self->sizey = MS_MAX(self->sizey, self->points[i].y); self->sizey = MS_MAX(self->sizey, self->points[i].y);
} }
self->numpoints = line->numpoints; self->numpoints = line->numpoints;
return self->numpoints; return self->numpoints;
Expand Down Expand Up @@ -101,23 +101,13 @@
outputFormatObj *format = NULL; outputFormatObj *format = NULL;
rendererVTableObj *renderer = NULL; rendererVTableObj *renderer = NULL;


if (self->type != MS_SYMBOL_PIXMAP)
{
msSetError(MS_SYMERR, "Can't return image from non-pixmap symbol",
"getImage()");
return NULL;
}

if (input_format) if (input_format)
{ {
format = input_format; format = input_format;
} }
else else
{ {
format = msCreateDefaultOutputFormat(NULL, "GD/GIF", "gdgif"); format = msCreateDefaultOutputFormat(NULL, "AGG/PNG", "aggpng");
if (format == NULL)
format = msCreateDefaultOutputFormat(NULL, "GD/PNG", "gdpng");

if (format) if (format)
msInitializeRendererVTable(format); msInitializeRendererVTable(format);
} }
Expand Down Expand Up @@ -173,5 +163,3 @@
} }


} }


0 comments on commit f3edb87

Please sign in to comment.