Example #1
0
 for member in gf_archive.getmembers():
     if not member.name.endswith('.poly'):
         continue
     
     extract_path = member.name[:-5] + '.osm.pbf'
     extract_href = urljoin(gf_base_href, extract_path)
     
     try:
         content_length, last_modified = size_and_date(extract_href)
         print extract_href
 
     except IOError:
         print 'Failed', extract_href
         continue
     
     lines = list(gf_archive.extractfile(member))
     shape = parse_poly(lines)
     
     extracts.append((extract_href, content_length, last_modified, shape))
 
 
 
 db = connect(database='tiledrawer', user='******').cursor()
 
 db.execute('BEGIN')
 db.execute('DELETE FROM extracts')
 
 for (href, size, date, shape) in extracts:
     db.execute("""INSERT INTO extracts (href, size, date, geom)
                   VALUES (%s, %s, %s, SetSRID(Multi(GeomFromText(%s)), 4326))""",
                (href, size, date, str(shape)))
Example #2
0
    for member in gf_archive.getmembers():
        if not member.name.endswith('.poly'):
            continue

        extract_path = member.name[:-5] + '.osm.pbf'
        extract_href = urljoin(gf_base_href, extract_path)

        try:
            content_length, last_modified = size_and_date(extract_href)
            print extract_href

        except IOError:
            print 'Failed', extract_href
            continue

        lines = list(gf_archive.extractfile(member))
        shape = parse_poly(lines)

        extracts.append((extract_href, content_length, last_modified, shape))

    db = connect(database='tiledrawer', user='******').cursor()

    db.execute('BEGIN')
    db.execute('DELETE FROM extracts')

    for (href, size, date, shape) in extracts:
        db.execute(
            """INSERT INTO extracts (href, size, date, geom)
                      VALUES (%s, %s, %s, SetSRID(Multi(GeomFromText(%s)), 4326))""",
            (href, size, date, str(shape)))