- Add some more error checking

- Simplify configuration
This commit is contained in:
Jean-Francois Doyon 2006-04-11 00:36:08 +00:00
parent 378d4a4e1d
commit d4b5171efb
2 changed files with 9 additions and 2 deletions

View file

@ -36,8 +36,8 @@ class Handler(cgi.DebugHandler):
conf = SafeConfigParser()
conf.readfp(open(self.configpath))
self.conf = conf
mapfactorymodule = __import__(conf.get('server', 'mapfactorymodule'))
self.mapfactory = getattr(mapfactorymodule, conf.get('server', 'mapfactoryclass'))()
mapfactorymodule = __import__(conf.get('server', 'module'))
self.mapfactory = getattr(mapfactorymodule, 'MapFactory')()
self.requesthandlers = {}
def process(self, req):

View file

@ -197,6 +197,10 @@ class WMSBaseServiceHandler(BaseServiceHandler):
def getmap(self, params):
if str(params['crs']) != str(self.crs):
raise OGCException('Unsupported CRS requested. Must be "%s" and not "%s".' % (self.crs, params['crs']), 'InvalidCRS')
if params['bbox'][0] >= params['bbox'][2]:
raise OGCException("BBOX values don't make sense. minx is greater than maxx.")
if params['bbox'][1] >= params['bbox'][3]:
raise OGCException("BBOX values don't make sense. miny is greater than maxy.")
m = Map(params['width'], params['height'])
if params.has_key('transparent') and params['transparent'] == 'FALSE':
m.background = params['bgcolor']
@ -209,6 +213,9 @@ class WMSBaseServiceHandler(BaseServiceHandler):
if stylename in mapstyles.keys():
m.append_style(stylename, mapstyles[stylename])
m.layers.append(layer)
if len(m.layers) != len(params['layers']):
badnames = [ layername for layername in params['layers'] if layername not in [ layer.name() for layer in m.layers ] ]
raise OGCException('The following layers are not defined by this server: %s.' % ','.join(badnames), 'LayerNotDefined')
m.zoom_to_box(Envelope(params['bbox'][0], params['bbox'][1], params['bbox'][2], params['bbox'][3]))
im = Image(params['width'], params['height'])
render(m, im)