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.
Files changed (48) hide show
  1. package/Makefile +54 -57
  2. package/README.md +6 -27
  3. package/dist/index.js +53 -2
  4. package/dist/index.mjs +43 -0
  5. package/dist/{spl.wasm → index.wasm} +0 -0
  6. package/dist/proj/proj.db +0 -0
  7. package/dist/proj/proj.ini +10 -0
  8. package/dist/proj/projjson.schema.json +31 -5
  9. package/dist/spl-node.mjs +1 -0
  10. package/dist/spl-web.js +2 -0
  11. package/examples/extensions.html +45 -45
  12. package/examples/lib/index.js +38 -0
  13. package/examples/lib/lib.js +456 -0
  14. package/examples/lib/ol.css +345 -0
  15. package/examples/lib/package-lock.json +2291 -0
  16. package/examples/lib/package.json +26 -0
  17. package/examples/lib/rollup.config.js +17 -0
  18. package/examples/lights-performance.html +240 -250
  19. package/examples/openlayers.html +76 -75
  20. package/examples/topology.html +3 -4
  21. package/package.json +19 -20
  22. package/rollup.config.node.js +16 -11
  23. package/rollup.config.web.js +5 -12
  24. package/rollup.config.worker.js +6 -10
  25. package/scripts/stringify.js +3 -3
  26. package/src/index.js +53 -0
  27. package/src/index.mjs +43 -0
  28. package/src/{result.ts → result.js} +2 -4
  29. package/src/spl-node.mjs +3 -0
  30. package/src/{spl-web.ts → spl-web.js} +42 -22
  31. package/src/{spl-worker.ts → spl-worker.js} +12 -5
  32. package/src/{spl.ts → spl.js} +96 -73
  33. package/test/browser.js +4 -87
  34. package/test/electron.js +8 -3
  35. package/test/files/tmp/memory_and_local_dbs_1.db +0 -0
  36. package/test/files/tmp/save_and_load_from_to_memory.db +0 -0
  37. package/test/node.js +39 -42
  38. package/dist/index.d.ts +0 -54
  39. package/dist/spl.d.ts +0 -46
  40. package/dist/spl.js +0 -1
  41. package/src/interfaces.ts +0 -85
  42. package/src/spl-node.ts +0 -4
  43. package/src/spl-web.d.ts +0 -54
  44. package/src/spl.d.ts +0 -46
  45. package/tsconfig.json +0 -9
  46. package/tslint.json +0 -126
  47. /package/examples/{lights.zip → data/lights.zip} +0 -0
  48. /package/examples/{world.json → data/world.json} +0 -0
@@ -1,56 +1,56 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <title>Extensions</title>
6
- <script src="https://unpkg.com/d3@4"></script>
7
- <script src="https://unpkg.com/d3-geo-projection@4"></script>
8
- <script src="https://unpkg.com/topojson-client@3"></script>
9
- <script type="module" src="https://unpkg.com/@material/mwc-circular-progress?module"></script>
10
- </head>
11
- <body>
12
- <pre style="text-align:center; width: 100%; margin-top: 20px;">
13
- 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.
14
- </pre>
15
- <canvas width="800" height="600"></canvas>
16
- <script type="module">
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
- import SPL from '../dist/index.js';
20
+ import { d3, geoAitoff, topojson } from './lib/lib.js';
21
+ import SPL from '../dist/index.js';
19
22
 
20
- const extention = {
21
- extends: 'db',
22
- fns: {
23
- 'toTopoJSON': async (db, table, column='geometry') => {
24
- if (typeof(topojson) === 'undefined') {
25
- await import('https://unpkg.com/topojson-server@3');
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
- const spl = await SPL([extention]);
36
- const db = await spl.mount('data', [{
37
- name: 'world.geojson',
38
- data: await fetch('world.json').then(res => res.arrayBuffer())
39
- }]).db().read(`
40
- SELECT InitSpatialMetaDataFull(1);
41
- SELECT ImportGeoJSON('/data/world.geojson', 'world');
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
- const context = d3.select('canvas').node().getContext('2d');
45
- const path = d3.geoPath().projection(d3.geoAitoff()).context(context);
44
+ const context = d3.select('canvas').node().getContext('2d');
45
+ const path = d3.geoPath().projection(geoAitoff()).context(context);
46
46
 
47
- db.toTopoJSON('world').then(topology => {
48
- context.beginPath();
49
- document.querySelector('#progress').remove();
50
- path(topojson.mesh(topology));
51
- context.stroke();
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
- </script>
55
- </body>
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
+ }