-
Notifications
You must be signed in to change notification settings - Fork 754
[GH-2230] Add GeoSeries.shortest_line and GeoSeries.offset_curve #2828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1058,8 +1058,13 @@ def extract_unique_points(self): | |
| ) | ||
|
|
||
| def offset_curve(self, distance, quad_segs=8, join_style="round", mitre_limit=5.0): | ||
| # Implementation of the abstract method. | ||
| raise NotImplementedError("This method is not implemented yet.") | ||
| # ST_OffsetCurve returns null for empty geometries, but GeoPandas returns LINESTRING EMPTY | ||
| empty_line = stc.ST_GeomFromText(F.lit("LINESTRING EMPTY")) | ||
| spark_col = F.when( | ||
| stf.ST_IsEmpty(self.spark.column), | ||
jiayuasu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| empty_line, | ||
| ).otherwise(stf.ST_OffsetCurve(self.spark.column, distance, quad_segs)) | ||
|
Comment on lines
+1061
to
+1066
|
||
| return self._query_geometry_column(spark_col, returns_geom=True) | ||
|
|
||
| @property | ||
| def interiors(self): | ||
|
|
@@ -1528,6 +1533,18 @@ def intersection( | |
| ) | ||
| return result | ||
|
|
||
| def shortest_line(self, other, align=None) -> "GeoSeries": | ||
| other_series, extended = self._make_series_of_val(other) | ||
| align = False if extended else align | ||
|
|
||
| spark_expr = stf.ST_ShortestLine(F.col("L"), F.col("R")) | ||
| return self._row_wise_operation( | ||
| spark_expr, | ||
| other_series, | ||
| align=align, | ||
| returns_geom=True, | ||
| ) | ||
|
|
||
| def snap(self, other, tolerance, align=None) -> "GeoSeries": | ||
| if not isinstance(tolerance, (float, int)): | ||
| raise NotImplementedError( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.