Skip to content

Instantly share code, notes, and snippets.

View rmarianski's full-sized avatar

Robert Marianski rmarianski

View GitHub Profile
--------------------------------------------------------------------------------
-- disable-triggers.sql
--------------------------------------------------------------------------------
ALTER TABLE planet_osm_point DISABLE TRIGGER USER;
ALTER TABLE planet_osm_polygon DISABLE TRIGGER USER;
ALTER TABLE planet_osm_line DISABLE TRIGGER USER;
--------------------------------------------------------------------------------
-- functions.sql
from redis import StrictRedis
from tilequeue.cache import RedisCacheIndex
from tilequeue.tile import coord_to_bounds
from tilequeue.tile import coord_unmarshall_int
from tilequeue.tile import serialize_coord
import shapely.geometry
redis_host = '...'
redis_client = StrictRedis(redis_host)
cache_index = RedisCacheIndex(redis_client)
ALTER TABLE planet_osm_point DISABLE TRIGGER USER;
ALTER TABLE planet_osm_polygon DISABLE TRIGGER USER;
CREATE OR REPLACE FUNCTION mz_one_pixel_zoom(
way_area real)
RETURNS real AS $$
BEGIN
RETURN
CASE WHEN way_area < 5.704
THEN 16.0
@rmarianski
rmarianski / gist:4c690725a6758e07ee4b
Last active October 1, 2015 15:11
migration-20150930
CREATE OR REPLACE FUNCTION mz_one_pixel_zoom(
way_area real)
RETURNS real AS $$
BEGIN
RETURN
CASE WHEN way_area < 5.704
THEN 16.0
ELSE (17.256-ln(way_area)/ln(4))
END;
END;
@rmarianski
rmarianski / migrate.sql
Last active September 24, 2015 15:57
db migration 20150923
-- (will need to update relevant polygons/lines that have been updated)
-- IF YOU UPDATE THIS, PLEASE UPDATE mz_calculate_landuse_kind
-- BELOW!
CREATE OR REPLACE FUNCTION mz_calculate_is_landuse(
landuse_val text, leisure_val text, natural_val text, highway_val text,
amenity_val text, aeroway_val text, tourism_val text, man_made_val text,
power_val text, boundary_val text)
RETURNS BOOLEAN AS $$
BEGIN
@rmarianski
rmarianski / migration-20150918.sql
Last active September 18, 2015 17:45
db migration 20150918
-- functions.sql will get run first
-- point.sql and polygon.sql will get run in parallel
-- cleanup-point.sql will get run after the new code gets deployed
-- diffs will be turned off before applying updates, and then re-enabled
-- nothing should lock the tables for reading though
--------------------------------------------------------------------------------
-- functions.sql
@rmarianski
rmarianski / gist:99a2d6e16b6cad4f9313
Created August 26, 2015 16:30
mapbox-vector-tile python3 test failures
$ virtualenv --python=python3 env3
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in env3/bin/python3
Also creating executable in env3/bin/python
Installing setuptools, pip...done.
$ source env3/bin/activate
$ python -V
Python 3.4.0
$ python setup.py develop
package main
import (
"fmt"
"github.com/qedus/osmpbf"
"io"
"log"
"os"
"runtime"
"time"
@rmarianski
rmarianski / gist:198ce34d12ebbb05923c
Created February 13, 2015 16:29
migrate waterway dock
BEGIN;
ALTER TABLE planet_osm_polygon DISABLE TRIGGER USER;
COMMIT;
BEGIN;
CREATE OR REPLACE FUNCTION mz_calculate_is_water(
waterway_val text, natural_val text, landuse_val text)
@rmarianski
rmarianski / migration.sql
Last active August 29, 2015 14:15
Migrate osm data (landuse, road, poi)
BEGIN;
-- update functions
CREATE OR REPLACE FUNCTION mz_calculate_is_landuse(
landuse_val text, leisure_val text, natural_val text, highway_val text, amenity_val text, aeroway_val text)
RETURNS BOOLEAN AS $$
BEGIN
RETURN
landuse_val IN ('park', 'forest', 'residential', 'retail', 'commercial',