-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.html
58 lines (41 loc) · 1.74 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Saul modules example page</title>
</head>
<body>
<h1>Saul modules example</h1>
<p>Just opening this example.html file might not work becuase of CORS restrictions when trying to access STAC API.</p>
<p>You should run this HTML file from a simple server like Python's <code>http.server</code></p>
<h2>This is the result</h2>
<div id="result"></div>
<script type="module">
// You should add your own config.js with proper tokens, etc.
// Check config.js.example for info on how to set it up
import auth from './config.js'
import {image2world, world2image, getZ, iterate} from './modules/saul-core.js'
import {getSTAC} from './modules/api.js'
let xcoor = 579782.75
let ycoor = 6131096.03
const result_display_element = document.getElementById('result')
let apidata = await getSTAC('/collections/skraafotos2019/items/2019_83_37_2_0046_00001113', auth)
// Let's call an imported method
let zcoor = await getZ(xcoor, ycoor, auth)
let image_coor = world2image(apidata, xcoor, ycoor, zcoor)
let col = image_coor[0]
let row = image_coor[1]
let world_coor = image2world(apidata, col, row, zcoor)
col = 7375
row = 5382
let ite = await iterate(apidata, col, row, auth, 0.05)
// Write out result for the user to see
if (image_coor) {
result.innerText = xcoor + ' ' + ycoor + ' ' + zcoor + '\n' + image_coor[0] + ' ' + image_coor[1] + '\n' +ite
} else {
result.innerText = 'There was no result'
}
</script>
</body>
</html>