@dataforsyningen/saul 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config.js.example +2 -2
- package/example.html +1 -1
- package/index.js +1 -1
- package/modules/api.js +4 -4
- package/modules/saul-core.js +1 -0
- package/package.json +6 -2
- package/test/saul-combined.test.js +1 -2
- package/test/saul-core.test.js +1 -1
- package/test/saul-elevation.test.js +1 -1
package/config.js.example
CHANGED
|
@@ -7,6 +7,6 @@ export default {
|
|
|
7
7
|
// DHM URL and auth can be aquired from https://datafordeler.dk/dataoversigt/danmarks-hoejdemodel-dhm/koter/
|
|
8
8
|
API_DHM_WCS_BASEURL: "https://services.datafordeler.dk/DHMNedboer/dhm_wcs/1.0.0/WCS",
|
|
9
9
|
API_DHM_BASEURL: "https://services.datafordeler.dk/DHMTerraen/DHMKoter/1.0.0/GEOREST/HentKoter",
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
API_DHM_TOKENA: "", // DHM API service username
|
|
11
|
+
API_DHM_TOKENB: "" // DHM API service password
|
|
12
12
|
}
|
package/example.html
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
<script type="module">
|
|
19
19
|
|
|
20
|
-
// You should add your own config.js with proper tokens,
|
|
20
|
+
// You should add your own config.js with proper tokens, etc.
|
|
21
21
|
// Check config.js.example for info on how to set it up
|
|
22
22
|
import auth from './config.js'
|
|
23
23
|
|
package/index.js
CHANGED
package/modules/api.js
CHANGED
|
@@ -154,11 +154,11 @@ function post(url, requestbody, token) {
|
|
|
154
154
|
/**
|
|
155
155
|
* API method to fetch data from DHM
|
|
156
156
|
* @param {string} query - DHM API query. Find details at https://datafordeler.dk/dataoversigt/danmarks-hoejdemodel-dhm/koter/
|
|
157
|
-
* @param {{API_DHM_BASEURL: string,
|
|
157
|
+
* @param {{API_DHM_BASEURL: string, API_DHM_TOKENA: string, API_DHM_TOKENB: string}} auth - API autentication data. See ../config.js.example for reference.
|
|
158
158
|
* @returns {object} Response data
|
|
159
159
|
*/
|
|
160
160
|
function getDHM(query, auth) {
|
|
161
|
-
const auth_params = `&username=${auth.
|
|
161
|
+
const auth_params = `&username=${auth.API_DHM_TOKENA}&password=${auth.API_DHM_TOKENB}`
|
|
162
162
|
return get(encodeURI(auth.API_DHM_BASEURL + query + auth_params))
|
|
163
163
|
.then((data) => data)
|
|
164
164
|
}
|
|
@@ -197,7 +197,7 @@ async function consumeGeoTIFF(raw_data) {
|
|
|
197
197
|
|
|
198
198
|
/** Fetches a GeoTIFF with elevation data matching the bounding box of a STAC API item (image)
|
|
199
199
|
* @param {object} stac_item - STAC API item from a featureCollection request
|
|
200
|
-
* @param {{API_DHM_WCS_BASEURL: string,
|
|
200
|
+
* @param {{API_DHM_WCS_BASEURL: string, API_DHM_TOKENA: string, API_DHM_TOKENB: string}} auth - API autentication data. See ../config.js.example for reference.
|
|
201
201
|
* @param {number} [resolution] - Resolution (1 - 0.01). Higher number means more pixels and better precision.
|
|
202
202
|
* @returns {object} GeoTiff data
|
|
203
203
|
*/
|
|
@@ -210,7 +210,7 @@ function getTerrainGeoTIFF(stac_item, auth, resolution = 0.05) {
|
|
|
210
210
|
// GET request for DHM WCS data
|
|
211
211
|
let url = auth.API_DHM_WCS_BASEURL
|
|
212
212
|
url += '?SERVICE=WCS&COVERAGE=dhm_terraen&RESPONSE_CRS=epsg:25832&CRS=epsg:25832&FORMAT=GTiff&REQUEST=GetCoverage&VERSION=1.0.0'
|
|
213
|
-
url += `&username=${ auth.
|
|
213
|
+
url += `&username=${ auth.API_DHM_TOKENA }&password=${ auth.API_DHM_TOKENB }`
|
|
214
214
|
url += `&height=${ height }`
|
|
215
215
|
url += `&width=${ width }`
|
|
216
216
|
url += `&bbox=${ bbox[0]},${ bbox[1]},${ bbox[2]},${ bbox[3]}`
|
package/modules/saul-core.js
CHANGED
|
@@ -217,6 +217,7 @@ async function compareZ(options) {
|
|
|
217
217
|
* @param {array} options.xy - image coordinates
|
|
218
218
|
* @param {object} options.image - STAC API item
|
|
219
219
|
* @param {object} options.terrain - GeoTIFF object from getTerrainGeoTIFF() output
|
|
220
|
+
* @param {number} precision - Precision in meters for "good enough"
|
|
220
221
|
* @returns {array} Array with world coordinates (indexes 0 and 1) and elevation (index 2). Coordinates are EPSG:25832 format.
|
|
221
222
|
*/
|
|
222
223
|
async function getWorldXYZ(options, precision = 0.3) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dataforsyningen/saul",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "This is a collection of stand-alone methods for photogrammetry calculations and API interactions for 'Danske Skråfotos'.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -17,7 +17,11 @@
|
|
|
17
17
|
"SDFI",
|
|
18
18
|
"saul"
|
|
19
19
|
],
|
|
20
|
-
"author":
|
|
20
|
+
"author": {
|
|
21
|
+
"name": "Styrelsen for Dataforsyning og Infrastruktur",
|
|
22
|
+
"email": "support@sdfi.dk",
|
|
23
|
+
"url": "https://sdfi.dk/"
|
|
24
|
+
},
|
|
21
25
|
"license": "MIT",
|
|
22
26
|
"bugs": {
|
|
23
27
|
"url": "https://github.com/SDFIdk/saul/issues"
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
// You should add your own config.js with proper tokens,
|
|
1
|
+
// You should add your own config.js with proper tokens, etc.
|
|
2
2
|
// Check config.js.example for info on how to set it up
|
|
3
3
|
import auth from '../config.js'
|
|
4
|
-
import assert from 'assert'
|
|
5
4
|
import { getSTAC, getTerrainGeoTIFF,getZ, getWorldXYZ, getImageXY } from '../index.js'
|
|
6
5
|
|
|
7
6
|
|
package/test/saul-core.test.js
CHANGED