@nshiab/simple-data-analysis-core 0.0.24 → 0.0.26

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.
@@ -1 +1 @@
1
- {"version":3,"file":"randomPointQuery.d.ts","sourceRoot":"","sources":["../../src/methods/randomPointQuery.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,UAoBtB"}
1
+ {"version":3,"file":"randomPointQuery.d.ts","sourceRoot":"","sources":["../../src/methods/randomPointQuery.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,UA8BtB"}
@@ -5,14 +5,24 @@ ${newColumn === column
5
5
  ? ""
6
6
  : `ALTER TABLE "${table}" ADD COLUMN "${newColumn}" GEOMETRY;`}
7
7
  UPDATE "${table}" AS t
8
- SET "${newColumn}" = (
9
- SELECT pt FROM (
10
- SELECT ST_Point(
11
- ST_XMin(t."${column}") + random() * (ST_XMax(t."${column}") - ST_XMin(t."${column}")),
12
- ST_YMin(t."${column}") + random() * (ST_YMax(t."${column}") - ST_YMin(t."${column}"))
13
- ) AS pt
14
- FROM range(${nbPointsToTry})
15
- ) WHERE ST_Within(pt, t."${column}")
16
- LIMIT 1
17
- );`;
8
+ SET "${newColumn}" = sub.pt
9
+ FROM (
10
+ SELECT
11
+ t_inner.rowid AS rid,
12
+ p.pt
13
+ FROM "${table}" AS t_inner
14
+ CROSS JOIN LATERAL (
15
+ SELECT pt
16
+ FROM (
17
+ SELECT ST_Point(
18
+ ST_XMin(t_inner."${column}") + (CASE WHEN (t_inner.rowid + r.id) IS NOT NULL THEN random() END) * (ST_XMax(t_inner."${column}") - ST_XMin(t_inner."${column}")),
19
+ ST_YMin(t_inner."${column}") + (CASE WHEN (t_inner.rowid + r.id) IS NOT NULL THEN random() END) * (ST_YMax(t_inner."${column}") - ST_YMin(t_inner."${column}"))
20
+ ) AS pt
21
+ FROM range(${nbPointsToTry}) AS r(id)
22
+ )
23
+ WHERE ST_Within(pt, t_inner."${column}")
24
+ LIMIT 1
25
+ ) AS p
26
+ ) AS sub
27
+ WHERE t.rowid = sub.rid;`;
18
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nshiab/simple-data-analysis-core",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "The core functionalities of the simple-data-analysis library, with only one dependency: DuckDB.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +1 @@
1
- {"version":3,"file":"randomPointQuery.d.ts","sourceRoot":"","sources":["../../src/methods/randomPointQuery.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,UAoBtB"}
1
+ {"version":3,"file":"randomPointQuery.d.ts","sourceRoot":"","sources":["../../src/methods/randomPointQuery.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,UA8BtB"}
@@ -8,14 +8,24 @@ ${newColumn === column
8
8
  ? ""
9
9
  : `ALTER TABLE "${table}" ADD COLUMN "${newColumn}" GEOMETRY;`}
10
10
  UPDATE "${table}" AS t
11
- SET "${newColumn}" = (
12
- SELECT pt FROM (
13
- SELECT ST_Point(
14
- ST_XMin(t."${column}") + random() * (ST_XMax(t."${column}") - ST_XMin(t."${column}")),
15
- ST_YMin(t."${column}") + random() * (ST_YMax(t."${column}") - ST_YMin(t."${column}"))
16
- ) AS pt
17
- FROM range(${nbPointsToTry})
18
- ) WHERE ST_Within(pt, t."${column}")
19
- LIMIT 1
20
- );`;
11
+ SET "${newColumn}" = sub.pt
12
+ FROM (
13
+ SELECT
14
+ t_inner.rowid AS rid,
15
+ p.pt
16
+ FROM "${table}" AS t_inner
17
+ CROSS JOIN LATERAL (
18
+ SELECT pt
19
+ FROM (
20
+ SELECT ST_Point(
21
+ ST_XMin(t_inner."${column}") + (CASE WHEN (t_inner.rowid + r.id) IS NOT NULL THEN random() END) * (ST_XMax(t_inner."${column}") - ST_XMin(t_inner."${column}")),
22
+ ST_YMin(t_inner."${column}") + (CASE WHEN (t_inner.rowid + r.id) IS NOT NULL THEN random() END) * (ST_YMax(t_inner."${column}") - ST_YMin(t_inner."${column}"))
23
+ ) AS pt
24
+ FROM range(${nbPointsToTry}) AS r(id)
25
+ )
26
+ WHERE ST_Within(pt, t_inner."${column}")
27
+ LIMIT 1
28
+ ) AS p
29
+ ) AS sub
30
+ WHERE t.rowid = sub.rid;`;
21
31
  }