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
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,16 @@ def testConstructor(self):
assert symbol.name == 'test'
assert symbol.thisown == 1

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



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

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

class MapSymbolTestCase(MapTestCase):

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

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

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

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

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

int setPoints(lineObj *line) {
int i;
self->sizex = 0;
self->sizey = 0;
self->sizex = 0;
self->sizey = 0;
for (i=0; i<line->numpoints; i++) {
MS_COPYPOINT(&(self->points[i]), &(line->point[i]));
self->sizex = MS_MAX(self->sizex, self->points[i].x);
self->sizey = MS_MAX(self->sizey, self->points[i].y);
self->sizex = MS_MAX(self->sizex, self->points[i].x);
self->sizey = MS_MAX(self->sizey, self->points[i].y);
}
self->numpoints = line->numpoints;
return self->numpoints;
Expand Down Expand Up @@ -101,23 +101,13 @@
outputFormatObj *format = 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)
{
format = input_format;
}
else
{
format = msCreateDefaultOutputFormat(NULL, "GD/GIF", "gdgif");
if (format == NULL)
format = msCreateDefaultOutputFormat(NULL, "GD/PNG", "gdpng");

format = msCreateDefaultOutputFormat(NULL, "AGG/PNG", "aggpng");
if (format)
msInitializeRendererVTable(format);
}
Expand Down Expand Up @@ -173,5 +163,3 @@
}

}


0 comments on commit f3edb87

Please sign in to comment.