chore: import upstream snapshot with attribution
CI / compile_and_lint (push) Failing after 0s
CI / docker_build (linux/amd64, -linux-amd64-duckdb, duckdb) (push) Failing after 0s
CI / docker_build (linux/arm64, -linux-arm64, minimal) (push) Failing after 2s
CI / docker_build (linux/arm64, -linux-arm64-duckdb, duckdb) (push) Failing after 1s
CI / docker_build (linux/amd64, minimal) (push) Failing after 1s
CI / test (, sqlite, sqlite::memory:) (push) Has been skipped
CI / test (mssql, mssql, mssql://root:Password123!@127.0.0.1/sqlpage) (push) Has been skipped
CI / test (mysql, mysql, mysql://root:Password123!@127.0.0.1/sqlpage) (push) Has been skipped
CI / test (oracle, oracle, Driver=Oracle 21 ODBC driver;Dbq=//127.0.0.1:1521/FREEPDB1;Uid=root;Pwd=Password123!) (push) Has been skipped
CI / test (postgres, odbc, Driver=PostgreSQL Unicode;Server=127.0.0.1;Port=5432;Database=sqlpage;UID=root;PWD=Password123!, true) (push) Has been skipped
CI / test (postgres, postgres, postgres://root:Password123!@127.0.0.1/sqlpage) (push) Has been skipped
CI / playwright (push) Has been skipped
CI / docker_build (linux/arm/v7, -linux-arm-v7, minimal) (push) Failing after 0s
CI / hurl_examples (push) Failing after 8s
deploy website / deploy_official_site (push) Failing after 1s
CI / hurl (${{ matrix.example }}) (push) Has been skipped
CI / docker_push (duckdb) (push) Has been cancelled
CI / docker_push (minimal) (push) Has been cancelled
CI / windows_test (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 12:31:57 +08:00
commit d718c5a372
986 changed files with 74597 additions and 0 deletions
@@ -0,0 +1,10 @@
FROM debian:stable-slim
COPY --from=lovasoa/sqlpage:main /usr/local/bin/sqlpage /usr/local/bin/sqlpage
RUN apt-get update && \
apt-get -y install libsqlite3-mod-spatialite
COPY . .
CMD ["sqlpage"]
@@ -0,0 +1,25 @@
# Using spatialite to build a geographic data application
## Introduction
This is a small application that uses [spatialite](https://www.gaia-gis.it/fossil/libspatialite/index)
to save data associated to greographic coordinates.
If you are using a postgres database, see [this other example instead](../PostGIS%20-%20using%20sqlpage%20with%20geographic%20data/),
which implements the same application using the `PostGIS` extension.
### Installation
You need to install the `spatialite` extension for SQLite. On Debian, or Ubuntu, you can do it with:
```bash
sudo apt install libsqlite3-mod-spatialite
```
Then you can run this application normally with SQLPage.
Notice the `sqlite_extensions` configuration parameter in [`sqlpage/sqlpage.json`](./sqlpage/sqlpage.json).
## Screenshots
![](./screenshots/code.png)
@@ -0,0 +1,11 @@
INSERT INTO spatial_data (title, geom, description)
VALUES (
:Title,
MakePoint(
CAST(:Longitude AS REAL),
CAST(:Latitude AS REAL
), 4326),
:Text
) RETURNING
'redirect' AS component,
'index.sql' AS link;
@@ -0,0 +1,5 @@
services:
web:
build: .
ports:
- "8080:8080"
@@ -0,0 +1,40 @@
SELECT 'shell' as component,
'Map' AS title,
'/' as link,
'book' as icon;
SELECT 'map' AS component,
ST_Y(geom) AS latitude,
ST_X(geom) AS longitude
FROM spatial_data
WHERE id = $id;
SELECT 'map' as component,
'Points of interest' as title,
2 as zoom,
700 as height;
SELECT title,
ST_Y(geom) AS latitude,
ST_X(geom) AS longitude,
'point.sql?id=' || id as link,
'red' as color,
'world-pin' as icon
FROM spatial_data;
SELECT 'list' as component,
'My points' as title;
SELECT title,
'point.sql?id=' || id as link,
'red' as color,
'world-pin' as icon
FROM spatial_data;
SELECT 'form' AS component,
'Add a point' AS title,
'add_point.sql' AS action;
SELECT 'Title' AS name;
SELECT 'Latitude' AS name, 'number' AS type, 0.00000001 AS step;
SELECT 'Longitude' AS name, 'number' AS type, 0.00000001 AS step;
SELECT 'Text' AS name, 'textarea' AS type;
@@ -0,0 +1,56 @@
SELECT 'shell' as component,
title,
'/' as link,
'index' as menu_item,
'book' as icon
FROM spatial_data
WHERE id = $id;
SELECT 'datagrid' as component, title FROM spatial_data WHERE id = $id;
SELECT 'Latitude' as title,
ST_Y(geom) as description,
'purple' as color,
'world-latitude' as icon
FROM spatial_data WHERE id = $id;
SELECT 'Longitude' as title,
ST_X(geom) as description,
'purple' as color,
'world-longitude' as icon
FROM spatial_data WHERE id = $id;
SELECT 'Created at' as title,
created_at as description,
'calendar' as icon,
'Date and time of creation' as footer
FROM spatial_data WHERE id = $id;
SELECT 'Label' as title,
title as description,
'geo:' || ST_Y(geom) || ',' || ST_X(geom) || '?z=16' AS link,
'blue' as color,
'world' as icon,
'User-generated point name' as footer
FROM spatial_data
WHERE id = $id;
SELECT 'text' as component,
description as contents_md
FROM spatial_data
WHERE id = $id;
SELECT 'list' as component, 'Closest points' as title;
SELECT to_label as title,
ROUND(CvtToKm(distance), 3) || ' km' as description,
'point.sql?id=' || to_id as link,
'red' as color,
'world-pin' as icon
FROM distances
WHERE from_id = $id
ORDER BY distance
LIMIT 5;
SELECT 'map' AS component,
ST_Y(geom) AS latitude, ST_X(geom) AS longitude
FROM spatial_data WHERE id = $id;
Binary file not shown.

After

Width:  |  Height:  |  Size: 846 KiB

@@ -0,0 +1,23 @@
-- Create a spatialite-enabled database
CREATE TABLE spatial_data (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
geom POINT,
description TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
SELECT InitSpatialMetaData();
CREATE VIEW distances AS
SELECT from_point.id AS from_id,
from_point.title AS from_label,
to_point.id AS to_id,
to_point.title AS to_label,
ST_Distance(
from_point.geom,
to_point.geom,
TRUE
) AS distance
FROM spatial_data AS from_point, spatial_data AS to_point
WHERE from_point.id != to_point.id;
@@ -0,0 +1,3 @@
{
"sqlite_extensions": ["mod_spatialite"]
}
@@ -0,0 +1,44 @@
GET http://localhost:8080/
HTTP 200
[Asserts]
body contains "Points of interest"
body contains "Add a point"
body not contains "An error occurred"
POST http://localhost:8080/add_point.sql
[FormParams]
Title: Hurl Paris
Latitude: 48.8566
Longitude: 2.3522
Text: First Hurl point
HTTP 302
[Asserts]
header "Location" == "index.sql"
POST http://localhost:8080/add_point.sql
[FormParams]
Title: Hurl Lyon
Latitude: 45.764
Longitude: 4.8357
Text: Second Hurl point
HTTP 302
GET http://localhost:8080/
HTTP 200
[Captures]
paris_id: xpath "substring-after(string(//a[normalize-space(.)='Hurl Paris']/@href), 'id=')"
[Asserts]
body contains "Hurl Paris"
body contains "Hurl Lyon"
body htmlUnescape contains "point.sql?id={{paris_id}}"
body not contains "An error occurred"
GET http://localhost:8080/point.sql?id={{paris_id}}
HTTP 200
[Asserts]
body contains "48.8566"
body contains "2.3522"
body contains "First Hurl point"
body contains "Closest points"
body contains "Hurl Lyon"
body not contains "An error occurred"