Exemplo n.º 1
0
    def dashboard(self):
        if not 'mapclient.enable.api.dashboard' in config or not asbool(config['mapclient.enable.api.dashboard']) == True:
            abort(404, 'Data API dashboard is not enabled.')

        # Servers
        c.servers = {
            'mapproxy' : filter(None, [s.strip() for s in config['mapclient.servers.mapproxy'].split(',')]),
            'osm' : filter(None, [s.strip() for s in config['mapclient.servers.osm'].split(',')])
        }

        # Data API configuration
        c.api = {}

        # Resource alias
        resource_list = None
        alias_list = None

        if 'mapclient.enable.api.dashboard.queries.resource' in config and not config['mapclient.enable.api.dashboard.queries.resource'] is None:
            resource_list = filter(None, [s.strip() for s in config['mapclient.enable.api.dashboard.queries.resource'].split(',')])

        if 'mapclient.enable.api.dashboard.queries.alias' in config and not config['mapclient.enable.api.dashboard.queries.alias'] is None:
            alias_list = filter(None, [s.strip() for s in config['mapclient.enable.api.dashboard.queries.alias'].split(',')])

        if not resource_list is None and not alias_list is None:
            if len(resource_list) > 0 and len(resource_list) == len(alias_list):
                c.api['alias'] = dict(zip(alias_list, resource_list))

        # WPS endpoint
        c.api['wps'] = config['mapclient.enable.api.dashboard.wps.endpoint']

        # Google Analytics
        if 'mapclient.google.analytics' in config and config['mapclient.google.analytics']:
            c.google = config['mapclient.google.analytics']

        return render('/api/dashboard.jinja2')
Exemplo n.º 2
0
    def embed(self, id):
        try:
            configuration = self._expand(id)

            if 'mapclient.google.analytics' in config and config['mapclient.google.analytics']:
                c.google = config['mapclient.google.analytics']

            c.lib = config['lib'] if 'lib' in config else 'leaflet'
            c.config = json.dumps(configuration)
        except Exception as ex:
            log.exception(u'Failed to load and embed configuration {config}.'.format(config = id))

            abort(404, 'Map configuration was not found')

        return render('/embed.jinja2')
Exemplo n.º 3
0
    def index(self):
        # Servers
        c.servers = {
            'mapproxy' : filter(None, [s.strip() for s in config['mapclient.servers.mapproxy'].split(',')]),
            'tilecache' : filter(None, [s.strip() for s in config['mapclient.servers.tilecache'].split(',')]),
            'osm' : filter(None, [s.strip() for s in config['mapclient.servers.osm'].split(',')])
        }

        # Google Analytics
        if 'mapclient.google.analytics' in config and config['mapclient.google.analytics']:
            c.google = config['mapclient.google.analytics']

        # Get metadata version
        c.metadata = {
            'version' : ''
        }

        if 'mapclient.catalog.metadata.physical' in config:
            filename = config['mapclient.catalog.metadata.physical']

            if os.path.exists(filename):
                c.metadata['version'] = os.stat(filename).st_mtime

        # Export disabled format
        c.exportDisabledFormats = []
        if 'dataapi.export.formats.disabled' in config:
           c.exportDisabledFormats =  filter(None, config['dataapi.export.formats.disabled'].split(','))

        # Debug mode
        debug = asbool(config['mapclient.debug'])

        # RequireJS main script
        if self._isMobileOrTablet() == False:
            if debug == True:
                c.main = 'js/client-main.js'
            else:
                c.main = 'jsmin/client-main.js'
        else:
            if debug == True:
                c.main = 'js/client-main-mobile.js'
            else:
                c.main = 'jsmin/client-main-mobile.js'

        return render('/index.jinja2')