Esempio n. 1
0
def match_berkeley():
    conf = config.settings

    city_nwk = None
    osm_nwk = None
    setup()

    log('TOP')

    # OUTPUT DIR
    if not os.path.exists(conf['out_dir']): os.makedirs(conf['out_dir'])

    #DATABASE
    # if set write results (and intermediate files) to this database
    global db
    db=False
    #db = postgis.PGIS(conf['project'])
    #db = spatialite.Slite(os.path.join(out_dir, conf['project'] + '.sqlite'))

    # CITY 
    if True: 
        # DOWNLOAD BERKELEY CITY DATA
        misc.update_file_from_url(filename=paths['city_zip'],url=paths['city_url'])
        misc.unzip(paths['city_zip'])

        build_city_network()
    
    # OSM
    if True:
        # DOWNLOAD UP-TO-DATE OSM DATA
        misc.update_file_from_url(filename=paths['osm'],url=paths['osm_url'])

        # BBOX 
        city_nwk = pnwk.PNwk(name='city',filename=paths['city_network'],units='meters')
        city_bbox = city_nwk.get_bbox()
        print 'city_bbox:', city_bbox
        city_bbox_buffered = geo.buffer_box(city_bbox,1000) #buffer by 1000 meters
        print 'city_bbox_buffered:', city_bbox_buffered
        city_bbox_buffered_geo = conf['project_projection'].project_box(city_bbox_buffered, rev=True)
        print 'city_bbox_buffered_geo:', city_bbox_buffered_geo

        build_osm_network(clip_rect=city_bbox_buffered,target_proj=conf['project_proj4text'])

    # MATCH
    if True:
        if not city_nwk:
            city_nwk = pnwk.PNwk(name='city',filename=paths['city_network'],units='meters')
        if not osm_nwk: 
            osm_nwk = pnwk.PNwk(filename=paths['osm_network'],name='osm',units='meters')
        match_networks(osm_nwk, city_nwk)
    
    # MISMATCHED NAMES REPORT
    if True:
        mismatched_names_report()

    log('DONE.')
def doit():
    conf = config.settings
    setup()
    log('TOP')

    # OUTPUT DIR
    if not os.path.exists(conf['out_dir']): os.makedirs(conf['out_dir'])

    #DATABASE
    # if set write results (and intermediate files) to this database
    global db
    #db=False
    #db = postgis.PGIS(conf['project'])
    db = spatialite.Slite(os.path.join(conf['out_dir'], conf['project'] + '.sqlite'))

    misc.update_file_from_url(filename=paths['osm'], url=paths['osm_url'])
    build_osm_network(clip_rect=conf['project_bbox'],target_proj=conf['project_proj4text'])

    log('DONE')