forked from apache/sedona
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathst_constructors.py
More file actions
696 lines (560 loc) · 24.7 KB
/
st_constructors.py
File metadata and controls
696 lines (560 loc) · 24.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import inspect
import sys
from functools import partial
from typing import Optional, Union
from pyspark.sql import Column
from sedona.spark.sql.dataframe_api import (
ColumnOrName,
ColumnOrNameOrNumber,
call_sedona_function,
validate_argument_types,
)
_call_constructor_function = partial(call_sedona_function, "st_constructors")
@validate_argument_types
def ST_GeomFromGeoHash(
geohash: ColumnOrName, precision: Union[ColumnOrName, int]
) -> Column:
"""Generate a geometry column from a geohash column at a specified precision.
:param geohash: Geohash string column to generate from.
:type geohash: ColumnOrName
:param precision: Geohash precision to use, either an integer or an integer column.
:type precision: Union[ColumnOrName, int]
:return: Geometry column representing the supplied geohash and precision level.
:rtype: Column
"""
return _call_constructor_function("ST_GeomFromGeoHash", (geohash, precision))
@validate_argument_types
def ST_PointFromGeoHash(
geohash: ColumnOrName, precision: Optional[Union[ColumnOrName, int]] = None
) -> Column:
"""Generate a point column from a geohash column at a specified precision.
:param geohash: Geohash string column to generate from.
:type geohash: ColumnOrName
:param precision: Geohash precision to use, either an integer or an integer column.
:type precision: Union[ColumnOrName, int]
:return: Point column representing the supplied geohash and precision level.
:rtype: Column
"""
args = (geohash) if precision is None else (geohash, precision)
return _call_constructor_function("ST_PointFromGeoHash", args)
@validate_argument_types
def ST_GeomFromGeoJSON(geojson_string: ColumnOrName) -> Column:
"""Generate a geometry column from a GeoJSON string column.
:param geojson_string: GeoJSON string column to generate from.
:type geojson_string: ColumnOrName
:return: Geometry column representing the GeoJSON string.
:rtype: Column
"""
return _call_constructor_function("ST_GeomFromGeoJSON", geojson_string)
@validate_argument_types
def ST_GeomFromGML(gml_string: ColumnOrName) -> Column:
"""Generate a geometry column from a Geography Markup Language (GML) string column.
:param gml_string: GML string column to generate from.
:type gml_string: ColumnOrName
:return: Geometry column representing the GML string.
:rtype: Column
"""
return _call_constructor_function("ST_GeomFromGML", gml_string)
@validate_argument_types
def ST_GeomFromKML(kml_string: ColumnOrName) -> Column:
"""Generate a geometry column from a KML string column.
:param kml_string: KML string column to generate from.
:type kml_string: ColumnOrName
:return: Geometry column representing the KML string.
:rtype: Column
"""
return _call_constructor_function("ST_GeomFromKML", kml_string)
@validate_argument_types
def ST_GeomFromText(
wkt: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate a geometry column from a Well-Known Text (WKT) string column.
This is an alias of ST_GeomFromWKT.
:param wkt: WKT string column to generate from.
:type wkt: ColumnOrName
:return: Geometry column representing the WKT string.
:rtype: Column
"""
args = (wkt) if srid is None else (wkt, srid)
return _call_constructor_function("ST_GeomFromText", args)
@validate_argument_types
def ST_GeometryFromText(
wkt: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate a geometry column from a Well-Known Text (WKT) string column.
This is an alias of ST_GeomFromWKT.
:param wkt: WKT string column to generate from.
:type wkt: ColumnOrName
:return: Geometry column representing the WKT string.
:rtype: Column
"""
args = (wkt) if srid is None else (wkt, srid)
return _call_constructor_function("ST_GeometryFromText", args)
@validate_argument_types
def ST_GeomFromWKB(wkb: ColumnOrName) -> Column:
"""Generate a geometry column from a Well-Known Binary (WKB) binary column.
:param wkb: WKB binary column to generate from.
:type wkb: ColumnOrName
:return: Geometry column representing the WKB binary.
:rtype: Column
"""
return _call_constructor_function("ST_GeomFromWKB", wkb)
@validate_argument_types
def ST_GeomFromEWKB(wkb: ColumnOrName) -> Column:
"""Generate a geometry column from a Well-Known Binary (WKB) binary column.
:param wkb: WKB binary column to generate from.
:type wkb: ColumnOrName
:return: Geometry column representing the WKB binary.
:rtype: Column
"""
return _call_constructor_function("ST_GeomFromEWKB", wkb)
@validate_argument_types
def ST_GeomFromWKT(
wkt: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate a geometry column from a Well-Known Text (WKT) string column.
This is an alias of ST_GeomFromText.
:param wkt: WKT string column to generate from.
:type wkt: ColumnOrName
:return: Geometry column representing the WKT string.
:rtype: Column
"""
args = (wkt) if srid is None else (wkt, srid)
return _call_constructor_function("ST_GeomFromWKT", args)
@validate_argument_types
def ST_GeogFromWKT(
wkt: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate a geography column from a Well-Known Text (WKT) string column.
:param wkt: WKT string column to generate from.
:type wkt: ColumnOrName
:return: Geography column representing the WKT string.
:rtype: Column
"""
args = (wkt) if srid is None else (wkt, srid)
return _call_constructor_function("ST_GeogFromWKT", args)
@validate_argument_types
def ST_GeogFromText(
wkt: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate a geography column from a Well-Known Text (WKT) string column.
This is an alias of ST_GeogFromWKT.
:param wkt: WKT string column to generate from.
:type wkt: ColumnOrName
:return: Geography column representing the WKT string.
:rtype: Column
"""
args = (wkt) if srid is None else (wkt, srid)
return _call_constructor_function("ST_GeogFromText", args)
@validate_argument_types
def ST_GeogFromWKB(
wkb: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate a geography column from a Well-Known Binary (WKB) binary column.
:param wkb: WKB binary column to generate from.
:type wkb: ColumnOrName
:return: Geography column representing the WKB binary.
:rtype: Column
"""
args = (wkb) if srid is None else (wkb, srid)
return _call_constructor_function("ST_GeogFromWKB", args)
@validate_argument_types
def ST_GeogFromEWKB(wkb: ColumnOrName) -> Column:
"""Generate a geography column from an OGC Extended Well-Known Binary (EWKB) binary column.
:param wkb: EWKB binary column to generate from.
:type wkb: ColumnOrName
:return: Geography column representing the EWKB binary.
:rtype: Column
"""
return _call_constructor_function("ST_GeogFromEWKB", wkb)
@validate_argument_types
def ST_GeogFromEWKT(ewkt: ColumnOrName) -> Column:
"""Generate a geography column from an OGC Extended Well-Known Text (EWKT) string column.
:param ewkt: EWKT string column to generate from.
:type ewkt: ColumnOrName
:return: Geography column representing the EWKT string.
:rtype: Column
"""
return _call_constructor_function("ST_GeogFromEWKT", ewkt)
@validate_argument_types
def ST_GeogFromGeoHash(
geohash: ColumnOrName, precision: Optional[Union[ColumnOrName, int]] = None
) -> Column:
"""Generate a geography column from a geohash column at a specified precision.
:param geohash: Geohash string column to generate from.
:type geohash: ColumnOrName
:param precision: Geohash precision to use, either an integer or an integer column.
:type precision: Union[ColumnOrName, int]
:return: Geography column representing the supplied geohash and precision level.
:rtype: Column
"""
args = (geohash) if precision is None else (geohash, precision)
return _call_constructor_function("ST_GeogFromGeoHash", args)
@validate_argument_types
def ST_GeogCollFromText(
wkt: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate a GeometryCollection geography from a GeometryCollection WKT representation.
:param wkt: GeometryCollection WKT string column to generate from.
:type wkt: ColumnOrName
:param srid: SRID for the geography.
:type srid: ColumnOrNameOrNumber
:return: GeometryCollection geography generated from the wkt column.
:rtype: Column
"""
args = (wkt) if srid is None else (wkt, srid)
return _call_constructor_function("ST_GeogCollFromText", args)
@validate_argument_types
def ST_GeogToGeometry(geog: ColumnOrName) -> Column:
"""Convert a geography column into a geometry column.
:param geog: Geography column to convert.
:type geog: ColumnOrName
:return: Geometry column representing the geography.
:rtype: Column
"""
return _call_constructor_function("ST_GeogToGeometry", geog)
@validate_argument_types
def ST_GeomToGeography(geom: ColumnOrName) -> Column:
"""Convert a geometry column into a geography column.
:param geom: Geometry column to convert.
:type geom: ColumnOrName
:return: Geography column representing the geometry.
:rtype: Column
"""
return _call_constructor_function("ST_GeomToGeography", geom)
@validate_argument_types
def ST_GeomFromEWKT(ewkt: ColumnOrName) -> Column:
"""Generate a geometry column from a OGC Extended Well-Known Text (WKT) string column.
:param ewkt: OGC Extended WKT string column to generate from.
:type ewkt: ColumnOrName
:return: Geometry column representing the EWKT string.
:rtype: Column
"""
return _call_constructor_function("ST_GeomFromEWKT", ewkt)
@validate_argument_types
def ST_LineFromText(wkt: ColumnOrName) -> Column:
"""Generate linestring geometry from a linestring WKT representation.
:param wkt: Linestring WKT string column to generate from.
:type wkt: ColumnOrName
:return: Linestring geometry generated from the wkt column.
:rtype: Column
"""
return _call_constructor_function("ST_LineFromText", wkt)
@validate_argument_types
def ST_LineStringFromText(coords: ColumnOrName, delimiter: ColumnOrName) -> Column:
"""Generate a linestring geometry column from a list of coords separated by a delimiter
in a string column.
:param coords: String column containing a list of coords.
:type coords: ColumnOrName
:param delimiter: Delimiter that separates each coordinate in the coords column, a string constant must be wrapped as a string literal (using pyspark.sql.functions.lit).
:type delimiter: ColumnOrName
:return: Linestring geometry column generated from the list of coordinates.
:rtype: Column
"""
return _call_constructor_function("ST_LineStringFromText", (coords, delimiter))
@validate_argument_types
def ST_Point(x: ColumnOrNameOrNumber, y: ColumnOrNameOrNumber) -> Column:
"""Generates a 2D point geometry column from numeric values.
:param x: Either a number or numeric column representing the X coordinate of a point.
:type x: ColumnOrNameOrNumber
:param y: Either a number or numeric column representing the Y coordinate of a point.
:type y: ColumnOrNameOrNumber
:return: Point geometry column generated from the coordinate values.
:rtype: Column
"""
return _call_constructor_function("ST_Point", (x, y))
@validate_argument_types
def ST_PointZ(
x: ColumnOrNameOrNumber,
y: ColumnOrNameOrNumber,
z: ColumnOrNameOrNumber,
srid: Optional[ColumnOrNameOrNumber] = None,
) -> Column:
"""Generates a 3D point geometry column from numeric values.
:param x: Either a number or numeric column representing the X coordinate of a point.
:type x: ColumnOrNameOrNumber
:param y: Either a number or numeric column representing the Y coordinate of a point.
:type y: ColumnOrNameOrNumber
:param z: Either a number or numeric column representing the Z coordinate of a point, if None then a 2D point is generated, defaults to None
:type z: ColumnOrNameOrNumber
:param srid: The srid of the point. Defaults to 0 (unknown).
:type srid: Optional[ColumnOrNameOrNumber], optional
:return: Point geometry column generated from the coordinate values.
:rtype: Column
"""
args = (x, y, z) if srid is None else (x, y, z, srid)
return _call_constructor_function("ST_PointZ", args)
@validate_argument_types
def ST_PointM(
x: ColumnOrNameOrNumber,
y: ColumnOrNameOrNumber,
m: ColumnOrNameOrNumber,
srid: Optional[ColumnOrNameOrNumber] = None,
) -> Column:
"""Generates a 3D point geometry column from numeric values.
:param x: Either a number or numeric column representing the X coordinate of a point.
:type x: ColumnOrNameOrNumber
:param y: Either a number or numeric column representing the Y coordinate of a point.
:type y: ColumnOrNameOrNumber
:param z: Either a number or numeric column representing the Z coordinate of a point, if None then a 2D point is generated, defaults to None
:type z: ColumnOrNameOrNumber
:param srid: The srid of the point. Defaults to 0 (unknown).
:type srid: Optional[ColumnOrNameOrNumber], optional
:return: Point geometry column generated from the coordinate values.
:rtype: Column
"""
args = (x, y, m) if srid is None else (x, y, m, srid)
return _call_constructor_function("ST_PointM", args)
@validate_argument_types
def ST_PointZM(
x: ColumnOrNameOrNumber,
y: ColumnOrNameOrNumber,
z: ColumnOrNameOrNumber,
m: ColumnOrNameOrNumber,
srid: Optional[ColumnOrNameOrNumber] = None,
) -> Column:
"""Generates a 3D point geometry column from numeric values.
:param x: Either a number or numeric column representing the X coordinate of a point.
:type x: ColumnOrNameOrNumber
:param y: Either a number or numeric column representing the Y coordinate of a point.
:type y: ColumnOrNameOrNumber
:param z: Either a number or numeric column representing the Z coordinate of a point, if None then a 2D point is generated, defaults to None
:type z: ColumnOrNameOrNumber
:param m: Either a number or numeric column representing the M value of a point.
:type m: ColumnOrNameOrNumber
:param srid: The srid of the point. Defaults to 0 (unknown).
:type srid: Optional[ColumnOrNameOrNumber], optional
:return: Point geometry column generated from the coordinate values.
:rtype: Column
"""
args = (x, y, z, m) if srid is None else (x, y, z, m, srid)
return _call_constructor_function("ST_PointZM", args)
@validate_argument_types
def ST_PointFromText(coords: ColumnOrName, delimiter: ColumnOrName) -> Column:
"""Generate a point geometry column from coordinates separated by a delimiter and stored
in a string column.
:param coords: String column with the stored coordinates.
:type coords: ColumnOrName
:param delimiter: Delimiter separating the coordinates, a string constant must be wrapped as a string literal (using pyspark.sql.functions.lit).
:type delimiter: ColumnOrName
:return: Point geometry column generated from the coordinates.
:rtype: Column
"""
return _call_constructor_function("ST_PointFromText", (coords, delimiter))
@validate_argument_types
def ST_PointFromWKB(
wkb: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate a Point geometry column from a Well-Known Binary (WKB) binary column.
:param wkb: WKB binary column to generate from.
:type wkb: ColumnOrName
:param srid: SRID to be set for geometry
:type srid: ColumnOrNameOrNumber
:return: Point Geometry column representing the WKB binary.
:rtype: Column
"""
args = (wkb) if srid is None else (wkb, srid)
return _call_constructor_function("ST_PointFromWKB", args)
@validate_argument_types
def ST_LineFromWKB(
wkb: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate a Line geometry column from a Well-Known Binary (WKB) binary column.
:param wkb: WKB binary column to generate from.
:type wkb: ColumnOrName
:param srid: SRID to be set for the geometry.
:type srid: ColumnOrNameOrNumber
:return: Geometry column representing the WKB binary.
:rtype: Column
"""
args = (wkb) if srid is None else (wkb, srid)
return _call_constructor_function("ST_LineFromWKB", args)
@validate_argument_types
def ST_LinestringFromWKB(
wkb: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate a Line geometry column from a Well-Known Binary (WKB) binary column.
:param wkb: WKB binary column to generate from.
:type wkb: ColumnOrName
:param srid: SRID to be set for the geometry.
:type srid: ColumnOrNameOrNumber
:return: Geometry column representing the WKB binary.
:rtype: Column
"""
args = (wkb) if srid is None else (wkb, srid)
return _call_constructor_function("ST_LinestringFromWKB", args)
@validate_argument_types
def ST_MakePointM(
x: ColumnOrNameOrNumber, y: ColumnOrNameOrNumber, m: ColumnOrNameOrNumber
) -> Column:
"""Generate 3D M Point geometry.
:param x: Either a number or numeric column representing the X coordinate of a point.
:type x: ColumnOrNameOrNumber
:param y: Either a number or numeric column representing the Y coordinate of a point.
:type y: ColumnOrNameOrNumber
:param m: Either a number or numeric column representing the M coordinate of a point
:type m: ColumnOrNameOrNumber
:return: Point geometry column generated from the coordinate values.
:rtype: Column
"""
return _call_constructor_function("ST_MakePointM", (x, y, m))
@validate_argument_types
def ST_MakePoint(
x: ColumnOrNameOrNumber,
y: ColumnOrNameOrNumber,
z: Optional[ColumnOrNameOrNumber] = None,
m: Optional[ColumnOrNameOrNumber] = None,
) -> Column:
"""Generate a 2D, 3D Z or 4D ZM Point geometry. If z is None then a 2D point is generated.
This function doesn't support M coordinates for creating a 4D ZM Point in Dataframe API.
:param x: Either a number or numeric column representing the X coordinate of a point.
:type x: ColumnOrNameOrNumber
:param y: Either a number or numeric column representing the Y coordinate of a point.
:type y: ColumnOrNameOrNumber
:param z: Either a number or numeric column representing the Z coordinate of a point, if None then a 2D point is generated, defaults to None
:type z: ColumnOrNameOrNumber
:param m: Either a number or numeric column representing the M coordinate of a point, if None then a point without M coordinate is generated, defaults to None
:type m: ColumnOrNameOrNumber
:return: Point geometry column generated from the coordinate values.
:rtype: Column
"""
args = (x, y)
if z is not None:
args = args + (z,)
if m is not None:
args = args + (m,)
return _call_constructor_function("ST_MakePoint", (args))
@validate_argument_types
def ST_MakeEnvelope(
min_x: ColumnOrNameOrNumber,
min_y: ColumnOrNameOrNumber,
max_x: ColumnOrNameOrNumber,
max_y: ColumnOrNameOrNumber,
srid: Optional[ColumnOrNameOrNumber] = None,
) -> Column:
"""Generate a polygon geometry column from the minimum and maximum coordinates of an envelope with an option to add SRID
:param min_x: Minimum X coordinate for the envelope.
:type min_x: ColumnOrNameOrNumber
:param min_y: Minimum Y coordinate for the envelope.
:type min_y: ColumnOrNameOrNumber
:param max_x: Maximum X coordinate for the envelope.
:type max_x: ColumnOrNameOrNumber
:param max_y: Maximum Y coordinate for the envelope.
:type max_y: ColumnOrNameOrNumber
:param srid: SRID to be set for the envelope.
:type srid: ColumnOrNameOrNumber
:return: Polygon geometry column representing the envelope described by the coordinate bounds.
:rtype: Column
"""
args = (min_x, min_y, max_x, max_y, srid)
if srid is None:
args = (min_x, min_y, max_x, max_y)
return _call_constructor_function("ST_MakeEnvelope", args)
@validate_argument_types
def ST_PolygonFromEnvelope(
min_x: ColumnOrNameOrNumber,
min_y: ColumnOrNameOrNumber,
max_x: ColumnOrNameOrNumber,
max_y: ColumnOrNameOrNumber,
) -> Column:
"""Generate a polygon geometry column from the minimum and maximum coordinates of an envelope.
:param min_x: Minimum X coordinate for the envelope.
:type min_x: ColumnOrNameOrNumber
:param min_y: Minimum Y coordinate for the envelope.
:type min_y: ColumnOrNameOrNumber
:param max_x: Maximum X coordinate for the envelope.
:type max_x: ColumnOrNameOrNumber
:param max_y: Maximum Y coordinate for the envelope.
:type max_y: ColumnOrNameOrNumber
:return: Polygon geometry column representing the envelope described by the coordinate bounds.
:rtype: Column
"""
return _call_constructor_function(
"ST_PolygonFromEnvelope", (min_x, min_y, max_x, max_y)
)
@validate_argument_types
def ST_PolygonFromText(coords: ColumnOrName, delimiter: ColumnOrName) -> Column:
"""Generate a polygon from a list of coordinates separated by a delimiter stored
in a string column.
:param coords: String column containing the coordinates.
:type coords: ColumnOrName
:param delimiter: Delimiter separating the coordinates, a string constant must be wrapped as a string literal (using pyspark.sql.functions.lit).
:type delimiter: ColumnOrName
:return: Polygon geometry column generated from the list of coordinates.
:rtype: Column
"""
return _call_constructor_function("ST_PolygonFromText", (coords, delimiter))
@validate_argument_types
def ST_MPolyFromText(
wkt: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate multiPolygon geometry from a multiPolygon WKT representation.
:param wkt: multiPolygon WKT string column to generate from.
:type wkt: ColumnOrName
:return: multiPolygon geometry generated from the wkt column.
:rtype: Column
"""
args = (wkt) if srid is None else (wkt, srid)
return _call_constructor_function("ST_MPolyFromText", args)
@validate_argument_types
def ST_MLineFromText(
wkt: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate multiLineString geometry from a multiLineString WKT representation.
:param wkt: multiLineString WKT string column to generate from.
:type wkt: ColumnOrName
:return: multiLineString geometry generated from the wkt column.
:rtype: Column
"""
args = (wkt) if srid is None else (wkt, srid)
return _call_constructor_function("ST_MLineFromText", args)
@validate_argument_types
def ST_MPointFromText(
wkt: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate MultiPoint geometry from a MultiPoint WKT representation.
:param wkt: MultiPoint WKT string column to generate from.
:type wkt: ColumnOrName
:param srid: SRID for the geometry
:type srid: ColumnOrNameOrNumber
:return: MultiPoint geometry generated from the wkt column.
:rtype: Column
"""
args = (wkt) if srid is None else (wkt, srid)
return _call_constructor_function("ST_MPointFromText", args)
@validate_argument_types
def ST_GeomCollFromText(
wkt: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate GeometryCollection geometry from a GeometryCollection WKT representation.
:param wkt: GeometryCollection WKT string column to generate from.
:type wkt: ColumnOrName
:param srid: SRID for the geometry
:type srid: ColumnOrNameOrNumber
:return: GeometryCollection geometry generated from the wkt column.
:rtype: Column
"""
args = (wkt) if srid is None else (wkt, srid)
return _call_constructor_function("ST_GeomCollFromText", args)
# Automatically populate __all__
__all__ = [
name
for name, obj in inspect.getmembers(sys.modules[__name__])
if inspect.isfunction(obj)
]