This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| dbscan_cid, | |
| st_union(geom) geom | |
| FROM ( | |
| SELECT | |
| ST_ClusterDBSCAN(geom, 0.23, 1) OVER () dbscan_cid, | |
| geom | |
| FROM gb_retailpoint | |
| ) kmeans GROUP BY dbscan_cid; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| SUM(count)::integer count, | |
| JSON_Agg(JSON_Build_Object(cat, count)) cat, | |
| ST_AsGeoJson(ST_PointOnSurface(ST_Union(geom))) geomj | |
| FROM ( | |
| SELECT | |
| COUNT(cat) count, | |
| ST_Union(geom) geom, | |
| cat, | |
| kmeans_cid, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| INSERT INTO dev.natural_earth_countries__mvts (z, x, y, mvt, tile) | |
| SELECT | |
| 5, | |
| 10, | |
| 13, | |
| ST_AsMVT(tile, 'COUNTRIES', 4096, 'geom') mvt, | |
| ST_MakeEnvelope( | |
| ${-m + (x * r)}, | |
| ${ m - (y * r)}, | |
| ${-m + (x * r) + r}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| create table if not exists natural_earth_countries__mvts | |
| ( | |
| z integer not null, | |
| x integer not null, | |
| y integer not null, | |
| mvt bytea, | |
| tile geometry(Polygon,3857), | |
| constraint dev_natural_earth_countries__mvts_z_x_y_pk | |
| primary key (z, x, y) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = async (layer, table, id) => { | |
| const q = ` | |
| DELETE FROM ${table}__mvts | |
| WHERE | |
| ST_Intersects( | |
| tile, | |
| (SELECT ${layer.geom_3857} FROM ${table} WHERE ${layer.qID} = $1) | |
| );`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Set jsrender module for server-side templates. | |
| const jsr = require('jsrender'); | |
| module.exports = {route, view}; | |
| function route(fastify) { | |
| fastify.route({ | |
| method: 'GET', | |
| url: '/', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const env = require('../mod/env'); | |
| const sql_filter = require('../mod/pg/sql_filter'); | |
| const sql_fields = require('../mod/pg/sql_fields'); | |
| fastify.route({ | |
| method: 'GET', | |
| url: '/api/layer/table', | |
| preValidation: fastify.auth([ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const env = require('../mod/env'); | |
| module.exports = fastify => (req, res, next, access = {}) => { | |
| // Delete query token param if string 'null' instead of null. | |
| if (req.query.token === 'null') { | |
| delete req.query.token; | |
| } | |
| // Public access without token. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fastify = require('fastify')({ | |
| trustProxy: true, | |
| logger: { | |
| level: process.env.LOG_LEVEL || 'error', | |
| prettifier: require('pino-pretty'), | |
| prettyPrint: { | |
| errorProps: 'hint, detail', | |
| levelFirst: true, | |
| crlf: true | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let currentFeature; | |
| map.on('click', select); | |
| function select(e) { | |
| sourceVector.clear(); | |
| map.removeInteraction(drawInteraction); |
OlderNewer