Skip to content

Commit

Permalink
Fix some bugs of code example in comments. (#578)
Browse files Browse the repository at this point in the history
* fix api comment

* fix api comment

* fix api comment

* change param name in gis api

* change param name in gis api

* change scheam name

* change scheam name

* fix api comment

* ...

* fix Copyright

* fix api comment

* fix api comment

* fix gis api comment

* fix api comment

* modified param name

* modify plot api comment

* modify plot api comment

* modify plot api comment

* add register_func comment

* modify register_func comment

* change import order in plot test

* fix param type from double to float

* fix gis comment

* fix api comment

* fix api comment

* fix api comment

* fix bugs in gis test example

Co-authored-by: yxm1536 <xiaomeng.yi@outlook.com>
  • Loading branch information
become-nice and yxm1536 authored May 9, 2020
1 parent e90d144 commit 297b80a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions python/arctern/_wrapper_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def ST_Intersection(geo1, geo2):
>>> import arctern
>>> data1 = pandas.Series(["POLYGON ((1 1,1 2,2 2,2 1,1 1))"])
>>> data2 = pandas.Series(["POLYGON ((2 1,3 1,3 2,2 2,2 1))"])
>>> string_ptr = arctern.ST_AsText(arctern.ST_Point(data1, data2))
>>> string_ptr = arctern.ST_AsText(arctern.ST_Intersection(data1, data2))
>>> print(string_ptr)
0 LINESTRING (2 2,2 1)
dtype: object
Expand Down Expand Up @@ -366,7 +366,7 @@ def ST_PrecisionReduce(geos, precision):
>>> import pandas
>>> import arctern
>>> data = pandas.Series(["POINT (1.333 2.666)", "POINT (2.655 4.447)"])
>>> rst = arctern.arctern.ST_AsText(arctern.ST_PrecisionReduce(arctern.ST_GeomFromText(data), 3))
>>> rst = arctern.ST_AsText(arctern.ST_PrecisionReduce(arctern.ST_GeomFromText(data), 3))
>>> print(rst)
0 POINT (1.33 2.67)
1 POINT (2.66 4.45)
Expand Down Expand Up @@ -646,7 +646,7 @@ def ST_PolygonFromEnvelope(min_x, min_y, max_x, max_y):
>>> x_max = pandas.Series([1.0])
>>> y_min = pandas.Series([0.0])
>>> y_max = pandas.Series([1.0])
>>> rst = arctern.ST_AsText(rctern.ST_PolygonFromEnvelope(x_min, y_min, x_max, y_max))
>>> rst = arctern.ST_AsText(arctern.ST_PolygonFromEnvelope(x_min, y_min, x_max, y_max))
>>> print(rst)
0 POLYGON ((0 0,0 1,1 1,1 0,0 0))
dtype: object
Expand Down Expand Up @@ -1153,6 +1153,7 @@ def ST_Transform(geos, from_srid, to_srid):
:example:
>>> import pandas
>>> import arctern
>>> from osgeo import ogr
>>> data = ["POINT (10 10)"]
>>> data = pandas.Series(data)
>>> rst = arctern.ST_AsText(arctern.ST_Transform(arctern.ST_GeomFromText(data), "EPSG:4326", "EPSG:3857"))
Expand Down Expand Up @@ -1186,7 +1187,7 @@ def ST_CurveToLine(geos):
>>> import arctern
>>> data = ["CURVEPOLYGON(CIRCULARSTRING(0 0, 4 0, 4 4, 0 4, 0 0))"]
>>> data = pandas.Series(data)
>>> rst = arctern.ST_CurveToLine(arctern.ST_GeomFromText(data))
>>> rst = arctern.ST_AsText(arctern.ST_CurveToLine(arctern.ST_GeomFromText(data)))
>>> assert str(rst[0]).startswith("POLYGON")
"""
import pyarrow as pa
Expand Down
6 changes: 3 additions & 3 deletions spark/pyspark/arctern_pyspark/_wrapper_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ def ST_IsSimple(geos):
>>> test_data = []
>>> test_data.extend([('POLYGON((1 2, 3 4, 5 6, 1 2))',)])
>>> test_data.extend([('LINESTRING(1 1,2 2,2 3.5,1 3,1 2,2 1)',)])
>>> test_data.extend([('POINT (1 1)')])
>>> test_data.extend([('POINT (1 1)',)])
>>> simple_df = spark_session.createDataFrame(data=test_data, schema=['geos']).cache()
>>> simple_df.createOrReplaceTempView("simple")
>>> spark_session.sql("select ST_IsSimple(ST_GeomFromText(geos)) from simple").show(100,0)
Expand Down Expand Up @@ -1247,7 +1247,7 @@ def ST_Union_Aggr(geos):
+-----------------------------------------------+
|ST_AsText(ST_Union_Aggr(ST_GeomFromText(geos)))|
+-----------------------------------------------+
|POLYGON ((4 1,4 0,0 0,0 4,4 4,4 2,5 2,5 1,4 1))|
|POLYGON ((1 1,1 2,2 2,3 2,3 1,2 1,1 1)) |
+-----------------------------------------------+
"""
rst = arctern.ST_Union_Aggr(geos)
Expand Down Expand Up @@ -1306,7 +1306,7 @@ def ST_Transform(geos, from_srid, to_srid):
>>> from arctern_pyspark import register_funcs
>>> spark_session = SparkSession.builder.appName("Python Arrow-in-Spark example").getOrCreate()
>>> register_funcs(spark_session)
>>> test_data = []
>>> test_data = []
>>> test_data.extend([('POINT (10 10)',)])
>>> buffer_df = spark_session.createDataFrame(data=test_data, schema=['geos']).cache()
>>> buffer_df.createOrReplaceTempView("buffer")
Expand Down
2 changes: 1 addition & 1 deletion spark/pyspark/arctern_pyspark/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def register_funcs(spark):
>>> from arctern_pyspark import register_funcs
>>> spark_session = SparkSession.builder.appName("Python Arrow-in-Spark example").getOrCreate()
>>> register_funcs(spark_session)
>>> test_data = []
>>> test_data = []
>>> test_data.extend([('POINT (10 10)',)])
>>> buffer_df = spark_session.createDataFrame(data=test_data, schema=['geos']).cache()
>>> buffer_df.createOrReplaceTempView("buffer")
Expand Down

0 comments on commit 297b80a

Please sign in to comment.