Exemplo n.º 1
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 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)
Exemplo n.º 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)
Exemplo n.º 3
0
def compress(s):
    return _compress(s, 1)