Beispiel #1
0
def road_abbreviate_name(shape, properties, fid):
    name = properties.get('name', None)
    if not name:
        return shape, properties, fid
    short_name = short_street_name(name)
    properties['name'] = short_name
    return shape, properties, fid
def output_geojson_bzipped(index, streets):
    '''
    '''
    try:
        ids = [str(uuid1()) for (n, k, h, g) in streets]
        geometries = [geom.__geo_interface__ for (n, k, h, geom) in streets]

        properties = [dict(name=short_street_name(n), long_name=n, kind=k, highway=h)
                      for (n, k, h, g) in streets]
        
        features = [dict(type='Feature', id=id, properties=p, geometry=g)
                    for (id, p, g) in zip(ids, properties, geometries)]
        
        geojson = dict(type='FeatureCollection', features=features)
        encoder = JSONEncoder(separators=(',', ':'))
        encoded = encoder.iterencode(geojson)

        output = BZ2File('streets-%06d.json.bz2' % index, 'w')
        
        for token in encoded:
            if charfloat_pat.match(token):
                # in python 2.7, we see a character followed by a float literal
                output.write(token[0] + '%.6f' % float(token[1:]))
            
            elif float_pat.match(token):
                # in python 2.6, we see a simple float literal
                output.write('%.6f' % float(token))
            
            else:
                output.write(token)        

        output.close()
    
    except Exception, e:
        return index, len(streets), e
Beispiel #3
0
def road_abbreviate_name(shape, properties, fid):
    name = properties.get('name', None)
    if not name:
        return shape, properties, fid
    short_name = short_street_name(name)
    properties['name'] = short_name
    return shape, properties, fid
 def key_properties((name, )):
     return dict(name=name,
                 zoomlevel=options.zoom, pixelwidth=options.width,
                 shortname=short_street_name(name))
Beispiel #5
0
 def key_properties(xxx_todo_changeme1):
     (name, ) = xxx_todo_changeme1
     return dict(name=name,
                 zoomlevel=options.zoom, pixelwidth=options.width,
                 shortname=short_street_name(name))
Beispiel #6
0
 def key_properties((name, )):
     return dict(name=name,
                 zoomlevel=options.zoom,
                 pixelwidth=options.width,
                 shortname=short_street_name(name))