GeoDjango & HTML5 Geolocation

5,836 views
5,388 views

Published on

Presentation at September 2011 Lambda Lounge.

Published in: Technology
0 Comments
12 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,836
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
71
Comments
0
Likes
12
Embeds 0
No embeds

No notes for slide

GeoDjango & HTML5 Geolocation

  1. 1. GeoDjango & HTML5 GeolocationJohn Paulett john@paulett.orgSeptember 1, 2011 @johnpaulett
  2. 2. The PlanHTML5 GeolocationDjango Crash CourseWhat is GeoDjango?GeoDjango BasicsDemo Application
  3. 3. Geolocation
  4. 4. W3C GeolocationGPS, nearby Wi-Fi networks, cell towers, IPaddressIE 9, FF 3.6, Safari 5.0, Chrome, Opera 10.6, iOS,Androidnavigator.geolocation.getCurrentPositionnavigator.geolocation.watchPosition
  5. 5. W3C Geolocationfunction showMap(position) { console.log(position);}navigator.geolocation.getCurrentPosition( showMap);
  6. 6. W3C Geolocation{ "coords": { "accuracy": 22000, "altitude": null, "altitudeAccuracy": null, "heading": null, "latitude": 38.631756, "longitude": -90.24323, "speed": null }, "timestamp": 1314459776275}
  7. 7. Crash Course
  8. 8. models.pyfrom django.db import modelsclass City(models.Model): name = models.TextField()class UserGroup(models.Model): name = models.TextField() city = models.ForeignKey(City) started = models.DateField() def join(self, user): # add user to group
  9. 9. urls.pyurlpatterns = patterns( url( r^user-groups/(?P<city_name>w+)$, myapp.views.user_groups ),)
  10. 10. views.pydef user_groups(request, city_name): city = City.objects.get(name=city_name) groups = UserGroup.objects.filter(city=city) return render(request, user_groups.html, {groups: groups})
  11. 11. user_groups.html{% extends "base.html%}<ul> {% for group in groups %} <li> {{ group.name }} </li> {% endfor %}</ul>
  12. 12. What is GeoDjango?“world-class geographic Web framework”included in Django coreCombine existing Python & DB tools withstandard APIbut first …
  13. 13. Some GIS ProblemsThe Earth is not a sphere!How to store & query efficiently Vendor implementationsWide range of data formats Tiger/LINE, Shapefiles, E00, OGR, GeoJSON, WKT, EWKT, EWKB, GML, KML, OSM, GLOBE, TIFF, ArcGrid ….
  14. 14. GeoDjango Basics
  15. 15. GeoDjango Model Fieldsfrom django.contrib.gis.db import modelsmodels.PointFieldmodels.LineStringFieldmodels.PolygonFieldmodels.MultiPointFieldmodels.MultiLineStringFieldmodels.MultiPolygonFieldmodels.GeometryCollectionField
  16. 16. Given a Set of Geo ObjectsMeasure & Find: distance, area, perimeter, centroid, envelopeEdit: transform (SRID), scaleOperations: intersection, difference, unionOutput: geojson, gml, kml, svgSalesRegion.objects.all().kml()
  17. 17. Geo Queryingcontains, covers, crosses, disjoint, equals,intersects, touches, left/right, distance_lt,distance_gt …SalesRegion.objects.filter( poly__distance_lt=(pnt, D(mi=500)))
  18. 18. lambdageo
  19. 19. lambdageo http://lambdageo.ep.iohttp://github.com/johnpaulett/lambdageo
  20. 20. lambdageo.ep.io ●models.pyAdminViewsTemplates
  21. 21. Django Admin
  22. 22. GIS is CoolPython GIS Tile Servers, Mapnik, etc.Data Openstreet Maps, Census
  23. 23. lambdageo.ep.iogithub.com/johnpaulett/lambdageojohn@paulett.org / @johnpaulett
  24. 24. References
  25. 25. ReferencesPython Geospatial Development – ErikWestra
  26. 26. Referenceshttp://geodjango.org/http://dev.w3.org/geo/api/spec-source.htmlhttp://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/geolocation/http://caniuse.com/#search=geolocation

×