From 1b9c91fd87f888c6718a79b52f376598dcd84f68 Mon Sep 17 00:00:00 2001 From: Elena Date: Tue, 29 Aug 2023 17:36:44 +0200 Subject: [PATCH 1/3] Added documentation for wkt functions --- docs/triply-etl/transform/ratt/index.md | 106 ++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/docs/triply-etl/transform/ratt/index.md b/docs/triply-etl/transform/ratt/index.md index cff93d98..01e4c220 100644 --- a/docs/triply-etl/transform/ratt/index.md +++ b/docs/triply-etl/transform/ratt/index.md @@ -1433,3 +1433,109 @@ 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()` {#wkt.addPoint()} + +## Description + +Creates from the geospatial point the corresponding Well-Known Text (WKT) serialization strings. + +## 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 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()` {#wkt.project()} + +## 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 now can 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 +``` \ No newline at end of file From 61895932b1953fddcaabcdb3a6594c0a941dd4ff Mon Sep 17 00:00:00 2001 From: Elena Date: Wed, 30 Aug 2023 13:45:08 +0200 Subject: [PATCH 2/3] Fixed docs --- docs/triply-etl/transform/ratt/index.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/triply-etl/transform/ratt/index.md b/docs/triply-etl/transform/ratt/index.md index 01e4c220..cfeacfff 100644 --- a/docs/triply-etl/transform/ratt/index.md +++ b/docs/triply-etl/transform/ratt/index.md @@ -1439,7 +1439,7 @@ We do not have a good example for this transformation middleware yet. Let us kno ## Description -Creates from the geospatial point the corresponding Well-Known Text (WKT) serialization strings. +Creates from the geospatial point the corresponding Well-Known Text (WKT) serialization string. ## Parameters @@ -1449,10 +1449,9 @@ Creates from the geospatial point the corresponding Well-Known Text (WKT) serial - `key` A new key where the WKT string is stored. ## Example -The following example creates a WKT literal from geo coordinates of Amsterdam: +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', @@ -1504,12 +1503,12 @@ The following example converts an array with latitude and longitude in `content` ```ts fromJson({ place: 'Amsterdam', lat: 121307, long: 487360 }), - wkt.project({ - content: ['lat', 'long'], - key: '_coordinates', - fromCrs: epsg[666], - toCrs: epsg[4326] - }), +wkt.project({ + content: ['lat', 'long'], + key: '_coordinates', + fromCrs: epsg[666], + toCrs: epsg[4326] + }), ``` From 8979171e967a6c90c20dbf270dd9f57f04d7f593 Mon Sep 17 00:00:00 2001 From: Elena Date: Fri, 1 Sep 2023 16:09:28 +0200 Subject: [PATCH 3/3] Updated according to the feedback --- docs/triply-etl/transform/ratt/index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/triply-etl/transform/ratt/index.md b/docs/triply-etl/transform/ratt/index.md index cfeacfff..51a0df7b 100644 --- a/docs/triply-etl/transform/ratt/index.md +++ b/docs/triply-etl/transform/ratt/index.md @@ -1435,11 +1435,11 @@ This middleware can uppercase strings in any language; the Unicode Default Case 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()` {#wkt.addPoint()} +# Function `wkt.addPoint()` {#wktAddPoint()} ## Description -Creates from the geospatial point the corresponding Well-Known Text (WKT) serialization string. +Creates a Well-Known Text (WKT) serialization string from the corresponding geospatial point. ## Parameters @@ -1485,7 +1485,7 @@ city:Amstedam geo:asWKT "Point (52.37308 4.89245)"^^geo:wktLiteral ``` -# Function `wkt.project()` {#wkt.project()} +# Function `wkt.project()` {#wktProject()} ## Description @@ -1522,7 +1522,7 @@ This results in the following record of the key `'_coordinates'`: ] } ``` -We now can use the converted result to create a WKT `Point()` using [addPoint()](#function-wktaddpoint-wktaddpoint): +We can now use the converted result to create a WKT `Point()` using [addPoint()](#function-wktaddpoint-wktaddpoint): ```ts wkt.addPoint({