Beispiel #1
0
    def surface(self,
                features,
                mapid="mapbox.mapbox-terrain-v1",
                layer="contour",
                fields=["ele"],
                geojson=True,
                polyline=False,
                interpolate=None,
                zoom=None):

        params = {
            'layer': layer,
            'fields': ','.join(fields),
            'geojson': 'true' if geojson else 'false',
        }

        if interpolate is not None:
            params['interpolate'] = 'true' if interpolate else 'false',

        if zoom is not None:
            params['zoom'] = zoom

        if polyline:
            params['encoded_polyline'] = encode_polyline(features)
        else:
            params['points'] = encode_waypoints(
                features, precision=6, min_limit=1, max_limit=300)

        uri = URITemplate(self.baseuri + '/{mapid}.json').expand(mapid=mapid)
        res = self.session.get(uri, params=params)
        self.handle_http_error(res)

        def geojson():
            return res.json()['results']
        res.geojson = geojson

        return res
def test_encode_polyline():
    expected = "wp_~EvdatO{xiAfupD"
    assert expected == encode_polyline(gj_point_features)
    assert expected == encode_polyline(gj_multipoint_features)
    assert expected == encode_polyline(gj_line_features)
def test_encode_polyline():
    expected = "vdatOwp_~EhupD{xiA"
    assert expected == encode_polyline(gj_point_features)
    assert expected == encode_polyline(gj_multipoint_features)
    assert expected == encode_polyline(gj_line_features)