コード例 #1
0
ファイル: wsgi.py プロジェクト: drewjelani/OGCServer
 def __init__(self,
              configpath,
              fonts=None,
              home_html=None,
              **kwargs
             ):
     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 'debug' in kwargs:
         self.debug = bool(kwargs['debug'])
     else:
         self.debug = False
     if self.debug:
         self.debug=1
     else:
         self.debug=0
     if 'maxage' in kwargs:
         self.max_age = 'max-age=%d' % kwargs.get('maxage')
     else:
         self.max_age = None
コード例 #2
0
ファイル: wsgi.py プロジェクト: drewjelani/OGCServer
 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
コード例 #3
0
ファイル: cli.py プロジェクト: seanlee928/invar
    def __init__(self):
        """
        Perform argument processing and other setup for a InvarUtility.
        """
        self._init_common_parser()
        self.add_arguments()
        self.args = self.argparser.parse_args()
        self._install_exception_handler()

        if hasattr(self.args, 'font_paths'):
            for font_path in self.args.font_paths:
                mapnik2.register_fonts(font_path)
コード例 #4
0
ファイル: cli.py プロジェクト: seanlee928/invar
    def __init__(self):
        """
        Perform argument processing and other setup for a InvarUtility.
        """
        self._init_common_parser()
        self.add_arguments()
        self.args = self.argparser.parse_args()
        self._install_exception_handler()

        if hasattr(self.args, 'font_paths'):
            for font_path in self.args.font_paths:
                mapnik2.register_fonts(font_path)
コード例 #5
0
    def __init__(self,
                 map_w,
                 map_h,
                 gpx_file=None,
                 gpx_style=None,
                 map_zoom=18,
                 mapfile=None,
                 maps_cache=None,
                 no_lazy_load=False,
                 font_path=None):

        if font_path is not None:
            mapnik.register_fonts(font_path)

        self.m = None
        self.mapfile = mapfile
        self.gpx_style = gpx_style
        self.gpx_file = gpx_file
        self.map_width = map_w
        self.map_height = map_h
        if map_zoom is None:
            self.zoom_changeable = True
        else:
            self.zoom_changeable = False
        self.map_zoom = map_zoom
        self.maps_cache = maps_cache
        self.mapnik_style_file = mapfile

        if self.maps_cache is not None:
            self._save_cache()

        else:
            self._lazy_init_map()

        if no_lazy_load:
            self._lazy_init_map()
コード例 #6
0
#!/usr/bin/python
from math import pi,cos,sin,log,exp,atan
from subprocess import call
import sys, os
from Queue import Queue
import mapnik2
import threading
import argparse

custom_fonts_dir = '/Library/Fonts/'
mapnik2.register_fonts(custom_fonts_dir)

DEG_TO_RAD = pi/180
RAD_TO_DEG = 180/pi

# Default number of rendering threads to spawn, should be roughly equal to number of CPU cores available
NUM_THREADS = 4

def minmax (a,b,c):
    a = max(a,b)
    a = min(a,c)
    return a

class GoogleProjection:
    def __init__(self,levels=18):
        self.Bc = []
        self.Cc = []
        self.zc = []
        self.Ac = []
        c = 256
        for d in range(0,levels):
コード例 #7
0
ファイル: toposm.py プロジェクト: calvinmetcalf/TopOSM
from coords import *
from common import *
import NED
import areas
from JobManager import JobManager

__author__      = "Lars Ahlzen and contributors"
__copyright__   = "(c) Lars Ahlzen and contributors 2008-2011"
__license__     = "GPLv2"


##### Initialize Mapnik

# Import extra fonts
if EXTRA_FONTS_DIR != '':
    mapnik.register_fonts(EXTRA_FONTS_DIR)

# Check for cairo support
if not mapnik.has_cairo():
    print "ERROR: Your mapnik does not have Cairo support."
    sys.exit(1)


##### Render settings

# Set to true to save intermediate layers that are normally
# merged. Primarily useful for debugging and style editing.
SAVE_INTERMEDIATE_TILES = True

# If true, a composite JPEG layer is saved along with
# the standard PNG.
コード例 #8
0
from env import *
from coords import *
from common import *
import NED
import areas
from JobManager import JobManager

__author__ = "Lars Ahlzen and contributors"
__copyright__ = "(c) Lars Ahlzen and contributors 2008-2011"
__license__ = "GPLv2"

##### Initialize Mapnik

# Import extra fonts
if EXTRA_FONTS_DIR != '':
    mapnik.register_fonts(EXTRA_FONTS_DIR)

# Check for cairo support
if not mapnik.has_cairo():
    print "ERROR: Your mapnik does not have Cairo support."
    sys.exit(1)

##### Render settings

# Set to true to save intermediate layers that are normally
# merged. Primarily useful for debugging and style editing.
SAVE_INTERMEDIATE_TILES = True

# If true, a composite JPEG layer is saved along with
# the standard PNG.
SAVE_JPEG_COMPOSITE = True
コード例 #9
0
        ])
    except ValueError:
        parser.print_help()
        sys.exit(1)

    opts.more_opts = {}
    if opts.filename_pattern is not None:
        opts.more_opts['filename_pattern'] = opts.filename_pattern

    # semantic opts
    opts.single_tiles = opts.tiles is not None
    opts.push_children = not opts.single_tiles

    # debug(opts)
    info(opts)

    return opts


if __name__ == "__main__":
    opts = parse_args()

    master = Master(opts)

    # fixes for locally installed mapnik
    mapnik.register_fonts('/usr/share/fonts/')
    mapnik.register_plugins('/home/mdione/local/lib/mapnik/input/')
    info(mapnik.__file__)

    master.render_tiles()
コード例 #10
0
#!/usr/bin/python

# Inspired by generate_tiles.py, part of the Open Street Map project:
# http://svn.openstreetmap.org/applications/rendering/mapnik/generate_tiles.py

import argparse
from math import pi, sin, log, exp, atan
import multiprocessing
import Queue
import os
import sys

import mapnik2

mapnik2.register_fonts('/Library/Fonts/')
mapnik2.register_fonts('/usr/share/fonts')

DEFAULT_TILE_WIDTH = 256
DEFAULT_TILE_HEIGHT = 256
DEFAULT_MIN_ZOOM = 9
DEFAULT_MAX_ZOOM = 12
DEFAULT_PROCESS_COUNT = 2
DEFAULT_FILE_TYPE = 'png256'

DEG_TO_RAD = pi / 180
RAD_TO_DEG = 180 / pi

def minmax (a,b,c):
    a = max(a,b)
    a = min(a,c)
    return a
コード例 #11
0
ファイル: generate_tiles.py プロジェクト: StyXman/elevation
        opts.store_thread = False
    elif opts.parallel == 'fork':
        debug('mp.Process()')
        opts.parallel_factory = multiprocessing.Process
    elif opts.parallel == 'threads':
        debug('th.Thread()')
        opts.parallel_factory = threading.Thread

    # semantic opts
    opts.single_tiles = opts.tiles is not None
    opts.push_children = not opts.single_tiles

    # debug(opts)
    info(opts)

    return opts


if __name__  ==  "__main__":
    opts = parse_args()

    master = Master(opts)


    # fixes for locally installed mapnik
    mapnik.register_fonts ('/usr/share/fonts/')
    mapnik.register_plugins ('/home/mdione/local/lib/mapnik/input/')
    info(mapnik.__file__)

    master.render_tiles()