Ejemplo n.º 1
0
def decode(file):
    ''' Decode an MVT file into a list of (WKB, property dict) features.
    
        Result can be passed directly to mapnik.PythonDatasource.wkb_features().
    '''
    head = file.read(4)
    
    if head != '\x89MVT':
        raise Exception('Bad head: "%s"' % head)
    
    body = StringIO(_decompress(file.read(_next_int(file))))
    features = []
    
    for i in range(_next_int(body)):
        wkb = body.read(_next_int(body))
        raw = body.read(_next_int(body))

        props = json.loads(raw)
        features.append((wkb, props))
    
    return features
Ejemplo n.º 2
0
def decode(file):
    ''' Decode an MVT file into a list of (WKB, property dict) features.
    
        Result can be passed directly to mapnik.PythonDatasource.wkb_features().
    '''
    head = file.read(4)

    if head != '\x89MVT':
        raise Exception('Bad head: "%s"' % head)

    body = StringIO(_decompress(file.read(_next_int(file))))
    features = []

    for i in range(_next_int(body)):
        wkb = body.read(_next_int(body))
        raw = body.read(_next_int(body))

        props = json.loads(raw)
        features.append((wkb, props))

    return features
Ejemplo n.º 3
0
 def __init__(self):
     try:
         self.deflate = lambda data: _decompress(data, -1*_zlib_MAX_WBITS)
     except _zlib_error:
         self.deflate = lambda data: _decompress(data)