Skip to content
Discussion options

You must be logged in to vote

I've made some progress!

I’ve discovered how to combine all of my entries into a single FeatureCollection for a GeoJSON file.

Now I can clean up the GeoJSON output on each API call or subscription. Below is some sample code for anyone who needs it (and would like feedback).

CREATE TABLE locations (
id INTEGER PRIMARY KEY,
name TEXT,
lat REAL,
long REAL,
geojson TEXT GENERATED ALWAYS AS (
'{"type": "Feature", "geometry": {"type": "Point", "coordinates": [' || long || ', ' || lat || ']}}'
) VIRTUAL
) STRICT;

INSERT INTO
locations (name, lat, long)
VALUES
('Coffee Corner', 37.7749, -122.4194),
('Book Nook', 40.7128, -74.0060),
('Bike Hub', 34.0522, -118.2437);

CREATE VIEW location_geojson AS

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ignatz
Comment options

@Swamp2k9
Comment options

@ignatz
Comment options

Answer selected by Swamp2k9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants