Skip to content

Instantly share code, notes, and snippets.

View geobabbler's full-sized avatar
💭
Working

William Dollins geobabbler

💭
Working
View GitHub Profile
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
SELECT sql
FROM (
SELECT sql sql, type type, tbl_name tbl_name, name name
FROM sqlite_master
UNION ALL
SELECT sql, type, tbl_name, name
FROM sqlite_temp_master
)
WHERE type != 'meta'
AND sql NOTNULL
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
@geobabbler
geobabbler / GlobalMercator.cs
Created February 20, 2014 18:26
C# implementation of GlobalMercator class from globalmaptiles.py
/*
GlobalMercator.cs
Copyright (c) 2014 Bill Dollins. All rights reserved.
http://blog.geomusings.com
*************************************************************
Based on GlobalMapTiles.js - part of Aggregate Map Tools
Version 1.0
Copyright (c) 2009 The Bivings Group
All rights reserved.
Author: John Bafford
if (ImageFormat.Jpeg.Equals(image.RawFormat))
{
// JPEG
}
else if (ImageFormat.Png.Equals(image.RawFormat))
{
// PNG
}
else if (ImageFormat.Gif.Equals(image.RawFormat))
{
@geobabbler
geobabbler / MBTilesProvider.cs
Created February 25, 2014 17:13
Simple class to access MBTiles in C#
public class MBTilesProvider
{
public GeoExtent Bounds { get; private set; }
public CoordinatePair Center { get; private set; }
public int MinZoom { get; private set; }
public int MaxZoom { get; private set; }
public string Name { get; private set; }
public string Description { get; private set; }
public string MBTilesVersion { get; private set; }
public string Path { get; private set; }
@geobabbler
geobabbler / mbmerge.bat
Last active June 24, 2016 13:27
Windows batch file to merge MBTiles database. Based on 'patch' (https://github.com/mapbox/mbutil/blob/master/patch)
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
@geobabbler
geobabbler / globamaptiles.py
Created April 21, 2014 13:19
Update of globalmaptiles.py from http://www.maptiler.org to include functions to generate ArcGIS tile addresses (using hex notation) and to generate world file (affine transformation) parameters for a given TMS tile.
#!/usr/bin/env python
###############################################################################
# $Id$
#
# Project: GDAL2Tiles, Google Summer of Code 2007 & 2008
# Global Map Tiles Classes
# Purpose: Convert a raster into TMS tiles, create KML SuperOverlay EPSG:4326,
# generate a simple HTML viewers based on Google Maps and OpenLayers
# Author: Klokan Petr Pridal, klokan at klokan dot cz
# Web: http://www.klokan.cz/projects/gdal2tiles/
@geobabbler
geobabbler / worlddfile.py
Last active August 29, 2015 14:00
Function to generate world file parameters for any TMS tile. Useful for building virtual rasters. Add to globalmaptiles.py
def WorldFileParameters(self, tx, ty, zoom):
"Returns world file (affine transofrmation) parameters of the given tile."
bounds = self.TileBounds( tx, ty, zoom)
moriginx = bounds[3] + (self.Resolution(zoom) / 2)
moriginy = bounds[0] - (self.Resolution(zoom) / 2)
return (self.Resolution(zoom), 0.0, 0.0, self.Resolution(zoom) * -1, moriginy, moriginx)
var express = require('express'),
geo = require('./routes/geo');
var app = express();
app.get('/countries/:id/bbox', geo.bbox);
app.get('/countries/:id/bbox/:srid', geo.bboxSrid);
app.get('/countries/:id/polygon', geo.polygon);
app.get('/countries/:id/polygon/:srid', geo.polygonSrid);