Successfully reported this slideshow.

GeoDjango & HTML5 Geolocation

13

Share

Upcoming SlideShare
Geo-Django Python
Geo-Django Python
Loading in …3
×
1 of 28
1 of 28

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

Related Audiobooks

Free with a 14 day trial from Scribd

See all

GeoDjango & HTML5 Geolocation

  1. 1. GeoDjango & HTML5 Geolocation John Paulett john@paulett.org September 1, 2011 @johnpaulett
  2. 2. The Plan HTML5 Geolocation Django Crash Course What is GeoDjango? GeoDjango Basics Demo Application
  3. 3. Geolocation
  4. 4. W3C Geolocation GPS, nearby Wi-Fi networks, cell towers, IP address IE 9, FF 3.6, Safari 5.0, Chrome, Opera 10.6, iOS, Android navigator.geolocation.getCurrentPosition navigator.geolocation.watchPosition
  5. 5. W3C Geolocation function 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.py from django.db import models class 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.py urlpatterns = patterns( url( r'^user-groups/(?P<city_name>w+)$', 'myapp.views.user_groups' ), )
  10. 10. views.py def 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 core Combine existing Python & DB tools with standard API but first …
  13. 13. Some GIS Problems The Earth is not a sphere! How to store & query efficiently Vendor implementations Wide 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 Fields from django.contrib.gis.db import models models.PointField models.LineStringField models.PolygonField models.MultiPointField models.MultiLineStringField models.MultiPolygonField models.GeometryCollectionField
  16. 16. Given a Set of Geo Objects Measure & Find: distance, area, perimeter, centroid, envelope Edit: transform (SRID), scale Operations: intersection, difference, union Output: geojson, gml, kml, svg SalesRegion.objects.all().kml()
  17. 17. Geo Querying contains, 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.io http://github.com/johnpaulett/lambdageo
  20. 20. lambdageo.ep.io ● models.py Admin Views Templates
  21. 21. Django Admin
  22. 22. GIS is Cool Python GIS Tile Servers, Mapnik, etc. Data Openstreet Maps, Census
  23. 23. lambdageo.ep.io github.com/johnpaulett/lambdageo john@paulett.org / @johnpaulett
  24. 24. References
  25. 25. References Python Geospatial Development – Erik Westra
  26. 26. References http://geodjango.org/ http://dev.w3.org/geo/api/spec-source.html http://src.chromium.org/viewvc/chrome/tru nk/src/chrome/browser/geolocation/ http://caniuse.com/#search=geolocation

×