Skip to content

Commit

Permalink
[DOCS] Add example outputs to all Sedona functions - 10 (#930)
Browse files Browse the repository at this point in the history
  • Loading branch information
furqaankhan authored Jul 28, 2023
1 parent 81582e6 commit e668e30
Show file tree
Hide file tree
Showing 2 changed files with 193 additions and 115 deletions.
156 changes: 97 additions & 59 deletions docs/api/flink/Function.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,40 +169,38 @@ Since: `1.5.0`
Example:

```sql
ST_Angle(p1, p2, p3, p4)
SELECT ST_Angle(ST_GeomFromWKT('POINT(0 0)'), ST_GeomFromWKT('POINT (1 1)'), ST_GeomFromWKT('POINT(1 0)'), ST_GeomFromWKT('POINT(6 2)'))
```

Input: `p1: POINT (0 0)`

Input: `p2: POINT (1 1)`

Input: `p3: POINT (1 0)`
Output:

Input: `p4: POINT(6 2)`
```
0.4048917862850834
```

Output: 0.4048917862850834
Example:

```sql
ST_Angle(p1, p2, p3)
SELECT ST_Angle(ST_GeomFromWKT('POINT (1 1)'), ST_GeomFromWKT('POINT (0 0)'), ST_GeomFromWKT('POINT(3 2)'))
```

Input: `p1: POINT (1 1)`

Input: `p2: POINT (0 0)`
Output:

Input: `p3: POINT(3 2)`
```
0.19739555984988044
```

Output: 0.19739555984988044
Example:

```sql
ST_Angle(line1, line2)
SELECT ST_Angle(ST_GeomFromWKT('LINESTRING (0 0, 1 1)'), ST_GeomFromWKT('LINESTRING (0 0, 3 2)'))
```

Input: `line1: LINESTRING (0 0, 1 1)`

Input: `line2: LINESTRING (0 0, 3 2)`
Output:

Output: 0.19739555984988044
```
0.19739555984988044
```

## ST_Area

Expand Down Expand Up @@ -1007,34 +1005,38 @@ Since: `1.4.1`
Example:

```sql
SELECT ST_Force3D(df.geometry) AS geom
from df
SELECT ST_AsText(ST_Force3D(ST_GeomFromText('POLYGON((0 0 2,0 5 2,5 0 2,0 0 2),(1 1 2,3 1 2,1 3 2,1 1 2))'), 2.3))
```

Input: `LINESTRING(0 1, 1 2, 2 1)`

Output: `LINESTRING Z(0 1 0, 1 2 0, 2 1 0)`
Output:

Input: `POLYGON((0 0 2,0 5 2,5 0 2,0 0 2),(1 1 2,3 1 2,1 3 2,1 1 2))`
```
POLYGON Z((0 0 2, 0 5 2, 5 0 2, 0 0 2), (1 1 2, 3 1 2, 1 3 2, 1 1 2))
```

Output: `POLYGON Z((0 0 2,0 5 2,5 0 2,0 0 2),(1 1 2,3 1 2,1 3 2,1 1 2))`
Example:

```sql
SELECT ST_Force3D(df.geometry, 2.3) AS geom
from df
SELECT ST_AsText(ST_Force3D(ST_GeomFromText('LINESTRING(0 1,1 0,2 0)'), 2.3))
```

Input: `LINESTRING(0 1, 1 2, 2 1)`
Output:

Output: `LINESTRING Z(0 1 2.3, 1 2 2.3, 2 1 2.3)`
```
LINESTRING Z(0 1 2.3, 1 0 2.3, 2 0 2.3)
```

Input: `POLYGON((0 0 2,0 5 2,5 0 2,0 0 2),(1 1 2,3 1 2,1 3 2,1 1 2))`
Example:

Output: `POLYGON Z((0 0 2,0 5 2,5 0 2,0 0 2),(1 1 2,3 1 2,1 3 2,1 1 2))`
```sql
SELECT ST_AsText(ST_Force3D(ST_GeomFromText('LINESTRING EMPTY'), 3))
```

Input: `LINESTRING EMPTY`
Output:

Output: `LINESTRING EMPTY`
```
LINESTRING EMPTY
```

## ST_FrechetDistance

Expand All @@ -1048,13 +1050,16 @@ Format: `ST_FrechetDistance(g1: geomtry, g2: geometry)`
Since: `1.5.0`

Example:

```sql
SELECT ST_FrechetDistance(g1, g2)
SELECT ST_FrechetDistance(ST_GeomFromWKT('POINT (0 1)'), ST_GeomFromWKT('LINESTRING (0 0, 1 0, 2 0, 3 0, 4 0, 5 0)'))
```

Input: `g1: POINT (0 1), g2: LINESTRING (0 0, 1 0, 2 0, 3 0, 4 0, 5 0)`
Output:

Output: `5.0990195135927845`
```
5.0990195135927845
```

## ST_GeoHash

Expand Down Expand Up @@ -1169,21 +1174,28 @@ Format: `ST_HausdorffDistance(g1: geometry, g2: geometry, densityFrac)`
Since: `v1.5.0`

Example:

```sql
SELECT ST_HausdorffDistance(g1, g2, 0.1)
SELECT ST_HausdorffDistance(ST_GeomFromWKT('POINT (0.0 1.0)'), ST_GeomFromWKT('LINESTRING (0 0, 1 0, 2 0, 3 0, 4 0, 5 0)'), 0.1)
```

Input: `g1: POINT (0.0 1.0), g2: LINESTRING (0 0, 1 0, 2 0, 3 0, 4 0, 5 0)`
Output:

```
5.0990195135927845
```

Output: `5.0990195135927845`
Example:

```sql
SELECT ST_HausdorffDistance(ST_GeomFromText(), ST_GeomFromText())
SELECT ST_HausdorffDistance(ST_GeomFromText('POLYGON Z((1 0 1, 1 1 2, 2 1 5, 2 0 1, 1 0 1))'), ST_GeomFromText('POLYGON Z((4 0 4, 6 1 4, 6 4 9, 6 1 3, 4 0 4))'))
```

Input: `g1: POLYGON Z((1 0 1, 1 1 2, 2 1 5, 2 0 1, 1 0 1)), g2: POLYGON Z((4 0 4, 6 1 4, 6 4 9, 6 1 3, 4 0 4))`
Output:

Output: `5.0`
```
5.0
```


## ST_InteriorRingN
Expand Down Expand Up @@ -1952,9 +1964,15 @@ Format: `ST_SetSRID (A:geometry, srid: integer)`
Since: `v1.3.0`

Example:

```sql
SELECT ST_SetSRID(polygondf.countyshape, 3021)
FROM polygondf
SELECT ST_AsEWKT(ST_SetSRID(ST_GeomFromWKT('POLYGON((1 1, 8 1, 8 8, 1 8, 1 1))'), 3021))
```

Output:

```
SRID=3021;POLYGON ((1 1, 8 1, 8 8, 1 8, 1 1))
```

## ST_SRID
Expand All @@ -1966,9 +1984,15 @@ Format: `ST_SRID (A:geometry)`
Since: `v1.3.0`

Example:

```sql
SELECT ST_SRID(polygondf.countyshape)
FROM polygondf
SELECT ST_SRID(ST_SetSRID(ST_GeomFromWKT('POLYGON((1 1, 8 1, 8 8, 1 8, 1 1))'), 3021))
```

Output:

```
3021
```

## ST_SimplifyPreserveTopology
Expand Down Expand Up @@ -2103,16 +2127,16 @@ Format: `ST_Transform (A:geometry, SourceCRS:string, TargetCRS:string ,[Optional

Since: `v1.2.0`

Example (simple):
Example:

```sql
SELECT ST_Transform(polygondf.countyshape, 'epsg:4326','epsg:3857')
FROM polygondf
SELECT ST_AsText(ST_Transform(ST_GeomFromText('POLYGON((170 50,170 72,-130 72,-130 50,170 50))'),'EPSG:4326', 'EPSG:32649', false))
```

Example (with optional parameters):
```sql
SELECT ST_Transform(polygondf.countyshape, 'epsg:4326','epsg:3857', false)
FROM polygondf
Output:

```
POLYGON ((8766047.980342899 17809098.336766362, 5122546.516721856 18580261.912528664, 3240775.0740796793 -13688660.50985159, 4556241.924514083 -12463044.21488129, 8766047.980342899 17809098.336766362))
```

!!!note
Expand All @@ -2131,15 +2155,29 @@ Format: `ST_Translate(geometry: geometry, deltaX: deltaX, deltaY: deltaY, deltaZ

Since: `1.4.1`

Example:
Example:

Input: `ST_Translate(GEOMETRYCOLLECTION(MULTIPOLYGON (((1 0, 1 1, 2 1, 2 0, 1 0)), ((1 2, 3 4, 3 5, 1 2))), POINT(1, 1, 1), LINESTRING EMPTY), 2, 2, 3)`
```sql
SELECT ST_Translate(ST_GeomFromText('GEOMETRYCOLLECTION(MULTIPOLYGON(((3 2,3 3,4 3,4 2,3 2)),((3 4,5 6,5 7,3 4))), POINT(1 1 1), LINESTRING EMPTY)'), 2, 2, 3)
```

Output: `GEOMETRYCOLLECTION(MULTIPOLYGON (((3 2, 3 3, 4 3, 4 2, 3 2)), ((3 4, 5 6, 5 7, 3 4))), POINT(3, 3, 4), LINESTRING EMPTY)`
Output:

Input: `ST_Translate(POINT(1, 3, 2), 1, 2)`
```
GEOMETRYCOLLECTION (MULTIPOLYGON (((5 4, 5 5, 6 5, 6 4, 5 4)), ((5 6, 7 8, 7 9, 5 6))), POINT (3 3), LINESTRING EMPTY)
```

Output: `POINT(2, 5, 2)`
Example:

```sql
SELECT ST_Translate(ST_GeomFromText('POINT(-71.01 42.37)'),1,2)
```

Output:

```
POINT (-70.01 44.37)
```



Expand Down
Loading

0 comments on commit e668e30

Please sign in to comment.