Beispiel #1
0
def test_ST_AsGeoJSON():
    j0 = "{\"type\":\"Point\",\"coordinates\":[1,2]}"
    j1 = "{\"type\":\"LineString\",\"coordinates\":[[1,2],[4,5],[7,8]]}"
    j2 = "{\"type\":\"Polygon\",\"coordinates\":[[[0,0],[0,1],[1,1],[1,0],[0,0]]]}"
    data = pandas.Series([j0, j1, j2])
    str_ptr = arctern.ST_AsGeoJSON(arctern.ST_GeomFromGeoJSON(data))
    assert str_ptr[0] == '{ "type": "Point", "coordinates": [ 1.0, 2.0 ] }'
    assert str_ptr[1] == '{ "type": "LineString", "coordinates": [ [ 1.0, 2.0 ], [ 4.0, 5.0 ], [ 7.0, 8.0 ] ] }'
    assert str_ptr[
        2] == '{ "type": "Polygon", "coordinates": [ [ [ 0.0, 0.0 ], [ 0.0, 1.0 ], [ 1.0, 1.0 ], [ 1.0, 0.0 ], [ 0.0, 0.0 ] ] ] }'
Beispiel #2
0
def _plot_pandas_series(ax, geoms, **style_kwds):
    import pandas.core.series
    import arctern

    if not isinstance(geoms, pandas.core.series.Series):
        raise TypeError("geoms shuld be type of pandas.core.series.Series")
    len_geoms = len(geoms)
    if len_geoms < 1:
        return None
    if isinstance(geoms[0], str):
        pass
    elif isinstance(geoms[0], bytes):
        geoms = arctern.ST_AsGeoJSON(geoms)
    else:
        raise RuntimeError(f"unexpected input type, {type(geoms[0])}")

    _plot_collection(ax, geoms, **style_kwds)
    return None
Beispiel #3
0
def _plot_pandas_series(ax, geoms, **style_kwds):
    import pandas.core.series
    import json
    if not isinstance(geoms, pandas.core.series.Series):
        raise TypeError("geoms shuld be type of pandas.core.series.Series")
    if len(geoms) < 1:
        return None
    if isinstance(geoms[0], str):
        pass
    elif isinstance(geoms[0], bytes):
        import arctern
        geoms = arctern.ST_AsGeoJSON(geoms)
    else:
        raise RuntimeError(f"unexpected input type, {type(geoms[0])}")

    plot_collect = dict()
    for geo in geoms:
        geo_dict = json.loads(geo)
        _flat_geoms(geo_dict, plot_collect)

    _plot_collection(ax, plot_collect, **style_kwds)
    return None
def python_test(data):
    TIME_START(func_name)
    arctern.ST_AsGeoJSON(arctern.ST_GeomFromGeoJSON(data))
    TIME_END(func_name)
    return TIME_INFO()
Beispiel #5
0
def test_ST_AsGeoJSON():
    geo = "{\"type\":\"Polygon\",\"coordinates\":[[[0,0],[0,1],[1,1],[1,0],[0,0]]]}"
    arr = [geo for x in range(1, 10000001)]
    data = pandas.Series(arr)
    rst = arctern.ST_AsGeoJSON(arctern.ST_GeomFromGeoJSON(data))
    assert len(rst) == 10000000