This file contains 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
{ type: 'Feature', | |
geometry: { type: 'Point', coordinates: [ -76.6955, 38.3754 ] }, | |
properties: | |
{ message: 'insert', | |
schema: 'public', | |
table: 'simple_table', | |
id: '12' } } | |
--------------------------------- | |
{"type":"Feature","geometry":{"type":"Point","coordinates":[-76.6955,38.3754]},"properties":{"message":"insert","schema":"public","table":"simple_table","id":"12"}} |
This file contains 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
var PGPubsub = require('pg-pubsub'); | |
var pubsubInstance = new PGPubsub('postgres://postgres:user@localhost:5432/database'); | |
pubsubInstance.addChannel('actions', function (channelPayload) { | |
console.log(channelPayload); | |
console.log('---------------------------------'); | |
console.log(JSON.stringify(channelPayload)); | |
}); |
This file contains 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 simple_table(message, shape) | |
VALUES('test message', ST_GeomFromText('POINT(-76.6955 38.3754)', 4326)); |
This file contains 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 TRIGGER sample_table_trigger | |
AFTER INSERT | |
ON public.simple_table | |
FOR EACH ROW | |
EXECUTE PROCEDURE public.sample_notify(); |
This file contains 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 public.simple_table | |
( | |
id integer NOT NULL DEFAULT nextval('simple_table_id_seq'::regclass), | |
message text, | |
shape geometry(Point,4326), | |
CONSTRAINT pk_notify PRIMARY KEY (id) | |
) | |
WITH ( | |
OIDS=FALSE | |
); |
This file contains 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 OR REPLACE FUNCTION public.sample_notify() | |
RETURNS trigger AS | |
$BODY$ | |
DECLARE | |
BEGIN | |
PERFORM pg_notify('actions', '{"type": "Feature", "geometry": ' || | |
st_asgeojson(NEW.shape) || | |
',"properties": {"message": "' || | |
'insert' || '",' || | |
'"schema": "' || TG_TABLE_SCHEMA || '",' || |
This file contains 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
REM based on 'patch' here: https://github.com/mapbox/mbutil/blob/master/patch | |
@ECHO OFF | |
REM goto CATCH | |
REM %1 = source database | |
REM %2 = destination database | |
echo PRAGMA journal_mode=PERSIST;PRAGMA page_size=80000;PRAGMA synchronous=OFF;ATTACH DATABASE '%1' AS source;REPLACE INTO map SELECT * FROM source.map;REPLACE INTO images SELECT * FROM source.images;REPLACE INTO grid_data SELECT * FROM source.grid_data; | "C:\spatialite3\bin\sqlite3.exe" %2% | |
GOTO FINALLY | |
:CATCH | |
echo there was an error |
This file contains 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
d3.json( | |
"data/statistics.geojson", | |
function (json) { | |
//dimensions | |
var w = 980; | |
var h = 480; | |
//get the center of the data | |
var center = d3.geo.centroid(json); | |
var svg = d3.select("body").append("svg") | |
.attr("width", w) |
This file contains 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 name FROM sqlite_master | |
WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%' | |
UNION ALL | |
SELECT name FROM sqlite_temp_master | |
WHERE type IN ('table','view') | |
ORDER BY 1 |
This file contains 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
BEGIN; | |
-- Generate ADMINISTRATIVE_BOUNDARY_C for PostGIS. | |
CREATE TABLE "ADMINISTRATIVE_BOUNDARY_C" (OID INTEGER PRIMARY KEY, "BEN" varchar(15) DEFAULT 'noInformation', "BST" integer DEFAULT -999999, "CAA" integer DEFAULT -999999, "DSP" integer DEFAULT -999999, "F_CODE" varchar(5) DEFAULT 'FA000' CHECK ("F_CODE" = 'FA000'), "FA003_BAL" integer DEFAULT -999999, "FUFI" varchar(254) DEFAULT 'noInformation', "FURL" text DEFAULT 'noInformation', "LSP" integer DEFAULT -999999, "LZN" double precision DEFAULT -999999.0, "MGL" integer DEFAULT -999999, "MGL2" integer DEFAULT -999999, "MGL3" integer DEFAULT -999999, "OTH" text DEFAULT 'noInformation', "RPC" integer DEFAULT -999999, "UFI" varchar(254) DEFAULT 'noInformation', "ZI002_UFI" varchar(254) DEFAULT 'A9593791-4AE9-4180-8E1E-9CB3D239DEE5', "ZI004_RCG" varchar(30) DEFAULT 'noInformation', "ZI005_FNAA" varchar(200) DEFAULT 'No Information', "ZI005_FNAB" varchar(200) DEFAULT 'No Information', "ZI005_GNTA" integer DEFAULT -999999, "ZI005_GNTB" integer DEFAULT -99999 |