Skip to content
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

[DOCS] Add example outputs to all Sedona functions - 7 #924

Merged
merged 19 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 166 additions & 26 deletions docs/api/flink/Constructor.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ Format: `ST_GeomFromGeoHash(geohash: string, precision: int)`
Since: `v1.2.1`

SQL example:

```sql
SELECT ST_GeomFromGeoHash('s00twy01mt', 4) AS geom
```

Output:

```
POLYGON ((0.703125 0.87890625, 0.703125 1.0546875, 1.0546875 1.0546875, 1.0546875 0.87890625, 0.703125 0.87890625))
```

## ST_GeomFromGeoJSON

Introduction: Construct a Geometry from GeoJson
Expand All @@ -20,9 +27,41 @@ Format: `ST_GeomFromGeoJSON (GeoJson:string)`
Since: `v1.2.0`

SQL example:

```sql
SELECT ST_GeomFromGeoJSON(polygontable._c0) AS polygonshape
FROM polygontable
SELECT ST_GeomFromGeoJSON('{
furqaankhan marked this conversation as resolved.
Show resolved Hide resolved
"type":"Feature",
"properties":{
"STATEFP":"01",
"COUNTYFP":"077",
"TRACTCE":"011501",
"BLKGRPCE":"5",
"AFFGEOID":"1500000US010770115015",
"GEOID":"010770115015",
"NAME":"5",
"LSAD":"BG",
"ALAND":6844991,
"AWATER":32636
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[-87.621765, 34.873444],
[-87.617535, 34.873369],
[-87.62119, 34.85053],
[-87.62144, 34.865379],
[-87.621765, 34.873444]
]
]
}
}')
```

Output:

```
POLYGON ((-87.621765 34.873444, -87.617535 34.873369, -87.62119 34.85053, -87.62144 34.865379, -87.621765 34.873444))
```

## ST_GeomFromGML
Expand All @@ -35,8 +74,23 @@ Format:
Since: `v1.3.0`

SQL example:

```sql
SELECT ST_GeomFromGML('<gml:LineString srsName="EPSG:4269"><gml:coordinates>-71.16028,42.258729 -71.160837,42.259112 -71.161143,42.25932</gml:coordinates></gml:LineString>') AS geometry
SELECT ST_GeomFromGML('
<gml:LineString srsName="EPSG:4269">
<gml:coordinates>
-71.16028,42.258729
-71.160837,42.259112
-71.161143,42.25932
</gml:coordinates>
</gml:LineString>
')
```

Output:

```
LINESTRING (-71.16028 42.258729, -71.160837 42.259112, -71.161143 42.25932)
```

## ST_GeomFromKML
Expand All @@ -49,22 +103,43 @@ Format:
Since: `v1.3.0`

SQL example:

```sql
SELECT ST_GeomFromKML('<LineString><coordinates>-71.1663,42.2614 -71.1667,42.2616</coordinates></LineString>') AS geometry
SELECT ST_GeomFromKML('
<LineString>
<coordinates>
-71.1663,42.2614
-71.1667,42.2616
</coordinates>
</LineString>
')
```

Output:

```
LINESTRING (-71.1663 42.2614, -71.1667 42.2616)
```

## ST_GeomFromText

Introduction: Construct a Geometry from Wkt. Alias of [ST_GeomFromWKT](#ST_GeomFromWKT)
Introduction: Construct a Geometry from WKT. Alias of [ST_GeomFromWKT](#ST_GeomFromWKT)

Format:
`ST_GeomFromText (Wkt:string)`

Since: `v1.2.1`

SQL example:

```sql
SELECT ST_GeomFromText('POINT(40.7128 -74.0060)') AS geometry
SELECT ST_GeomFromText('POINT(40.7128 -74.0060)')
```

Output:

```
POINT(40.7128 -74.006)
```

## ST_GeomFromWKB
furqaankhan marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -96,7 +171,7 @@ FROM polygontable

## ST_GeomFromWKT

Introduction: Construct a Geometry from Wkt
Introduction: Construct a Geometry from WKT

Format:
`ST_GeomFromWKT (Wkt:string)`
Expand All @@ -105,20 +180,32 @@ Since: `v1.2.0`

SQL example:
```sql
SELECT ST_GeomFromWKT('POINT(40.7128 -74.0060)') AS geometry
SELECT ST_GeomFromWKT('POINT(40.7128 -74.0060)')
```

Output:

```
POINT(40.7128 -74.006)
```

## ST_LineFromText

Introduction: Construct a LineString from Text, delimited by Delimiter (Optional)
Introduction: Construct a LineString from Text

Format: `ST_LineFromText (Text:string, Delimiter:char)`
Format: `ST_LineFromText (Text:string)`

Since: `v1.2.1`

SQL example:
```sql
SELECT ST_LineFromText('Linestring(1 2, 3 4)') AS line
SELECT ST_LineFromText('Linestring(1 2, 3 4)')
```

Output:

```
LINESTRING (1 2, 3 4)
```

## ST_LineStringFromText
Expand All @@ -129,9 +216,16 @@ Format: `ST_LineStringFromText (Text:string, Delimiter:char)`

Since: `v1.2.1`

Spark SQL example:
Example:

```sql
SELECT ST_LineStringFromText('Linestring(1 2, 3 4)') AS line
SELECT ST_LineStringFromText('-74.0428197,40.6867969,-74.0421975,40.6921336,-74.0508020,40.6912794', ',')
```

Output:

```
LINESTRING (-74.0428197 40.6867969, -74.0421975 40.6921336, -74.050802 40.6912794)
```

## ST_MLineFromText
Expand All @@ -143,9 +237,15 @@ Format: `ST_MLineFromText (Text:string, Srid: int)`
Since: `1.3.1`

SQL example:

```sql
SELECT ST_MLineFromText('MULTILINESTRING((1 2, 3 4), (4 5, 6 7))') AS multiLine
SELECT ST_MLineFromText('MULTILINESTRING((1 2, 3 4), (4 5, 6 7))', 4269) AS multiLine
SELECT ST_MLineFromText('MULTILINESTRING((1 2, 3 4), (4 5, 6 7))')
```

Output:

```
MULTILINESTRING ((1 2, 3 4), (4 5, 6 7))
```

## ST_MPolyFromText
Expand All @@ -157,9 +257,15 @@ Format: `ST_MPolyFromText (Text:string, Srid: int)`
Since: `1.3.1`

SQL example:

```sql
SELECT ST_MPolyFromText('MULTIPOLYGON(((-70.916 42.1002,-70.9468 42.0946,-70.9765 42.0872 )))') AS multiPolygon
SELECT ST_MPolyFromText('MULTIPOLYGON(((-70.916 42.1002,-70.9468 42.0946,-70.9765 42.0872 )))', 4269) AS multiPolygon
SELECT ST_MPolyFromText('MULTIPOLYGON(((0 0 1,20 0 1,20 20 1,0 20 1,0 0 1),(5 5 3,5 7 3,7 7 3,7 5 3,5 5 3)))')
```

Output:

```
MULTIPOLYGON (((0 0, 20 0, 20 20, 0 20, 0 0), (5 5, 5 7, 7 7, 7 5, 5 5)))
```

## ST_Point
Expand All @@ -171,23 +277,38 @@ Format: `ST_Point (X:decimal, Y:decimal)`
Since: `v1.2.1`

SQL example:

```sql
SELECT ST_Point(x, y) AS pointshape
FROM pointtable
SELECT ST_Point(double(1.2345), 2.3456)
```

Output:

```
POINT (1.2345 2.3456)
```

## ST_PointZ

Introduction: Construct a Point from X, Y and Z and an optional srid. If srid is not set, it defaults to 0 (unknown).
Introduction: Construct a Point from X, Y and Z and an optional srid. If srid is not set, it defaults to 0 (unknown).
Must use ST_AsEWKT function to print the Z coordinate.

Format: `ST_PointZ (X:decimal, Y:decimal, Z:decimal)`

Format: `ST_PointZ (X:decimal, Y:decimal, Z:decimal, srid:integer)`

Since: `v1.5.0`

SQL example:

```sql
SELECT ST_PointZ(1.0, 2.0, 3.0) AS pointshape
SELECT ST_AsEWKT(ST_PointZ(1.2345, 2.3456, 3.4567))
```

Output:

```
POINT Z(1.2345 2.3456 3.4567)
```

## ST_PointFromText
Expand All @@ -199,8 +320,15 @@ Format: `ST_PointFromText (Text:string, Delimiter:char)`
Since: `v1.2.0`

SQL example:

```sql
SELECT ST_PointFromText('40.7128,-74.0060', ',') AS pointshape
SELECT ST_PointFromText('40.7128,-74.0060', ',')
```

Output:

```
POINT (40.7128 -74.006)
```

## ST_PolygonFromEnvelope
Expand All @@ -212,10 +340,15 @@ Format: `ST_PolygonFromEnvelope (MinX:decimal, MinY:decimal, MaxX:decimal, MaxY:
Since: `v1.2.0`

SQL example:

```sql
SELECT *
FROM pointdf
WHERE ST_Contains(ST_PolygonFromEnvelope(1.0,100.0,1000.0,1100.0), pointdf.pointshape)
SELECT ST_PolygonFromEnvelope(double(1.234),double(2.234),double(3.345),double(3.345))
```

Output:

```
POLYGON ((1.234 2.234, 1.234 3.345, 3.345 3.345, 3.345 2.234, 1.234 2.234))
```

## ST_PolygonFromText
Expand All @@ -227,6 +360,13 @@ Format: `ST_PolygonFromText (Text:string, Delimiter:char)`
Since: `v1.2.0`

SQL example:

```sql
SELECT ST_PolygonFromText('-74.0428197,40.6867969,-74.0421975,40.6921336,-74.0508020,40.6912794,-74.0428197,40.6867969', ',') AS polygonshape
SELECT ST_PolygonFromText('-74.0428197,40.6867969,-74.0421975,40.6921336,-74.0508020,40.6912794,-74.0428197,40.6867969', ',')
```

Output:

```
POLYGON ((-74.0428197 40.6867969, -74.0421975 40.6921336, -74.050802 40.6912794, -74.0428197 40.6867969))
```
Loading