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

Added documentation for wkt functions #89

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
105 changes: 105 additions & 0 deletions docs/triply-etl/transform/ratt/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1433,3 +1433,108 @@ This middleware can uppercase strings in any language; the Unicode Default Case
## Example

We do not have a good example for this transformation middleware yet. Let us know in case you have a good example!


# Function `wkt.addPoint()` {#wktAddPoint()}

## Description

Creates a Well-Known Text (WKT) serialization string from the corresponding geospatial point.

## Parameters

- `latitude` A key or a string assertion ([str()](/docs/triply-etl/assert/ratt#str)) with latitude.
- `longitude` A key or a string assertion ([str()](/docs/triply-etl/assert/ratt#str)) with longitude.
- `crs` Optionally, an IRI that denotes a Coordinate Reference System (CRS). You can use IRIs from the [`epsg`](/docs/triply-etl/declare#geospatial-declarations) object. If absent, uses [EPSG:4326/WGS84](https://epsg.io/4326) as the CRS.
- `key` A new key where the WKT string is stored.

## Example
The following example creates a WKT literal from the geo coordinates of Amsterdam:
```ts
fromJson({ place: 'Amsterdam', lat: 52.37308, long: 4.89245 }),
wkt.addPoint({
latitude: 'lat',
longitude: 'long',
key: '_point'
}),

triple(iri(prefix.city, 'place'), geo.asWKT, '_point'),
```
This results in the following record of the key `'_point'`:

```json
{
"_point": {
"termType": "Literal",
"value": "Point (52.37308 4.89245)",
"language": "",
"datatype": {
"termType": "NamedNode",
"value": "http://www.opengis.net/ont/geosparql#wktLiteral",
"validationStatus": "canonical"
},
"validationStatus": "canonical"
}
}

```

And in the following linked data assertion:
```
city:Amstedam geo:asWKT "Point (52.37308 4.89245)"^^geo:wktLiteral
```


# Function `wkt.project()` {#wktProject()}

## Description

Converts the projection of a Well-Known Text (WKT) literal from one Coordinate Reference System to another one.

## Parameters

- `content` An array of keys or numbers.
- `key` A new key where the new projection is stored.
- `fromCrs`: an IRI that denotes a Coordinate Reference System (CRS) of the `content`.
- `toCrs`: Optionally, an IRI that denotes a Coordinate Reference System (CRS) we want to convert to. If absent, uses [EPSG:4326/WGS84](https://epsg.io/4326) as the CRS.

## Example
The following example converts an array with latitude and longitude in `content` key from Dutch grid coordinates (Rijksdriehoeks-coordinates) to WGS84 coordinates.

```ts
fromJson({ place: 'Amsterdam', lat: 121307, long: 487360 }),
wkt.project({
content: ['lat', 'long'],
key: '_coordinates',
fromCrs: epsg[666],
toCrs: epsg[4326]
}),

```

This results in the following record of the key `'_coordinates'`:

```json
{
"_coordinates": [
4.892803721020475,
52.374671935135474
]
}
```
We can now use the converted result to create a WKT `Point()` using [addPoint()](#function-wktaddpoint-wktaddpoint):

```ts
wkt.addPoint({
latitude: '_coordinates[0]',
longitude: '_coordinates[1]',
key: '_point'
}),

triple(iri(prefix.id, 'place'), geo.asWKT, '_point')
```
This code snippet creates the following linked data assertion:

```turtle
city:Amstedam geo:asWKT "Point (4.892803721020475 52.374671935135474)"^^geo:asWKT
```