@@ -24,17 +24,22 @@ This page renders points from an iSamples parquet file on cesium using point pri
2424``` {ojs}
2525//| output: false
2626Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIwNzk3NjkyMy1iNGI1LTRkN2UtODRiMy04OTYwYWE0N2M3ZTkiLCJpZCI6Njk1MTcsImlhdCI6MTYzMzU0MTQ3N30.e70dpNzOCDRLDGxRguQCC-tRzGzA-23Xgno5lNgCeB4';
27+ ```
2728
29+ ``` {ojs}
30+ //| echo: false
2831viewof parquet_path = Inputs.text({label:"Source", value:"https://storage.googleapis.com/opencontext-parquet/oc_isamples_pqg.parquet", width:"100%", submit:true});
2932```
3033
3134``` {ojs}
3235//| code-fold: true
33- // Import Observable's libraries
34- import {DuckDBClient} from "@observablehq/duckdb"
3536
3637// Create a DuckDB instance
37- db = DuckDBClient.of();
38+ db = {
39+ const instance = await DuckDBClient.of();
40+ await instance.query(`create view nodes as select * from read_parquet('${parquet_path}')`)
41+ return instance;
42+ }
3843
3944
4045async function loadData(query, params=[], waiting_id=null) {
@@ -62,9 +67,13 @@ async function loadData(query, params=[], waiting_id=null) {
6267
6368locations = {
6469 // get the content form the parquet file
65- const query = `SELECT row_id, pid, latitude, longitude FROM read_parquet('${parquet_path}') WHERE otype='GeospatialCoordLocation'`;
70+ const query = `SELECT pid, latitude, longitude FROM nodes WHERE otype='GeospatialCoordLocation'`;
6671 const data = await loadData(query, [], "loading_1");
6772
73+ // Clear the existing PointPrimitiveCollection
74+ content.points.removeAll();
75+ //content.points = new Cesium.PointPrimitiveCollection();
76+
6877 // create point primitives for cesium display
6978 const scalar = new Cesium.NearFarScalar(1.5e2, 2, 8.0e6, 0.2);
7079 const color = Cesium.Color.PINK;
@@ -78,7 +87,6 @@ locations = {
7887 row.latitude, //latitude
7988 0,//randomCoordinateJitter(10.0, 10.0), //elevation, m
8089 ),
81- row_id: row.row_id,
8290 pixelSize: point_size,
8391 color: color,
8492 scaleByDistance: scalar,
@@ -109,7 +117,7 @@ function createShowPrimitive(viewer) {
109117 // If selectPoint is valid and no currently selected point
110118 if (Cesium.defined(selectPoint) && selectPoint.hasOwnProperty("primitive")) {
111119 //console.log(`showPrimitiveId ${selectPoint.id}`);
112- const carto = Cesium.Cartographic.fromCartesian(selectPoint.primitive.position)
120+ // const carto = Cesium.Cartographic.fromCartesian(selectPoint.primitive.position)
113121 viewer.pointLabel.position = selectPoint.primitive.position;
114122 viewer.pointLabel.label.show = true;
115123 //viewer.pointLabel.label.text = `id:${selectPoint.id}, ${carto}`;
@@ -180,11 +188,19 @@ async function getGeoRecord(pid) {
180188 if (pid === null || pid ==="" || pid == "unset") {
181189 return "unset";
182190 }
183- const q = `SELECT row_id, pid, otype, latitude, longitude FROM read_parquet('${parquet_path}') WHERE otype='GeospatialCoordLocation' AND pid=?`;
191+ const q = `SELECT row_id, pid, otype, latitude, longitude FROM nodes WHERE otype='GeospatialCoordLocation' AND pid=?`;
184192 const result = await db.queryRow(q, [pid]);
185193 return result;
186194}
187195
196+ async function locationUsedBy(rowid){
197+ if (rowid === undefined || rowid === null) {
198+ return [];
199+ }
200+ const q = `select pid, otype from nodes where row_id in (select nodes.s from nodes where list_contains(nodes.o, ?));`;
201+ return db.query(q, [rowid]);
202+ }
203+
188204mutable clickedPointId = "unset";
189205selectedGeoRecord = await getGeoRecord(clickedPointId);
190206
@@ -229,3 +245,4 @@ ${JSON.stringify(selectedGeoRecord, null, 2)}
229245`
230246```
231247
248+
0 commit comments