コード例 #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)