2019-07-14 20:37:26 +02:00
|
|
|
<html lang="en">
|
2019-07-16 17:31:20 +02:00
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8" />
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
2019-07-14 20:37:26 +02:00
|
|
|
<title>Document</title>
|
2019-07-16 17:31:20 +02:00
|
|
|
</head>
|
2019-07-14 20:37:26 +02:00
|
|
|
|
2019-07-16 17:31:20 +02:00
|
|
|
<body>
|
2019-07-14 20:37:26 +02:00
|
|
|
<div>Original array: <span id="src">Loading...</span></div>
|
|
|
|
<div>Simplified array: <span id="dest">Loading...</span></div>
|
2019-07-16 17:31:20 +02:00
|
|
|
|
2019-07-14 20:37:26 +02:00
|
|
|
<script type="module">
|
2019-07-16 17:31:20 +02:00
|
|
|
import moduleFactory from './simplify.js'
|
|
|
|
import {
|
|
|
|
storeCoords,
|
|
|
|
loadResultAndFreeMemory
|
|
|
|
} from '../wasm-util/coordinates.js'
|
2019-07-14 20:37:26 +02:00
|
|
|
|
2019-07-16 17:31:20 +02:00
|
|
|
const module = moduleFactory()
|
|
|
|
const data = [
|
|
|
|
[0, 0],
|
|
|
|
[1, 1],
|
|
|
|
[1, 2],
|
|
|
|
[2, 2],
|
|
|
|
[5, 5],
|
|
|
|
[5, 0],
|
|
|
|
[6, 10],
|
|
|
|
[10, 10]
|
|
|
|
]
|
|
|
|
document.getElementById('src').innerText = JSON.stringify(data)
|
2019-07-14 20:37:26 +02:00
|
|
|
|
2019-07-16 17:31:20 +02:00
|
|
|
module.onRuntimeInitialized = async _ => {
|
|
|
|
const buffer = storeCoords(module, data)
|
|
|
|
const result = module._simplify(buffer, data.length * 2, 2, false)
|
|
|
|
module._free(buffer)
|
|
|
|
const simplified = loadResultAndFreeMemory(module, result)
|
|
|
|
document.getElementById('dest').innerText = JSON.stringify(simplified)
|
|
|
|
}
|
2019-07-14 20:37:26 +02:00
|
|
|
</script>
|
2019-07-16 17:31:20 +02:00
|
|
|
</body>
|
|
|
|
</html>
|