Skip to content

Instantly share code, notes, and snippets.

View jasonbeverage's full-sized avatar

Jason Beverage jasonbeverage

View GitHub Profile
"""
Post processor for OSM tables imported by Imposm to rename suffixes and prefixes to shorter versions
Use like:
python gen_osm_replacment > gen_osm_replacment.sql
psql -d osm < gen_osm_replacmenet.sql
"""
replacements = [
('Avenue', 'Ave'),
('Boulevard', 'Blvd'),
@jasonbeverage
jasonbeverage / reset_south_migrations
Created April 28, 2014 12:49
How to reset South migrations
# From http://stackoverflow.com/questions/12822584/how-to-reset-south-migrations-to-capture-the-current-state-of-my-django-models/12823039#12823039
# I figured this out (wasn't too bad). To set up the migration reset, I do the following:
rm <app-dir>/migrations/*
python manage.py schemamigration <app-name> --initial
python manage.py migrate <app-name> 0001 --fake --delete-ghost-migrations
# I commit the changes to the repository, and then for each deployment of the code elsewhere, run:
python manage.py migrate <app-name> 0001 --fake --delete-ghost-migrations
/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2008-2014 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
@jasonbeverage
jasonbeverage / extract_lightpoints.cpp
Created April 9, 2015 16:46
Light Point Extraction
typedef std::set< osg::Node* > NodeSet;
typedef std::map< osg::Node*, osg::ref_ptr< osg::Node > > CloneMap;
struct CopyNodesVisitor : public osg::NodeVisitor
{
CopyNodesVisitor(NodeSet& keepers):
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
_keepers(keepers),
_currentParent(0)
{
@jasonbeverage
jasonbeverage / ScreenSpaceCameraController.js
Created April 20, 2015 15:41
Disable pitch in Cesium 1.6
function rotate3D(controller, startPosition, movement, constrainedAxis, rotateOnlyVertical, rotateOnlyHorizontal) {
rotateOnlyVertical = defaultValue(rotateOnlyVertical, false);
rotateOnlyHorizontal = defaultValue(rotateOnlyHorizontal, false);
var scene = controller._scene;
var camera = scene.camera;
var canvas = scene.canvas;
var oldAxis = camera.constrainedAxis;
if (defined(constrainedAxis)) {
@jasonbeverage
jasonbeverage / flatten_spikes.py
Created August 7, 2015 17:00
Test script to flatten some spikes in some aster data.
from osgeo import gdal
import numpy as np
import os
ds = gdal.Open("UNIT_S60W070/ASTGTM2_S56W068_dem.tif")
band = ds.GetRasterBand(1)
data = band.ReadAsArray()
@jasonbeverage
jasonbeverage / osgcapture.cpp
Created December 15, 2015 20:50
Simple openscenegraph capture camera example
/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2015 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
@jasonbeverage
jasonbeverage / osgscreenshot.cpp
Created December 15, 2015 20:52
Simple application to load an osg model and take a screenshot of it.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield
*
* This application is open source and may be redistributed and/or modified
* freely and without restriction, both in commercial and non commercial applications,
* as long as this copyright notice is maintained.
*
* This application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
@jasonbeverage
jasonbeverage / quantized_heightfield.cpp
Created June 2, 2016 19:40
Test for zig zag encoding a heightfield.
/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2015 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
@jasonbeverage
jasonbeverage / osgearth_placemarks.cpp
Created June 29, 2016 19:08
Example of modifying PlaceNodes style at runtime in osgEarth
/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2015 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*