From d99fafc332c71f60fac482bf28268f1c75bad370 Mon Sep 17 00:00:00 2001 From: sanj Date: Mon, 15 Mar 2010 17:00:31 +0530 Subject: [PATCH] first commit --- vurbanism/__init__.py | 0 vurbanism/flyovers/__init__.py | 0 vurbanism/flyovers/admin.py | 42 +++ vurbanism/flyovers/models.py | 77 ++++++ vurbanism/flyovers/tests.py | 23 ++ vurbanism/flyovers/views.py | 1 + vurbanism/importMyMaps.py | 19 ++ vurbanism/manage.py | 11 + vurbanism/settings.py | 86 ++++++ vurbanism/templates/gis/admin/google.html | 4 + vurbanism/templates/gis/admin/google.js | 11 + vurbanism/test_mymaps.xml | 315 ++++++++++++++++++++++ vurbanism/urls.py | 17 ++ 13 files changed, 606 insertions(+) create mode 100644 vurbanism/__init__.py create mode 100644 vurbanism/flyovers/__init__.py create mode 100644 vurbanism/flyovers/admin.py create mode 100644 vurbanism/flyovers/models.py create mode 100644 vurbanism/flyovers/tests.py create mode 100644 vurbanism/flyovers/views.py create mode 100644 vurbanism/importMyMaps.py create mode 100755 vurbanism/manage.py create mode 100644 vurbanism/settings.py create mode 100644 vurbanism/templates/gis/admin/google.html create mode 100644 vurbanism/templates/gis/admin/google.js create mode 100644 vurbanism/test_mymaps.xml create mode 100644 vurbanism/urls.py diff --git a/vurbanism/__init__.py b/vurbanism/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/vurbanism/flyovers/__init__.py b/vurbanism/flyovers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/vurbanism/flyovers/admin.py b/vurbanism/flyovers/admin.py new file mode 100644 index 0000000..6b31f0d --- /dev/null +++ b/vurbanism/flyovers/admin.py @@ -0,0 +1,42 @@ +from django.contrib.gis import admin +from django.contrib.gis.maps.google import GoogleMap +from models import * +from django.conf import settings + +class ImageInline(admin.TabularInline): + model = Image + extra = 5 + +class VideoInline(admin.TabularInline): + model = Video + extra = 3 + +class AudioInline(admin.TabularInline): + model = Audio + extra = 2 + +class TextInline(admin.TabularInline): + model = Text + extra = 4 + +class FlyoverAdmin(admin.OSMGeoAdmin): + fieldsets = ( + ('Flyover Data', {'fields': (('point','name', 'txt',)), 'classes': ('show','extrapretty')}), + ) + map_template = 'gis/admin/google.html' + default_lon = 72.855211097628413 + default_lat = 19.415775291486027 + default_zoom = 4 + extra_js = ['http://openstreetmap.org/openlayers/OpenStreetMap.js', 'http://maps.google.com/maps?file=api&v=2&key=%s' % settings.GOOGLE_MAPS_API_KEY] + inlines = [ImageInline, VideoInline, AudioInline, TextInline] + +admin.site.register(Flyover, FlyoverAdmin) +admin.site.register(Image) +admin.site.register(ImageCategory) +admin.site.register(Video) +admin.site.register(VideoCategory) +admin.site.register(Audio) +admin.site.register(AudioCategory) +admin.site.register(Text) +admin.site.register(TextCategory) + diff --git a/vurbanism/flyovers/models.py b/vurbanism/flyovers/models.py new file mode 100644 index 0000000..cd7b201 --- /dev/null +++ b/vurbanism/flyovers/models.py @@ -0,0 +1,77 @@ +from django.contrib.gis.db import models + + +class Flyover(models.Model): + point = models.PointField() + name = models.CharField(max_length=255) + txt = models.TextField(blank=True, null=True) + objects = models.GeoManager() + + def __unicode__(self): + return self.name + +class Image(models.Model): + url = models.URLField("FlickR URL") + caption = models.CharField(max_length=255, blank=True, null=True) + category = models.ForeignKey("ImageCategory") + flyover = models.ForeignKey(Flyover) + + def __unicode__(self): + return self.url + " - " + self.caption + " - " + self.category.name + +class ImageCategory(models.Model): + name = models.CharField(max_length=255) + description = models.TextField(blank=True, null=True) + + def __unicode__(self): + return self.name + +class Video(models.Model): + url = models.URLField("Youtube URL") + caption = models.CharField(max_length=255, blank=True, null=True) + category = models.ForeignKey("VideoCategory") + flyover = models.ForeignKey(Flyover) + + def __unicode__(self): + return self.url + " - " + self.caption + " - " + self.category.name + +class VideoCategory(models.Model): + name = models.CharField(max_length=255) + description = models.TextField(blank=True, null=True) + + def __unicode__(self): + return self.name + +class Audio(models.Model): + url = models.URLField("Audio URL") + caption = models.CharField(max_length=255, blank=True, null=True) + category = models.ForeignKey("AudioCategory") + flyover = models.ForeignKey(Flyover) + + def __unicode__(self): + return self.url + " - " + self.caption + " - " + self.category.name + +class AudioCategory(models.Model): + name = models.CharField(max_length=255) + description = models.TextField(blank=True, null=True) + + def __unicode__(self): + return self.name + +class Text(models.Model): +# url = models.URLField("FlickR URL") + text = models.TextField(max_length=255) + category = models.ForeignKey("TextCategory") + flyover = models.ForeignKey(Flyover) + + def __unicode__(self): + return self.text + " - " + self.category.name + +class TextCategory(models.Model): + name = models.CharField(max_length=255) + description = models.TextField(blank=True, null=True) + + def __unicode__(self): + return self.name + +# Create your models here. diff --git a/vurbanism/flyovers/tests.py b/vurbanism/flyovers/tests.py new file mode 100644 index 0000000..2247054 --- /dev/null +++ b/vurbanism/flyovers/tests.py @@ -0,0 +1,23 @@ +""" +This file demonstrates two different styles of tests (one doctest and one +unittest). These will both pass when you run "manage.py test". + +Replace these with more appropriate tests for your application. +""" + +from django.test import TestCase + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.failUnlessEqual(1 + 1, 2) + +__test__ = {"doctest": """ +Another way to test that 1 + 1 is equal to 2. + +>>> 1 + 1 == 2 +True +"""} + diff --git a/vurbanism/flyovers/views.py b/vurbanism/flyovers/views.py new file mode 100644 index 0000000..60f00ef --- /dev/null +++ b/vurbanism/flyovers/views.py @@ -0,0 +1 @@ +# Create your views here. diff --git a/vurbanism/importMyMaps.py b/vurbanism/importMyMaps.py new file mode 100644 index 0000000..c7f0b56 --- /dev/null +++ b/vurbanism/importMyMaps.py @@ -0,0 +1,19 @@ +import elementtree.ElementTree as ET +from django.contrib.gis.geos import Point +from flyovers.models import * + +def parseXml(fname): + root = ET.parse(fname).getroot() + channel = root.find('channel') + for item in channel.findall('item'): + title = item.find('title').text + description = item.find('description').text or '' + pt = item.find("{http://www.georss.org/georss}point").text.strip().split(" ") + lat = float(pt[0]) + lng = float(pt[1]) + point = Point(lng, lat,) + print point + f = Flyover(name=title, txt=description, point=point) + f.save() +# pt = item.find('georss:point').text + diff --git a/vurbanism/manage.py b/vurbanism/manage.py new file mode 100755 index 0000000..5e78ea9 --- /dev/null +++ b/vurbanism/manage.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +from django.core.management import execute_manager +try: + import settings # Assumed to be in the same directory. +except ImportError: + import sys + sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) + sys.exit(1) + +if __name__ == "__main__": + execute_manager(settings) diff --git a/vurbanism/settings.py b/vurbanism/settings.py new file mode 100644 index 0000000..481cda2 --- /dev/null +++ b/vurbanism/settings.py @@ -0,0 +1,86 @@ +# Django settings for vurbanism project. +import os +from os.path import join + +PROJECT_PATH = os.path.dirname(__file__) +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +ADMINS = ( + # ('Your Name', 'your_email@domain.com'), +) + +MANAGERS = ADMINS +GOOGLE_MAPS_API_KEY = 'ABQIAAAAnfs7bKE82qgb3Zc2YyS-oBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSySz_REpPq-4WZA27OwgbtyR3VcA' +DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. +DATABASE_NAME = 'vurbanism' # Or path to database file if using sqlite3. +DATABASE_USER = 'root' # Not used with sqlite3. +DATABASE_PASSWORD = '' # Not used with sqlite3. +DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. +DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. + +# Local time zone for this installation. Choices can be found here: +# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +# although not all choices may be available on all operating systems. +# If running in a Windows environment this must be set to the same as your +# system time zone. +TIME_ZONE = 'America/Chicago' + +# Language code for this installation. All choices can be found here: +# http://www.i18nguy.com/unicode/language-identifiers.html +LANGUAGE_CODE = 'en-us' + +SITE_ID = 1 + +# If you set this to False, Django will make some optimizations so as not +# to load the internationalization machinery. +USE_I18N = True + +# Absolute path to the directory that holds media. +# Example: "/home/media/media.lawrence.com/" +MEDIA_ROOT = '' + +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash if there is a path component (optional in other cases). +# Examples: "http://media.lawrence.com", "http://example.com/media/" +MEDIA_URL = '' + +# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a +# trailing slash. +# Examples: "http://foo.com/media/", "/media/". +ADMIN_MEDIA_PREFIX = '/media/' + +# Make this unique, and don't share it with anybody. +SECRET_KEY = ')s6v_j@m(o3n5qm0i^2h+#q3v+ltwkklkbxp#gz)#9vm_#-7&z' + +# List of callables that know how to import templates from various sources. +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.load_template_source', + 'django.template.loaders.app_directories.load_template_source', +# 'django.template.loaders.eggs.load_template_source', +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', +) + +ROOT_URLCONF = 'vurbanism.urls' + +TEMPLATE_DIRS = ( + join(PROJECT_PATH, 'templates') + # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". + # Always use forward slashes, even on Windows. + # Don't forget to use absolute paths, not relative paths. +) + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.admin', + 'django.contrib.gis', + 'flyovers', +) diff --git a/vurbanism/templates/gis/admin/google.html b/vurbanism/templates/gis/admin/google.html new file mode 100644 index 0000000..1134839 --- /dev/null +++ b/vurbanism/templates/gis/admin/google.html @@ -0,0 +1,4 @@ +{% extends "gis/admin/openlayers.html" %} +{% block openlayers %} +{% include "gis/admin/google.js" %} +{% endblock %} diff --git a/vurbanism/templates/gis/admin/google.js b/vurbanism/templates/gis/admin/google.js new file mode 100644 index 0000000..ed9090d --- /dev/null +++ b/vurbanism/templates/gis/admin/google.js @@ -0,0 +1,11 @@ +{% extends "gis/admin/openlayers.js" %} +{% block base_layer %} +new OpenLayers.Layer.Google("Google Terrain", {type: G_PHYSICAL_MAP, 'sphericalMercator': true}); +{% endblock %} + +{% block extra_layers %} + {{ module }}.layers.overlay = new OpenLayers.Layer.OSM.Mapnik("OpenStreetMap (Mapnik)"); + {{ module }}.map.addLayer({{ module }}.layers.overlay); +{% endblock %} + + diff --git a/vurbanism/test_mymaps.xml b/vurbanism/test_mymaps.xml new file mode 100644 index 0000000..2f403f2 --- /dev/null +++ b/vurbanism/test_mymaps.xml @@ -0,0 +1,315 @@ + + + + http://maps.google.com + Mumbaiflyovers + + + 000467cd891cf78f803f5 + Sat, 18 Apr 2009 05:26:13 +0000 + + Sahar Airport Flyover + Sahar Elevated Access Road linking Western Highway with Chhatrapati Shivaji International Airport]]> + andrewjharris + + 19.102898 72.866501 + + + + + 000467cd977ed767fb9ed + Sat, 18 Apr 2009 05:30:14 +0000 + Kalanagar Thackere Flyover + + andrewjharris + + 19.054695 72.846306 + + + + + 000467ce09f31ad2a85bf + Sat, 18 Apr 2009 06:02:14 +0000 + L and T flyover + IMG_5706 +]]> + andrewjharris + + + 19.124968 72.893150 + + + + 000467ce0d8e0b58f5439 + Sat, 18 Apr 2009 06:03:15 +0000 + Jogeshwari Flyover + + + andrewjharris + + 19.140568 72.854858 + + + + 000467ce14bb91dcf5ccf + + Sat, 18 Apr 2009 06:05:15 +0000 + Placemark 5 + + andrewjharris + + 19.128778 72.920067 + + + + + 000467cee442527126c52 + Sat, 18 Apr 2009 07:03:17 +0000 + Placemark 6 + + andrewjharris + + + 19.125200 72.925072 + + + + 000467d0715d910a760ed + Sat, 18 Apr 2009 08:54:19 +0000 + Andheri Flyover + mumbai07 237]]> + + andrewjharris + + 19.112692 72.854507 + + + + 000467d0715db05823f01 + Sat, 18 Apr 2009 08:54:19 +0000 + + barfiwala lane + + andrewjharris + + 19.116016 72.844353 + + + + + 000467d0750d936338b3f + Sat, 18 Apr 2009 08:55:21 +0000 + Goregaon + + andrewjharris + + 19.165154 72.858368 + + + + + 000467d078ae1fcc78e80 + Sat, 18 Apr 2009 08:56:22 +0000 + Kandivali Times of India + IMG_5789]]> + andrewjharris + + + 19.191698 72.858498 + + + + 000467d1c92c444d10e95 + Sat, 18 Apr 2009 10:30:27 +0000 + Borivali + + IMG_5823]]> + andrewjharris + + 19.206663 72.866318 + + + + 000467d1cccfb431b481a + + Sat, 18 Apr 2009 10:31:28 +0000 + Borivali2 + + andrewjharris + + 19.221512 72.865341 + + + + + 000467d1d072ae8aaea0d + Sat, 18 Apr 2009 10:32:29 +0000 + Placemark 13 + + andrewjharris + + + 19.232805 72.863380 + + + + 000468146385ccfd3e61f + Tue, 21 Apr 2009 17:58:05 +0000 + Thane Station + ]]> + + andrewjharris + + 19.187164 72.976425 + + + + 0004681474a3a5c53b135 + Tue, 21 Apr 2009 18:02:52 +0000 + + turbhe + ]]> + andrewjharris + + 19.065767 73.018829 + + + + + 0004686e8ad5932f80da5 + Sun, 26 Apr 2009 05:31:31 +0000 + Kurla Flyover + + andrewjharris + + + 19.067472 72.888405 + + + + 0004686e8ad968e0c2359 + Sun, 26 Apr 2009 05:31:32 +0000 + Kurla Flyover Model + + + andrewjharris + + 19.067959 72.885490 + + + + 0004686e8f60b1cafc8eb + Sun, 26 Apr 2009 05:32:48 +0000 + + Kurla Flyover South + ]]> + andrewjharris + + 19.065565 72.887077 + + + + + 0004686f7eb8df73ab5b5 + Sun, 26 Apr 2009 06:39:43 +0000 + TulsiPipeRoad + ]]> + andrewjharris + + 19.009094 72.833221 + + + + + 000468775d0a2eae41fee + Sun, 26 Apr 2009 16:02:58 +0000 + thane-belapur road + IMG_6438]]> + andrewjharris + + + 19.112326 73.009094 + + + + 000468776cbac3dbfe2de + Sun, 26 Apr 2009 16:07:21 +0000 + Kemps Corner Flyover + + IMG_6404]]> + andrewjharris + + 18.964142 72.807579 + + + + 00046877754e1ce7e6ae6 + + Sun, 26 Apr 2009 16:09:45 +0000 + Santa Cruz skywalk + IMG_6295]]> + andrewjharris + + 19.080309 72.846542 + + + + + 0004687782180c7d85660 + Sun, 26 Apr 2009 16:13:19 +0000 + Khargar FLyover + IMG_6180]]> + andrewjharris + + + 19.032080 73.065994 + + + + 0004687785af89bfeeff1 + Sun, 26 Apr 2009 16:14:20 +0000 + Kurla flyover + IMG_6050]]> + + andrewjharris + + 19.066418 72.887894 + + + + 00046878e54ca834f6fc1 + Sun, 26 Apr 2009 17:52:39 +0000 + + turningfromEEHtoSionTrombay Road + IMG_5940]]> + andrewjharris + + 19.052464 72.882355 + + + + + 00046878eee914f007c9c + Sun, 26 Apr 2009 17:55:20 +0000 + Siontobyculla flyovers + IMG_5385]]> + andrewjharris + + 18.997652 72.837341 + + + + + 00046878f280305a195aa + Sun, 26 Apr 2009 17:56:20 +0000 + JJ/Mohammed Ali Flyover +
]]>
+ andrewjharris + + + 18.960985 72.831955 + +
+
+
+ diff --git a/vurbanism/urls.py b/vurbanism/urls.py new file mode 100644 index 0000000..5e779bc --- /dev/null +++ b/vurbanism/urls.py @@ -0,0 +1,17 @@ +from django.conf.urls.defaults import * + +# Uncomment the next two lines to enable the admin: +from django.contrib import admin +admin.autodiscover() + +urlpatterns = patterns('', + # Example: + # (r'^vurbanism/', include('vurbanism.foo.urls')), + + # Uncomment the admin/doc line below and add 'django.contrib.admindocs' + # to INSTALLED_APPS to enable admin documentation: + # (r'^admin/doc/', include('django.contrib.admindocs.urls')), + + # Uncomment the next line to enable the admin: + (r'^admin/', include(admin.site.urls)), +)