Skip to content

Instantly share code, notes, and snippets.

@JerrySievert
JerrySievert / gist:6189314
Created August 8, 2013 22:16
building footprint processing for downtown portland
var JSONStream = require('JSONStream'),
fs = require('fs'),
Terraformer = require('Terraformer');
var incoming = fs.createReadStream("./buildings.json", { encoding: "utf8" });
var outgoing = fs.createWriteStream("./processed.json", { encoding: "utf8" });
var stream = JSONStream.parse(['features', true]);
var downtown = new Terraformer.Polygon(
@JerrySievert
JerrySievert / gist:6286832
Created August 20, 2013 20:28
index logic
/*
"crime":
{
"equals": "arson"
}
index -> specific index that references the property keyword
query -> object containing the specific queries for the index
set -> object containing keys of all of the id's matching currently
function foo() {
return "foo";
}
foo.bar = function () {
return "bar";
};
module.exports = exports = foo;
CREATE OR REPLACE FUNCTION _st_distance(geography, geography, double precision, boolean)
RETURNS double precision AS
'$libdir/postgis-2.2', 'geography_distance_uncached'
LANGUAGE c IMMUTABLE STRICT
COST 100;
est=# CREATE TABLE test (id serial, condition_geo geography);
CREATE TABLE
test=# INSERT INTO test (condition_geo) VALUES (ST_Buffer(ST_GeogFromWKB(ST_MakePoint(20.0,30.0)),10.0));
INSERT 0 1
test=# SELECT id FROM test WHERE ST_Intersects("condition_geo", ST_Buffer(ST_GeogFromText('POINT(20.0 30.0)'), 20.0)) IS TRUE;
id
----
1
(1 row)
var Terraformer = require('../Terraformer/'),
GeoStore = require('../terraformer-geostore/node/terraformer-geostore.js').GeoStore,
RTree = require('../terraformer-geostore-rtree/').RTree,
LevelStore = require('../terraformer-geostore-leveldb/').LevelStore;
fs = require('fs');
var JSONStream = require('JSONStream');
var index = new RTree();
var store = new GeoStore({
for (var i = 0; i < 1000; i++) {
setTimeout(function () {
console.log(i);
}, 1000);
}
function(msg) {
if(/^hawthorne/.test(msg.message)) {
var match = msg.message.match(/^hawthorne\s+(.+)/);
var tap;
var taps = [ ];
json = http.get("http://api.legitimatesounding.com/api/hawthorne");
feed = JSON.parse(json);
// keep only the first 20
function(msg) {
if(/^hawthorne/.test(msg.message)) {
var match = msg.message.match(/^hawthorne\s+(.+)/);
var tap;
var taps = [ ];
json = http.get("http://api.legitimatesounding.com/api/hawthorne");
feed = JSON.parse(json);
// delete the first 20
function(msg) {
if(/^baileys/.test(msg.message)) {
var match = msg.message.match(/^baileys\s+(.+)/);
var tap;
var taps = [ ];
json = http.get("http://api.legitimatesounding.com/api/baileys");
feed = JSON.parse(json);
var tap_list = "Bailey's Taps: ";