예제 #1
0
def test_full_example():
    data = [("广州", 45), ("漳州", 35), ("A市", 43)]
    geo = Geo("全国主要城市空气质量", "data from pm2.5", **style.init_style)
    coordinate = geo.get_coordinate("广州")
    assert 2 == len(coordinate)
    with assert_raises(ValueError):
        geo.get_coordinate("A市", raise_exception=True)
    attr, value = geo.cast(data)
    with assert_raises(ValueError):
        geo.add(
            "",
            attr,
            value,
            type="effectScatter",
            is_random=True,
            is_visualmap=True,
            is_piecewise=True,
            visual_text_color="#fff",
            pieces=[
                {
                    "min": 0,
                    "max": 13,
                    "label": "0 < x < 13"
                },
                {
                    "min": 14,
                    "max": 16,
                    "label": "14 < x < 16"
                },
            ],
            effect_scale=5,
        )
    geo.add_coordinate("A市", 119.3, 26.08)
    geo.add(
        "",
        attr,
        value,
        type="effectScatter",
        is_random=True,
        is_visualmap=True,
        is_piecewise=True,
        visual_text_color="#fff",
        pieces=[
            {
                "min": 0,
                "max": 13,
                "label": "0 < x < 13"
            },
            {
                "min": 14,
                "max": 16,
                "label": "14 < x < 16"
            },
        ],
        effect_scale=5,
    )
    geo.render()
예제 #2
0
def test_full_example():
    data = [("广州", 45), ("漳州", 35), ("A市", 43)]
    geo = Geo("全国主要城市空气质量", "data from pm2.5", **style.init_style)
    coordinate = geo.get_coordinate("广州")
    assert 2 == len(coordinate)
    with assert_raises(ValueError):
        geo.get_coordinate("A市", raise_exception=True)
    attr, value = geo.cast(data)
    with assert_raises(ValueError):
        geo.add(
            "",
            attr,
            value,
            type="effectScatter",
            is_random=True,
            is_visualmap=True,
            is_piecewise=True,
            visual_text_color="#fff",
            pieces=[
                {"min": 0, "max": 13, "label": "0 < x < 13"},
                {"min": 14, "max": 16, "label": "14 < x < 16"},
            ],
            effect_scale=5,
        )
    geo.add_coordinate("A市", 119.3, 26.08)
    geo.add(
        "",
        attr,
        value,
        type="effectScatter",
        is_random=True,
        is_visualmap=True,
        is_piecewise=True,
        visual_text_color="#fff",
        pieces=[
            {"min": 0, "max": 13, "label": "0 < x < 13"},
            {"min": 14, "max": 16, "label": "14 < x < 16"},
        ],
        effect_scale=5,
    )
    geo.render()
예제 #3
0

data = []
alist = all_list(city)
for item in alist:
    data.append((item, alist[item]))

style = Style(title_color="#fff",
              title_pos="center",
              width=1800,
              height=920,
              background_color="#404a59")

geo = Geo("Nifty Hospitals", "chaos", **style.init_style)

lat, lng = geo.get_coordinate("深圳市")


def add_pos_to_geo(geo):
    for item in data:
        url = get_url(item[0])
        req = urlopen(url)
        res = req.read().decode()
        result = json.loads(res)
        if int(result['status']) == 0 and result['result']['confidence'] > 40:
            geo.add_coordinate(item[0], result['result']['location']['lng'],
                               result['result']['location']['lat'])
        else:
            #print(item[0] + "   : " + str(result['result']['location']['lng']) + " -- " + str(result['result']['location']['lat']) + " -- " + str(result['result']['confidence']))
            data.remove(item)