- INIMAGE text now on transparent background
- BLANK error handling support added
This commit is contained in:
parent
f862ef425f
commit
bde3b7ae51
4 changed files with 28 additions and 9 deletions
|
@ -83,7 +83,7 @@ class BaseServiceHandler:
|
|||
finalparams = {}
|
||||
for paramname, paramdef in self.SERVICE_PARAMS[requestname].items():
|
||||
if paramname not in params.keys() and paramdef.mandatory:
|
||||
raise OGCException("Mandatory parameter '%s' missing from request." % paramname)
|
||||
raise OGCException('Mandatory parameter "%s" missing from request.' % paramname)
|
||||
elif paramname in params.keys():
|
||||
try:
|
||||
params[paramname] = paramdef.cast(params[paramname])
|
||||
|
@ -93,7 +93,7 @@ class BaseServiceHandler:
|
|||
raise OGCException('Invalid value "%s" for parameter "%s".' % (params[paramname], paramname))
|
||||
if paramdef.allowedvalues and params[paramname] not in paramdef.allowedvalues:
|
||||
if not paramdef.fallback:
|
||||
raise OGCException("Parameter '%s' has an illegal value." % paramname)
|
||||
raise OGCException('Parameter "%s" has an illegal value.' % paramname)
|
||||
else:
|
||||
finalparams[paramname] = paramdef.default
|
||||
else:
|
||||
|
@ -262,11 +262,26 @@ class BaseExceptionHandler:
|
|||
return Response(self.xmlmimetype, ElementTree.tostring(ogcexcetree))
|
||||
|
||||
def inimagehandler(self, code, message, params):
|
||||
im = new('L', (int(params['width']), int(params['height'])))
|
||||
im = new('RGBA', (int(params['width']), int(params['height'])))
|
||||
im.putalpha(new('1', (int(params['width']), int(params['height']))))
|
||||
draw = Draw(im)
|
||||
for count, line in enumerate(message.strip().split('\n')):
|
||||
draw.text((12,15*(count+1)), line, fill='#FFFFFF')
|
||||
draw.text((12,15*(count+1)), line, fill='#000000')
|
||||
fh = StringIO()
|
||||
im.save(fh, PIL_TYPE_MAPPING[params['format']])
|
||||
fh.seek(0)
|
||||
return Response(params['format'], fh.read())
|
||||
return Response(params['format'], fh.read())
|
||||
|
||||
def blankhandler(self, code, message, params):
|
||||
bgcolor = params.get('bgcolor', '#FFFFFF')
|
||||
bgcolor.replace('0x', '#')
|
||||
transparent = params.get('transparent', 'FALSE')
|
||||
if transparent == 'TRUE':
|
||||
im = new('RGBA', (int(params['width']), int(params['height'])))
|
||||
im.putalpha(new('1', (int(params['width']), int(params['height']))))
|
||||
else:
|
||||
im = new('RGBA', (int(params['width']), int(params['height'])), bgcolor)
|
||||
fh = StringIO()
|
||||
im.save(fh, PIL_TYPE_MAPPING[params['format']])
|
||||
fh.seek(0)
|
||||
return Response(params['format'], fh.read())
|
||||
|
|
|
@ -94,6 +94,7 @@ class ServiceHandler(WMSBaseServiceHandler):
|
|||
<Exception>
|
||||
<Format>application/vnd.ogc.se_xml</Format>
|
||||
<Format>application/vnd.ogc.se_inimage</Format>
|
||||
<Format>application/vnd.ogc.se_blank</Format>
|
||||
</Exception>
|
||||
<Layer>
|
||||
<Title>A Mapnik WMS Server</Title>
|
||||
|
@ -193,6 +194,7 @@ class ExceptionHandler(BaseExceptionHandler):
|
|||
xpath = 'ServiceException'
|
||||
|
||||
handlers = {'application/vnd.ogc.se_xml': BaseExceptionHandler.xmlhandler,
|
||||
'application/vnd.ogc.se_inimage': BaseExceptionHandler.inimagehandler}
|
||||
'application/vnd.ogc.se_inimage': BaseExceptionHandler.inimagehandler,
|
||||
'application/vnd.ogc.se_blank': BaseExceptionHandler.blankhandler}
|
||||
|
||||
defaulthandler = 'application/vnd.ogc.se_xml'
|
|
@ -100,6 +100,7 @@ class ServiceHandler(WMSBaseServiceHandler):
|
|||
<Exception>
|
||||
<Format>XML</Format>
|
||||
<Format>INIMAGE</Format>
|
||||
<Format>BLANK</Format>
|
||||
</Exception>
|
||||
<Layer>
|
||||
<Title>A Mapnik WMS Server</Title>
|
||||
|
@ -212,6 +213,7 @@ class ExceptionHandler(BaseExceptionHandler):
|
|||
xpath = '{http://www.opengis.net/ogc}ServiceException'
|
||||
|
||||
handlers = {'XML': BaseExceptionHandler.xmlhandler,
|
||||
'INIMAGE': BaseExceptionHandler.inimagehandler}
|
||||
'INIMAGE': BaseExceptionHandler.inimagehandler,
|
||||
'BLANK': BaseExceptionHandler.blankhandler}
|
||||
|
||||
defaulthandler = 'XML'
|
|
@ -18,9 +18,9 @@ Features/Caveats
|
|||
|
||||
- WMS 1.1.1 and 1.3.0
|
||||
- CGI/FastCGI
|
||||
- GetCapabilities and GetMap support only
|
||||
- GetCapabilities and GetMap support only (NO GetFeatureInfo)
|
||||
- GIF/JPEG/PNG output
|
||||
- XML error handling only
|
||||
- XML/INIMAGE/BLANK error handling
|
||||
- No real layer metadata support yet
|
||||
- No re-projection support
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue