GeoDjango & HTML5 Geolocation

  • 4,292 views
Uploaded on

Presentation at September 2011 Lambda Lounge.

Presentation at September 2011 Lambda Lounge.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
4,292
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
45
Comments
0
Likes
6

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. GeoDjango & HTML5 GeolocationJohn Paulett john@paulett.orgSeptember 1, 2011 @johnpaulett
  • 2. The PlanHTML5 GeolocationDjango Crash CourseWhat is GeoDjango?GeoDjango BasicsDemo Application
  • 3. Geolocation
  • 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. W3C Geolocationfunction showMap(position) { console.log(position);}navigator.geolocation.getCurrentPosition( showMap);
  • 6. W3C Geolocation{ "coords": { "accuracy": 22000, "altitude": null, "altitudeAccuracy": null, "heading": null, "latitude": 38.631756, "longitude": -90.24323, "speed": null }, "timestamp": 1314459776275}
  • 7. Crash Course
  • 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. urls.pyurlpatterns = patterns( url( r^user-groups/(?P<city_name>w+)$, myapp.views.user_groups ),)
  • 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. user_groups.html{% extends "base.html%}<ul> {% for group in groups %} <li> {{ group.name }} </li> {% endfor %}</ul>
  • 12. What is GeoDjango?“world-class geographic Web framework”included in Django coreCombine existing Python & DB tools withstandard APIbut first …
  • 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. GeoDjango Basics
  • 15. GeoDjango Model Fieldsfrom django.contrib.gis.db import modelsmodels.PointFieldmodels.LineStringFieldmodels.PolygonFieldmodels.MultiPointFieldmodels.MultiLineStringFieldmodels.MultiPolygonFieldmodels.GeometryCollectionField
  • 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. 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. lambdageo
  • 19. lambdageo http://lambdageo.ep.iohttp://github.com/johnpaulett/lambdageo
  • 20. lambdageo.ep.io ●models.pyAdminViewsTemplates
  • 21. Django Admin
  • 22. GIS is CoolPython GIS Tile Servers, Mapnik, etc.Data Openstreet Maps, Census
  • 23. lambdageo.ep.iogithub.com/johnpaulett/lambdageojohn@paulett.org / @johnpaulett
  • 24. References
  • 25. ReferencesPython Geospatial Development – ErikWestra
  • 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