Example #1
0
def test_ST_GeomFromGeoJSON():
    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_AsText(arctern.ST_GeomFromGeoJSON(data))
    assert str_ptr[0] == "POINT (1 2)"
    assert str_ptr[1] == "LINESTRING (1 2,4 5,7 8)"
    assert str_ptr[2] == "POLYGON ((0 0,0 1,1 1,1 0,0 0))"
Example #2
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 ] ] ] }'
Example #3
0
    def geom_from_geojson(cls, json, crs=None):
        """
        Construct geometry from the GeoJSON representation string.

        :type json: Series(dtype: object)
        :param json: Geometries in json format.

        :type crs: string, optional
        :param crs: Must be SRID format string.

        :rtype: GeoSeries
        :return: A GeoSeries contains geometries.

        :example:
        >>> from pandas import Series
        >>> from arctern import GeoSeries
        >>> json = Series(["{\"type\":\"LineString\",\"coordinates\":[[1,2],[4,5],[7,8]]}"])
        >>> GeoSeries.geom_from_geojson(json)
        0    LINESTRING (1 2,4 5,7 8)
        dtype: GeoDtype
        """
        crs = _validate_crs(crs)
        return cls(arctern.ST_GeomFromGeoJSON(json), crs=crs)
Example #4
0
def ST_GeomFromGeoJSON(json):
    return arctern.ST_GeomFromGeoJSON(json)
def python_test(data):
    TIME_START(func_name)
    arctern.ST_AsGeoJSON(arctern.ST_GeomFromGeoJSON(data))
    TIME_END(func_name)
    return TIME_INFO()
Example #6
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