Exemplo n.º 1
0
def main():
    global window
    windowname = 'map'

    glutInit([''])
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE)
    glutInitWindowSize(SCREEN_WIDTH, SCREEN_HEIGHT)
    glutInitWindowPosition(0, 0)
    window = glutCreateWindow(windowname)

    if settings.FULLSCREEN:
        glutFullScreen()
        #os.popen('wmctrl -r %s -b toggle,fullscreen' % windowname)

    glutDisplayFunc(DrawGLScene)
    glutIdleFunc(DrawGLScene)
    glutReshapeFunc(ReSizeGLScene)
    glutKeyboardFunc(keyPressed)

    InitGL(SCREEN_WIDTH, SCREEN_HEIGHT)

    global texture_manager
    texture_manager = TextureThread(glGenTextures(1))
    texture_manager.start()

    # todo: make layer selection specific to what's available in surrounding area
    global layers
    sess = maptile.dbsess()
    layers = [r[0] for r in sess.query(maptile.Tile.layer).distinct()]
    layers = filter(lambda lyr: not getattr(settings, 'SHOW_LAYERS', []) or lyr in settings.SHOW_LAYERS, layers)

    glutMainLoop()
Exemplo n.º 2
0
def tile_file (mode, zoom, x, y):
  global conn
  if conn == None:
    conn = maptile.dbsess()

  t = conn.query(maptile.Tile).get((mode, zoom, x, y))
  return t.open(conn) if t else None
Exemplo n.º 3
0
def db_validate(args):
    sess = mt.dbsess()

    try:
        region = sess.query(mt.Region).filter_by(name=args['name']).one()
        if args['region']:
            if args['update']:
                region.boundary = args['region'].boundary
                sess.commit()
            else:
                if (args['region'].poly() ^ region.poly()).area() > 1e-6:
                    raise RuntimeError(
                        'region "%s" already exists (set "update" flag?)' %
                        args['name'])

    except InvalidRequestError:
        if not args['region']:
            raise RuntimeError(
                'region "%s" does not exist (supply a region boundary?)' %
                args['name'])

        if args['name']:
            args['region'].name = args['name']
            sess.add(args['region'])
            sess.commit()
        region = args['region']

    args['region'] = region.merc_poly()
Exemplo n.º 4
0
def tile_file (mode, zoom, x, y):
  global conn
  if conn == None:
    conn = maptile.dbsess()

  t = conn.query(maptile.Tile).get((mode, zoom, x, y))
  return t.open(conn) if t else None
Exemplo n.º 5
0
def download_curses(w, polygon, layers):
    te = mapdownload.TileEnumerator(polygon, layers)
    monitor(w, 0, te, 'Enumerating', 15, 3)

    print_tile_counts(w, mapdownload.tile_counts(te.tiles), 'Tiles in region', 4, 2)

    tc = mapdownload.TileCuller(te.tiles, layers, mt.dbsess())
    monitor(w, 1, tc, 'Culling', 15)

    print_tile_counts(w, mapdownload.tile_counts(tc.tiles, max(L['zoom'] for L in layers)), 'Tiles to download', 4, 19)

    td = mapdownload.TileDownloader(tc.tiles, mt.dbsess())
    monitor(w, 2, td, 'Downloading', 15, erry=3)

    try:
        while True:
            time.sleep(.01)
    except KeyboardInterrupt:
        pass
Exemplo n.º 6
0
def download_curses(w, polygon, layers):
    te = mapdownload.TileEnumerator(polygon, layers)
    monitor(w, 0, te, 'Enumerating', 15, 3)

    print_tile_counts(w, mapdownload.tile_counts(te.tiles), 'Tiles in region',
                      4, 2)

    tc = mapdownload.TileCuller(te.tiles, layers, mt.dbsess())
    monitor(w, 1, tc, 'Culling', 15)

    print_tile_counts(
        w, mapdownload.tile_counts(tc.tiles, max(L['zoom'] for L in layers)),
        'Tiles to download', 4, 19)

    td = mapdownload.TileDownloader(tc.tiles, mt.dbsess())
    monitor(w, 2, td, 'Downloading', 15, erry=3)

    try:
        while True:
            time.sleep(.01)
    except KeyboardInterrupt:
        pass
Exemplo n.º 7
0
def main():
    global window
    windowname = 'map'

    glutInit([''])
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE)
    glutInitWindowSize(SCREEN_WIDTH, SCREEN_HEIGHT)
    glutInitWindowPosition(0, 0)
    window = glutCreateWindow(windowname)

    if settings.FULLSCREEN:
        glutFullScreen()
        #os.popen('wmctrl -r %s -b toggle,fullscreen' % windowname)

    glutDisplayFunc(DrawGLScene)
    glutIdleFunc(DrawGLScene)
    glutReshapeFunc(ReSizeGLScene)
    glutKeyboardFunc(keyPressed)

    InitGL(SCREEN_WIDTH, SCREEN_HEIGHT)

    global texture_manager
    texture_manager = TextureThread(glGenTextures(1))
    texture_manager.start()

    # todo: make layer selection specific to what's available in surrounding area
    global layers
    global view
    sess = maptile.dbsess()
    layers = [r[0] for r in sess.query(maptile.Tile.layer).distinct()]
    layers = filter(
        lambda lyr: not getattr(settings, 'SHOW_LAYERS', []) or lyr in settings
        .SHOW_LAYERS, layers)
    if view not in layers:
        view = layers[0]

    glutMainLoop()
Exemplo n.º 8
0
def db_validate(args):
    sess = mt.dbsess()

    try:
        region = sess.query(mt.Region).filter_by(name=args['name']).one()
        if args['region']:
            if args['update']:
                region.boundary = args['region'].boundary
                sess.commit()
            else:
                if (args['region'].poly() ^ region.poly()).area() > 1e-6:
                    raise RuntimeError('region "%s" already exists (set "update" flag?)' % args['name'])

    except InvalidRequestError:
        if not args['region']:
            raise RuntimeError('region "%s" does not exist (supply a region boundary?)' % args['name'])

        if args['name']:
            args['region'].name = args['name']
            sess.add(args['region'])
            sess.commit()
        region = args['region']

    args['region'] = region.merc_poly()
Exemplo n.º 9
0
        return filter(lambda e: e, [make_marker(pm) for pm in kml.findall('.//%s' % _('Placemark'))])

class MainHandler(web.RequestHandler):
    def get(self):
        self.render('map.html', onload='init_console')

class LayerPlaygroundHandler(web.RequestHandler):
    def get(self):
        self.render('map.html', onload='init_playground')

def tile_fetch_callback(meta, status, data):
    IOLoop.instance().add_callback(lambda: meta['callback'](md.normdata(status, data)))


sess = mt.dbsess()
tiledl = md.DownloadService(tile_fetch_callback, sess)

if __name__ == "__main__":

    u.setup()

    parser = OptionParser()
    parser.add_option("--ssl", dest="ssl", action='store_true',
                      help="enable ssl; prevents 'Referer' header from being sent to mapservers")
    parser.add_option('-u', '--url', dest='urls', action='append',
                      help='custom url specs')

    (options, args) = parser.parse_args()

    try:
Exemplo n.º 10
0
class MainHandler(web.RequestHandler):
    def get(self):
        self.render('map.html', onload='init_console')


class LayerPlaygroundHandler(web.RequestHandler):
    def get(self):
        self.render('map.html', onload='init_playground')


def tile_fetch_callback(meta, status, data):
    IOLoop.instance().add_callback(lambda: meta['callback']
                                   (md.normdata(status, data)))


sess = mt.dbsess()
tiledl = md.DownloadService(tile_fetch_callback, sess)

if __name__ == "__main__":

    u.setup()

    parser = OptionParser()
    parser.add_option(
        "--ssl",
        dest="ssl",
        action='store_true',
        help=
        "enable ssl; prevents 'Referer' header from being sent to mapservers")
    parser.add_option('-u',
                      '--url',