Skip to content

Instantly share code, notes, and snippets.

View andrewxhill's full-sized avatar

Andrew W. Hill andrewxhill

View GitHub Profile
@andrewxhill
andrewxhill / MOLTaxonomyModel.py
Created November 19, 2010 05:06
First implementation of a taxonomy model for the Map of Life project
class Species(db.Model):
authority = db.TextProperty()
classification = db.TextProperty()
names = db.TextProperty()
class SpeciesIndex(db.Model):
names = db.StringListProperty()
authorityName = db.StringProperty()
kingdom = db.StringProperty()
phylum = db.StringProperty()
@andrewxhill
andrewxhill / gist:863036
Created March 9, 2011 21:26
localhost quick work
#line 271
#comment out,
"""make sure that the keyname exists in MOL"""
"""
q = Species.get_by_key_name(species_key_name)
if not q:
self.error(404)
return
"""
#line 278, 279 swap which line is commented out
@andrewxhill
andrewxhill / gist:890806
Created March 28, 2011 16:45
canvas marker
renderMarkers: function(w,h,error){
var cnvs = $("<canvas width="+w+" height="+h+">");
var ctx = cnvs[0].getContext("2d");
ctx.drawImage(this.pmBackground, 0, 0, w, h);
if (this.type){
ctx.drawImage(this.pmType, 0, 0, w, h);
}
if (error){
mol.ui.Map.MarkerCanvas = mol.ui.Element.extend(
{
init: function() {
this._width = 120;
this._height = 120;
this._super('<canvas width='+this._width+' height='+this._height+'>');
this.setStyleName('mol-MarkerCanvas');
this._ctx = null;
this._canvasSupport = false;
/* Set up RightControl defaults */
#mol-Map-RightControl { margin-right: 5px; width: 290px; }
#mol-Map-RightControl .TOP { position: relative; float: left; width: 100%; height: auto; margin-bottom: 5px; }
#mol-Map-RightControl .MIDDLE { position: relative; float: left; width: 100%; height: auto; margin-bottom: 5px; }
#mol-Map-RightControl .BOTTOM { position: relative; float: left; width: 100%; height: auto; margin-bottom: 5px; }
/* Set up CenterControl defaults */
#mol-Map-CenterTopControl { margin-right: 5px; width: 290px; }
#mol-Map-CenterTopControl .TOP { position: relative; float: left; width: 100%; height: auto; margin-bottom: 5px; }
#mol-Map-CenterTopControl .MIDDLE { position: relative; float: left; width: 100%; height: auto; margin-bottom: 5px; }
result = {
SearchTerm: 'Puma',
SourceTypes : {
GBIFPoints : {
id: 1,
layers: [123,
0323,
434,
533,],
},
var mol = MOL(function(mol) {
bus = new mol.events.Bus();
api = new mol.ajax.Api(bus);
var config = {bus: bus, api: api, logging:true};
var app = new mol.app.Instance(config);
app.run();
return this;
});
@andrewxhill
andrewxhill / gist:935482
Created April 21, 2011 21:14
taxonomy service
# ------------------------------------------------------------------------------
# TaxonomyService
class TaxonomyProvider(object):
def __init__(self):
pass
def _key(self, k):
raise NotImplementedError()
class EcoregionLayerIndex(db.Model): #parent = an EcoregionSet
terms = db.CategoryProperty()
class EcoregionLayer(db.Model):
name = db.StringProperty()
id = db.StringProperty()
ecoCodes = db.ListProperty(db.Key)
class MOLLayers(db.Model):
layer = db.Key()
class OccurrenceSetIndex(db.Model): #parent = OccurrenceSet see below
terms = db.ListProperty() #string values to search for sets
class OccurrenceSet(db.Model): #key_name = wwf/puma_concolor or something
name = db.StringProperty() #this could be non-unique, Puma concolor is fine
source = db.StringProperty() #wwf
info = db.BlobProperty() #some meta standard for sets of occ polygons
class OccurrenceIndex(db.Model): #parent = OccurrencePolygon see below
introduced = db.BooleanProperty()