Skip to content

Instantly share code, notes, and snippets.

View bmoregeo's full-sized avatar

Christopher Fricke bmoregeo

View GitHub Profile
@bmoregeo
bmoregeo / gist:e6a09a5e7f65b1f7a903
Created May 25, 2014 19:26
Choropleth MySQL PHP
// To call this from your php script, insert $kml_output .= getGeo($row['SHAPE']);
// or whatever the geometry field in your MYSQL DB table is
function getGeo($shape){
// Parse WKT style coordinates to KML style Coordinates
$shape = preg_replace("/([0-9.-]+) ([0-9.-]+),*/", "$1,$2,0 ", $shape);
// If the Geometry Type is a point parse the geometry type as a point
if (preg_match("/^POINT/", $shape)){
$shape = substr($shape, 6);
$shape = substr($shape, 0,-1);
@bmoregeo
bmoregeo / phpbreaks
Created May 25, 2014 19:27
php get breaks
function getBreaks($max, $min, $q){
$quant = ($max - $min) / $q;
for ($x = 0; $x <= $q; $x++){
$breakValue[$x] = $min+($quant*$x);
}
return $breakValue;
}
@bmoregeo
bmoregeo / gist:8927619
Last active August 29, 2015 13:56
Install CartoDB on Ubuntu 11.10. Use https://github.com/lordlinus/cartodb as a template
# Install PostGIS
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list'
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install Postgresql-9.3-postgis postgresql-contrib
sudo -u postgres psql
# > CREATE EXTENSION adminpack;
# > \q