Esempio n. 1
0
 def __init__(self, configpath, mapfile=None,fonts=None,home_html=None):
     conf = SafeConfigParser()
     conf.readfp(open(configpath))
     # TODO - be able to supply in config as well
     self.home_html = home_html
     self.conf = conf
     if fonts:
         mapnik.register_fonts(fonts)
     if mapfile:
         wms_factory = BaseWMSFactory(configpath)
         # TODO - add support for Cascadenik MML
         wms_factory.loadXML(mapfile)
         wms_factory.finalize()
         self.mapfactory = wms_factory
     else:
         if not conf.has_option_with_value('server', 'module'):
             raise ServerConfigurationError('The factory module is not defined in the configuration file.')
         try:
             mapfactorymodule = do_import(conf.get('server', 'module'))
         except ImportError:
             raise ServerConfigurationError('The factory module could not be loaded.')
         if hasattr(mapfactorymodule, 'WMSFactory'):
             self.mapfactory = getattr(mapfactorymodule, 'WMSFactory')()
         else:
             raise ServerConfigurationError('The factory module does not have a WMSFactory class.')
     if conf.has_option('server', 'debug'):
         self.debug = int(conf.get('server', 'debug'))
     else:
         self.debug = 0
     if self.conf.has_option_with_value('server', 'maxage'):
         self.max_age = 'max-age=%d' % self.conf.get('server', 'maxage')
     else:
         self.max_age = None
Esempio n. 2
0
 def __init__(self, configpath):
     conf = SafeConfigParser()
     conf.readfp(open(configpath))
     self.conf = conf
     if not conf.has_option_with_value('server', 'module'):
         raise ServerConfigurationError(
             'The factory module is not defined in the configuration file.')
     try:
         mapfactorymodule = __import__(conf.get('server', 'module'))
     except ImportError:
         raise ServerConfigurationError(
             'The factory module could not be loaded.')
     if hasattr(mapfactorymodule, 'WMSFactory'):
         self.mapfactory = getattr(mapfactorymodule, 'WMSFactory')()
     else:
         raise ServerConfigurationError(
             'The factory module does not have a WMSFactory class.')
     if conf.has_option('server', 'debug'):
         self.debug = int(conf.get('server', 'debug'))
     else:
         self.debug = 0
     if self.conf.has_option_with_value('server', 'maxage'):
         self.max_age = 'max-age=%d' % self.conf.get('server', 'maxage')
     else:
         self.max_age = None
Esempio n. 3
0
 def __init__(self, url, logging, config=''):
     
     self.url = url 
     self.home_html = None
     self.logging = logging
     self.proto_schema = {
         "xml": {
             "test": self.is_xml,
             "get": self.get_mapnik,
             "request": self.request_mapnik,
             "metadata": self.get_metadata,
             "enable": True,
             },
     }
     # Load OGCServver config
     self.ogcserver = importlib.import_module('ogcserver')
     if os.path.isfile(config):
         self.ogc_configfile = config
     else:
         self.ogc_configfile = resource_filename(
             self.ogcserver.__name__, 'default.conf'
         )
     ogcconf = SafeConfigParser()
     ogcconf.readfp(open(self.ogc_configfile))
     self.ogcconf = ogcconf
     if ogcconf.has_option('server', 'debug'):
         self.debug = int(ogcconf.get('server', 'debug'))
     else:
         self.debug = 0
     self.mapnik_ver = mapnik_version()
Esempio n. 4
0
 def __init__(self, configpath, mapfile=None, fonts=None, home_html=None):
     # 实例化 ConfigParser 并加载配置文件
     conf = SafeConfigParser()
     # 从配置文件读取并分析(分列)配置信息
     conf.readfp(open(configpath))
     # TODO - be able to supply in config as well
     self.home_html = home_html
     self.conf = conf
     if fonts:
         # 注册指定字体
         mapnik.register_fonts(fonts)
     if mapfile:
         # 生成BaseWMSFactory实例
         wms_factory = BaseWMSFactory(configpath)
         # TODO - add support for Cascadenik MML
         wms_factory.loadXML(mapfile)
         wms_factory.finalize()
         self.mapfactory = wms_factory
     else:
         # 阅读default.conf,有疑惑???
         #
         # 原default.conf文件中module未定义,需要使用要在default.conf中自行定义
         if not conf.has_option_with_value('server', 'module'):
             raise ServerConfigurationError(
                 'The factory module is not defined in the configuration file.'
             )
         # 导入指定module
         try:
             # get(section,option),Get an option value for the named
             # section.
             mapfactorymodule = do_import(conf.get('server', 'module'))
         except ImportError:
             raise ServerConfigurationError(
                 'The factory module could not be loaded.')
         if hasattr(mapfactorymodule, 'WMSFactory'):
             # Get a named attribute from an object; getattr(x, 'y') is
             # equivalent to x.y.
             self.mapfactory = getattr(mapfactorymodule, 'WMSFactory')()
         else:
             raise ServerConfigurationError(
                 'The factory module does not have a WMSFactory class.')
     if conf.has_option('server', 'debug'):
         self.debug = int(conf.get('server', 'debug'))
     else:
         self.debug = 0
     if self.conf.has_option_with_value('server', 'maxage'):
         self.max_age = 'max-age=%d' % self.conf.get('server', 'maxage')
     else:
         self.max_age = None
Esempio n. 5
0
 def __init__(self, home_html=None):
     conf = SafeConfigParser()
     conf.readfp(open(self.configpath))
     # TODO - be able to supply in config as well
     self.home_html = home_html
     self.conf = conf
     if not conf.has_option_with_value('server', 'module'):
         raise ServerConfigurationError('The factory module is not defined in the configuration file.')
     try:
         mapfactorymodule = __import__(conf.get('server', 'module'))
     except ImportError:
         raise ServerConfigurationError('The factory module could not be loaded.')
     if hasattr(mapfactorymodule, 'WMSFactory'):
         self.mapfactory = getattr(mapfactorymodule, 'WMSFactory')()
     else:
         raise ServerConfigurationError('The factory module does not have a WMSFactory class.')
     if conf.has_option('server', 'debug'):
         self.debug = int(conf.get('server', 'debug'))
     else:
         self.debug = 0
Esempio n. 6
0
 def __init__(self, configpath):
     conf = SafeConfigParser()
     conf.readfp(open(configpath))
     self.conf = conf
     if not conf.has_option_with_value('server', 'module'):
         raise ServerConfigurationError('The factory module is not defined in the configuration file.')
     try:
         mapfactorymodule = __import__(conf.get('server', 'module'))
     except ImportError:
         raise ServerConfigurationError('The factory module could not be loaded.')
     if hasattr(mapfactorymodule, 'WMSFactory'):
         self.mapfactory = getattr(mapfactorymodule, 'WMSFactory')()
     else:
         raise ServerConfigurationError('The factory module does not have a WMSFactory class.')
     if conf.has_option('server', 'debug'):
         self.debug = int(conf.get('server', 'debug'))
     else:
         self.debug = 0
     if self.conf.has_option_with_value('server', 'maxage'):
         self.max_age = 'max-age=%d' % self.conf.get('server', 'maxage')
     else:
         self.max_age = None
Esempio n. 7
0
 def __init__(self, home_html=None):
     conf = SafeConfigParser()
     conf.readfp(open(self.configpath))
     # TODO - be able to supply in config as well
     self.home_html = home_html
     self.conf = conf
     if not conf.has_option_with_value('server', 'module'):
         raise ServerConfigurationError(
             'The factory module is not defined in the configuration file.')
     try:
         mapfactorymodule = __import__(conf.get('server', 'module'))
     except ImportError:
         raise ServerConfigurationError(
             'The factory module could not be loaded.')
     if hasattr(mapfactorymodule, 'WMSFactory'):
         self.mapfactory = getattr(mapfactorymodule, 'WMSFactory')()
     else:
         raise ServerConfigurationError(
             'The factory module does not have a WMSFactory class.')
     if conf.has_option('server', 'debug'):
         self.debug = int(conf.get('server', 'debug'))
     else:
         self.debug = 0