Skip to content

Commit

Permalink
source code of treemapindia.in server
Browse files Browse the repository at this point in the history
  • Loading branch information
otm-india committed Nov 6, 2013
0 parents commit f7627b4
Show file tree
Hide file tree
Showing 2,946 changed files with 531,194 additions and 0 deletions.
540 changes: 540 additions & 0 deletions #OTMIndiaNewSchema1.sql#

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Authors:
Josh Livni
Kelaine Vargas
Carissa Brittain
Brian Jacobs
Mike Tedeschi
Deb Boyer
Erik Osheim

This file is part of the OpenTreeMap code.

OpenTreeMap is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OpenTreeMap 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. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with OpenTreeMap. If not, see <http://www.gnu.org/licenses/>.

65 changes: 65 additions & 0 deletions OTM_treeschema_india.sql~
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
CREATE TABLE "treemap_tree" (
"id" serial NOT NULL PRIMARY KEY,
"plot_id" integer NOT NULL REFERENCES "treemap_plot" ("id") DEFERRABLE INITIALLY DEFERRED,
"tree_owner" varchar(256),
"steward_name" varchar(256),
"steward_user_id" integer REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED,
"sponsor" varchar(256),
"species_id" integer REFERENCES "treemap_species" ("id") DEFERRABLE INITIALLY DEFERRED,
"species_other1" varchar(255),
"species_other2" varchar(255),
"orig_species" varchar(256),
"dbh" double precision,
"height" double precision,
"canopy_height" double precision,
"date_planted" date,
"date_removed" date,
"present" boolean NOT NULL,
"last_updated" timestamp with time zone NOT NULL,
"last_updated_by_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED,
"s_order" integer,
"photo_count" integer,
"projects" varchar(20),
"import_event_id" integer NOT NULL REFERENCES "treemap_importevent" ("id") DEFERRABLE INITIALLY DEFERRED,
"condition" varchar(256),
"canopy_condition" varchar(256),
"readonly" boolean NOT NULL,
"url" varchar(255),
"pests" varchar(256),
"tree_number" integer,
"prabhagid" integer,
"clusterid" integer,
"propertyid" varchar(256),
"girth_m" integer,
"height_m" integer,
"nest" varchar(256),
"burrows" varchar(256),
"flowers" varchar(256),
"fruits" varchar(256),
"nails" varchar(256),
"poster" varchar(256),
"wires" varchar(256),
"tree_guard" varchar(256),
"other_nuisance" boolean NOT NULL,
"other_nuisance_desc" varchar(256),
"health_of_tree" varchar(256),
"ground_type" varchar(256),
"ground_desc" varchar(256),
"risk_due_to_tree" varchar(256),
"risc_desc" varchar(256),
"refer_to_dept" varchar(256),
"special_other" varchar(256),
"special_other_desc" varchar(256),
"latitude" double precision,
"longitude" double precision,
"creation_date" timestamp with time zone,
"device_id" varchar(12),
"surveyor_id" varchar(256),
"session_id" integer,
"photo_focused1" varchar(100),
"photo_focused2" varchar(100),
"photo_panorama1" varchar(100),
"photo_panorama2" varchar(100),
"photo_other" varchar(100)
)
;
Binary file added OpenTreeMap-CLA-Corporate.pdf
Binary file not shown.
Binary file added OpenTreeMap-CLA-Individual.pdf
Binary file not shown.
124 changes: 124 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
![OpenTreeMap Logo](https://github.com/azavea/OpenTreeMap/raw/master/static/images/Philadelphia/es/2011_opentreemap_trans.png)

#Updates? Issues? Questions?#
For updates join the announcement email list here: http://groups.google.com/group/opentreemap-user
For issues or questions you can try mailing the user list: http://groups.google.com/group/opentreemap-user or connect with us via IRC at #opentreemap on freenode (freenode.net).

This is v1.3 of OpenTreeMap, the in development version.

#Other Repositories
OpenTreeMap is also available for iOS and Android.

iOS app code is available at https://github.com/azavea/OpenTreeMap-iOS <br>
Default graphics and config files for the OpenTreeMap iOS app are available at https://github.com/azavea/OpenTreeMap-iOS-skin

Android app code is available at https://github.com/azavea/OpenTreeMap-Android <br>
A default skin is included in the repository, as are "howto.pdf" build instructions.

#Installation Instructions#
###Required programs:###
* Webserver - Gunicorn is recommended
* Database - Postgres 8.1 + postgis 1.5 is recommended (postgis 2.0+ is not yet supported)
* Map tile renderer - GeoServer(java) on tomcat is recommended
* SMTP service - sendmail is recommended
* tile caching service - tilecache is recommended (port 8080 through apache)
* Python 2.7

###Required python libraries (installed via pip)###
* BeautifulSoup (3.2.0)
* Django (1.3.4)
* PIL (1.1.7)
* South (0.7.5)
* Unidecode (0.04.9)
* django-badges (0.1.6)
* django-debug-toolbar (0.9.1)
* django-extensions (0.7.1)
* django-pagination (1.0.7)
* django-profiles (0.2)
* django-shapes (0.2.0)
* django-sorting (0.1)
* django-tagging (0.3.1)
* django-threadedcomments
* django-pipeline (1.1.27)
* feedparser (5.1)
* geopy (0.94.1)
* psycopg2 (2.4.1)
* python-omgeo (1.4.1)
* simplejson (2.3.2)
* sorl-thumbnail (11.12)
* template-utils (0.4p2)
* wsgiref (0.1.2)
* xlrd (0.7.1)
* yuicompressor (2.4.6.1)

###Optional libraries###
* gunicorn (0.14.3) (via pip)
* libapache2-mod-wsgi (if you want to run with apache) (via apt)

###Required libraries from aptitude###
* binutils
* libgeos-3.2.0
* libgeos-c1
* libgdal1-1.6.0
* libproj0
* gdal-bin

###Required libraries from the web###
* wget http://sourceforge.net/projects/dbfpy/files/dbfpy/2.2.5/dbfpy-2.2.5.tar.gz
* wget https://bitbucket.org/ubernostrum/django-registration/downloads/django-registration-0.8-alpha-1.tar.gz
* git clone git://github.com/miracle2k/webassets.git
* pip install django-pipeline==1.1.27

###Patches:###
Fix to proj to deal with spherical mercator
wget http://download.osgeo.org/proj/proj-datumgrid-1.4.tar.gz
tar -xzf /proj-datumgrid-1.4.tar.gz
cd proj-datumgrid-1.4
nad2bin null < null.lla
sudo cp null /usr/share/proj
Get django-sorting and fix bug
git clone git://github.com/directeur/django-sorting.git
Apply patch to django-sorting:
https://github.com/directeur/django-sorting/issues#issue/8
-including comment by Alsaihn
sudo cp django_sorting -R /usr/local/lib/python2.6/dist-packages/django_sorting
Get django-shapes and remove HttpResponse call
wget https://bitbucket.org/springmeyer/django-shapes/get/tip.tar.gz
In shapes/views/export.py - zip-response method - change >
# Stick it all in a django HttpResponse
#response = HttpResponse(zip_stream, mimetype=mimetype)
#response['Content-Disposition'] = 'attachment; filename=%s.zip' % file_name.replace('.shp','')
#response['Content-length'] = str(len(zip_stream))
#response['Content-Type'] = mimetype
#response.write(zip_stream)
return zip_stream

Get django-reputation and fix default config and user bug
svn checkout http://django-reputation.googlecode.com/svn/trunk/ django-reputation
cd django-reputation
sudo cp django_reputation -R /usr/local/lib/python2.6/dist-packages/django_reputation
Change default config and user bug: (b/c it doesn't seem to accept values in settings.py)
cd /usr/local/lib/python2.6/dist-packages/django_reputation
In config.py - <change values as needed>
In model.py - change >
....
relevant_reputation_actions = UserReputationAction.objects.filter(user=user).filter........
....
if expected_delta <= MAX_REPUTATION_GAIN_PER_DAY and expected_delta >= -1 * MAX_REPUTATION_LOSS_PER_DAY:
delta = action_value
elif expected_delta > MAX_REPUTATION_GAIN_PER_DAY:
delta = 0
elif expected_delta < MAX_REPUTATION_LOSS_PER_DAY:
delta = 0
...
Fix Tilecache TMS issue
In tilecache/Services/TMS.py - change >
...
elif len(parts) < 2:
return self.serviceCapabilities(host, self.service.layers)
else:
+ parts = parts[-5:]
layer = self.getLayer(parts[1])
if len(parts) < 3:
return self.layerCapabilities(host, layer)
...
15 changes: 15 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.

# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise32"

config.vm.forward_port 80, 6064

config.vm.share_folder "v-data", "/usr/local/otm/app", "."
end
Empty file added __init__.py
Empty file.
Binary file added __init__.pyc
Binary file not shown.
Empty file added api/__init__.py
Empty file.
Binary file added api/__init__.pyc
Binary file not shown.
68 changes: 68 additions & 0 deletions api/auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from django.http import HttpResponse
from django.contrib.auth import authenticate
import re
import base64
from functools import wraps

def create_401unauthorized(body="Unauthorized"):
res = HttpResponse(body)
res.status_code = 401
res['WWW-Authenticate'] = 'Basic realm="Secure Area"'
return res

def firstmatch(regx, strg):
m = re.match(regx, strg)
if (m == None):
return None
else:
return m.group(1)

def decodebasicauth(strg):
if (strg == None):
return None
else:
m = re.match(r'([^:]*)\:(.*)', base64.decodestring(strg))
if (m != None):
return (m.group(1), m.group(2))
else:
return None

def parse_basicauth(authstr):
auth = decodebasicauth(firstmatch('Basic (.*)', authstr))
if (auth == None):
return None
else:
return authenticate(username = auth[0], password = auth[1])

def parse_user_from_request(request):
user = None
if (request.META.has_key('HTTP_AUTHORIZATION')):
auth = request.META['HTTP_AUTHORIZATION']
user = parse_basicauth(auth)

return user

def login_required(view_f):
@wraps(view_f)
def wrapperf(request, *args, **kwargs):
user = parse_user_from_request(request)

if (user != None):
request.user = user
return view_f(request, *args, **kwargs)

return create_401unauthorized()

return wrapperf

def login_optional(view_f):
@wraps(view_f)
def wrapperf(request, *args, **kwargs):
user = parse_user_from_request(request)

if (user != None):
request.user = user

return view_f(request, *args, **kwargs)

return wrapperf
Binary file added api/auth.pyc
Binary file not shown.
Loading

0 comments on commit f7627b4

Please sign in to comment.