spl.js 0.1.0-beta.8 → 0.1.0-rc.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/Makefile +54 -57
- package/README.md +6 -27
- package/dist/index.js +53 -2
- package/dist/index.mjs +43 -0
- package/dist/{spl.wasm → index.wasm} +0 -0
- package/dist/proj/proj.db +0 -0
- package/dist/proj/proj.ini +10 -0
- package/dist/proj/projjson.schema.json +31 -5
- package/dist/spl-node.mjs +1 -0
- package/dist/spl-web.js +2 -0
- package/examples/extensions.html +45 -45
- package/examples/lib/index.js +38 -0
- package/examples/lib/lib.js +456 -0
- package/examples/lib/ol.css +345 -0
- package/examples/lib/package-lock.json +2291 -0
- package/examples/lib/package.json +26 -0
- package/examples/lib/rollup.config.js +17 -0
- package/examples/lights-performance.html +240 -250
- package/examples/openlayers.html +76 -75
- package/examples/topology.html +3 -4
- package/package.json +19 -20
- package/rollup.config.node.js +16 -11
- package/rollup.config.web.js +5 -12
- package/rollup.config.worker.js +6 -10
- package/scripts/stringify.js +3 -3
- package/src/index.js +53 -0
- package/src/index.mjs +43 -0
- package/src/{result.ts → result.js} +2 -4
- package/src/spl-node.mjs +3 -0
- package/src/{spl-web.ts → spl-web.js} +42 -22
- package/src/{spl-worker.ts → spl-worker.js} +12 -5
- package/src/{spl.ts → spl.js} +96 -73
- package/test/browser.js +4 -87
- package/test/electron.js +8 -3
- package/test/files/tmp/memory_and_local_dbs_1.db +0 -0
- package/test/files/tmp/save_and_load_from_to_memory.db +0 -0
- package/test/node.js +39 -42
- package/dist/index.d.ts +0 -54
- package/dist/spl.d.ts +0 -46
- package/dist/spl.js +0 -1
- package/src/interfaces.ts +0 -85
- package/src/spl-node.ts +0 -4
- package/src/spl-web.d.ts +0 -54
- package/src/spl.d.ts +0 -46
- package/tsconfig.json +0 -9
- package/tslint.json +0 -126
- /package/examples/{lights.zip → data/lights.zip} +0 -0
- /package/examples/{world.json → data/world.json} +0 -0
package/examples/extensions.html
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Extensions</title>
|
|
6
|
+
<style>
|
|
7
|
+
canvas {
|
|
8
|
+
display: block;
|
|
9
|
+
margin: 0 auto;
|
|
10
|
+
}
|
|
11
|
+
</style>
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<pre style="text-align:center; width: 100%; margin-top: 20px;">
|
|
15
|
+
Wait for loading & creating <mwc-circular-progress id="progress" style="vertical-align: middle;" density=-8 indeterminate></mwc-circular-progress> TopoJSON from a GeoJSON file inside the worker extension.
|
|
16
|
+
</pre>
|
|
17
|
+
<canvas width="800" height="600"></canvas>
|
|
18
|
+
<script type="module">
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
import { d3, geoAitoff, topojson } from './lib/lib.js';
|
|
21
|
+
import SPL from '../dist/index.js';
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const extension = {
|
|
24
|
+
extends: 'db',
|
|
25
|
+
fns: {
|
|
26
|
+
'toTopoJSON': async (db, table, column='geometry') => {
|
|
27
|
+
if (typeof(topojson) === 'undefined') {
|
|
28
|
+
await import('https://unpkg.com/topojson-server@3');
|
|
29
|
+
}
|
|
30
|
+
return topojson.topology(db.exec(`SELECT ${column} FROM ${table}`).get.flat);
|
|
26
31
|
}
|
|
27
|
-
return topojson.topology(db.exec(`SELECT ${column} FROM ${table}`).get.flat);
|
|
28
|
-
},
|
|
29
|
-
'timeout': async (_, delay) => {
|
|
30
|
-
return new Promise(resolve => setTimeout(resolve, delay));
|
|
31
32
|
}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
33
|
+
};
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
const spl = await SPL({}, [extension]);
|
|
36
|
+
const db = await spl.mount('data', [{
|
|
37
|
+
name: 'world.geojson',
|
|
38
|
+
data: await fetch('data/world.json').then(res => res.arrayBuffer())
|
|
39
|
+
}]).db().read(`
|
|
40
|
+
SELECT InitSpatialMetaDataFull(1);
|
|
41
|
+
SELECT ImportGeoJSON('/data/world.geojson', 'world');
|
|
42
|
+
`);
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const context = d3.select('canvas').node().getContext('2d');
|
|
45
|
+
const path = d3.geoPath().projection(geoAitoff()).context(context);
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
db.toTopoJSON('world').then(topology => {
|
|
48
|
+
context.beginPath();
|
|
49
|
+
document.querySelector('#progress').remove();
|
|
50
|
+
path(topojson.mesh(topology));
|
|
51
|
+
context.stroke();
|
|
52
|
+
});
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
</script>
|
|
55
|
+
</body>
|
|
56
56
|
</html>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Map from 'ol/Map';
|
|
2
|
+
import View from 'ol/View';
|
|
3
|
+
import TileLayer from 'ol/layer/Tile';
|
|
4
|
+
import VectorLayer from 'ol/layer/Vector';
|
|
5
|
+
import OSM from 'ol/source/OSM';
|
|
6
|
+
import Vector from 'ol/source/Vector';
|
|
7
|
+
import GeoJSON from 'ol/format/GeoJSON';
|
|
8
|
+
import WKB from 'ol/format/WKB';
|
|
9
|
+
import Style from 'ol/style/Style';
|
|
10
|
+
import Icon from 'ol/style/Icon';
|
|
11
|
+
import Circle from 'ol/style/Circle';
|
|
12
|
+
import Fill from 'ol/style/Fill';
|
|
13
|
+
import Point from 'ol/geom/Point';
|
|
14
|
+
import Feature from 'ol/Feature';
|
|
15
|
+
import Collection from 'ol/Collection';
|
|
16
|
+
import Translate from 'ol/interaction/Translate';
|
|
17
|
+
import { CircularProgress } from '@material/mwc-circular-progress';
|
|
18
|
+
import { Slider } from '@material/mwc-slider';
|
|
19
|
+
import * as d3 from 'd3';
|
|
20
|
+
import { geoAitoff } from 'd3-geo-projection';
|
|
21
|
+
import * as topojson from 'topojson-client';
|
|
22
|
+
import debounce from 'lodash-es/debounce';
|
|
23
|
+
|
|
24
|
+
const ol = {
|
|
25
|
+
Map, View, TileLayer, VectorLayer, OSM, Vector,
|
|
26
|
+
GeoJSON, WKB,
|
|
27
|
+
Point, Feature, Collection,
|
|
28
|
+
Translate,
|
|
29
|
+
Style, Circle, Fill, Icon
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
ol,
|
|
34
|
+
d3, geoAitoff,
|
|
35
|
+
topojson,
|
|
36
|
+
debounce,
|
|
37
|
+
CircularProgress, Slider
|
|
38
|
+
}
|