示例#1
0
文件: mvt.py 项目: byrman/TileStache
def encode(file, features):
    ''' Encode a list of (WKB, property dict) features into an MVT stream.
    
        Geometries in the features list are assumed to be in spherical mercator.
        Floating point precision in the output is approximated to 26 bits.
    '''
    parts = []
    
    for feature in features:
        wkb = approximate_wkb(feature[0])
        prop = json.dumps(feature[1])
        
        parts.extend([_pack('>I', len(wkb)), wkb, _pack('>I', len(prop)), prop])
    
    body = _compress(_pack('>I', len(features)) + b''.join(parts))
    
    file.write(b'\x89MVT')
    file.write(_pack('>I', len(body)))
    file.write(body)
示例#2
0
def encode(file, features):
    ''' Encode a list of (WKB, property dict) features into an MVT stream.
    
        Geometries in the features list are assumed to be in spherical mercator.
        Floating point precision in the output is approximated to 26 bits.
    '''
    parts = []

    for (wkb, prop) in features:
        wkb = approximate_wkb(wkb)
        prop = json.dumps(prop)

        parts.extend(
            [_pack('>I', len(wkb)), wkb,
             _pack('>I', len(prop)), prop])

    body = _compress(_pack('>I', len(features)) + ''.join(parts))

    file.write('\x89MVT')
    file.write(_pack('>I', len(body)))
    file.write(body)
示例#3
0
文件: util.py 项目: wtzhuque/dpark
def compress(s):
    return _compress(s, 1)