SlideShare a Scribd company logo
1 of 28
Download to read offline
GeoDjango &
       HTML5 Geolocation


John Paulett        john@paulett.org
September 1, 2011       @johnpaulett
The Plan
HTML5 Geolocation


Django Crash Course


What is GeoDjango?


GeoDjango Basics


Demo Application
Geolocation
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
W3C Geolocation
function showMap(position) {
     console.log(position);
}


navigator.geolocation.getCurrentPosition(
     showMap
);
W3C Geolocation
{
    "coords": {
         "accuracy": 22000,
         "altitude": null,
         "altitudeAccuracy": null,
         "heading": null,
         "latitude": 38.631756,
         "longitude": -90.24323,
         "speed": null
    },
    "timestamp": 1314459776275
}
Crash Course
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
urls.py
urlpatterns = patterns(
    url(
         r'^user-groups/(?P<city_name>w+)$',
         'myapp.views.user_groups'
    ),
)
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})
user_groups.html
{% extends "base.html%}


<ul>
   {% for group in groups %}
        <li>
           {{ group.name }}
        </li>
   {% endfor %}
</ul>
What is GeoDjango?
“world-class geographic Web framework”
included in Django core


Combine existing Python & DB tools with
standard API


but first …
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 ….
GeoDjango Basics
GeoDjango Model Fields
from django.contrib.gis.db import models


models.PointField
models.LineStringField
models.PolygonField
models.MultiPointField
models.MultiLineStringField
models.MultiPolygonField
models.GeometryCollectionField
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()
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))
)
lambdageo
lambdageo



     http://lambdageo.ep.io



http://github.com/johnpaulett/lambdageo
lambdageo.ep.io
        ●



models.py
Admin
Views
Templates
Django Admin
GIS is Cool
Python GIS
 Tile Servers, Mapnik, etc.


Data
 Openstreet Maps, Census
lambdageo.ep.io

github.com/johnpaulett/lambdageo

john@paulett.org / @johnpaulett
References
References
Python Geospatial Development – Erik
Westra
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

More Related Content

Similar to GeoDjango & HTML5 Geolocation

Demoiselle Spatial Latinoware 2011
Demoiselle Spatial Latinoware 2011Demoiselle Spatial Latinoware 2011
Demoiselle Spatial Latinoware 2011
Rafael Soto
 
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
CoLab Athens
 
Geolocation on Rails
Geolocation on RailsGeolocation on Rails
Geolocation on Rails
nebirhos
 
Mapping, GIS and geolocating data in Java
Mapping, GIS and geolocating data in JavaMapping, GIS and geolocating data in Java
Mapping, GIS and geolocating data in Java
Joachim Van der Auwera
 

Similar to GeoDjango & HTML5 Geolocation (20)

PyDX Presentation about Python, GeoData and Maps
PyDX Presentation about Python, GeoData and MapsPyDX Presentation about Python, GeoData and Maps
PyDX Presentation about Python, GeoData and Maps
 
Scripting GeoServer
Scripting GeoServerScripting GeoServer
Scripting GeoServer
 
Geo django
Geo djangoGeo django
Geo django
 
mobl
moblmobl
mobl
 
Django101 geodjango
Django101 geodjangoDjango101 geodjango
Django101 geodjango
 
Demoiselle Spatial Latinoware 2011
Demoiselle Spatial Latinoware 2011Demoiselle Spatial Latinoware 2011
Demoiselle Spatial Latinoware 2011
 
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
 
Saving Gaia with GeoDjango
Saving Gaia with GeoDjangoSaving Gaia with GeoDjango
Saving Gaia with GeoDjango
 
Geolocation on Rails
Geolocation on RailsGeolocation on Rails
Geolocation on Rails
 
Green dao
Green daoGreen dao
Green dao
 
Mapping, GIS and geolocating data in Java
Mapping, GIS and geolocating data in JavaMapping, GIS and geolocating data in Java
Mapping, GIS and geolocating data in Java
 
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
 
Mapping, GIS and geolocating data in Java @ JAX London
Mapping, GIS and geolocating data in Java @ JAX LondonMapping, GIS and geolocating data in Java @ JAX London
Mapping, GIS and geolocating data in Java @ JAX London
 
Java Tech & Tools | Mapping, GIS and Geolocating Data in Java | Joachim Van d...
Java Tech & Tools | Mapping, GIS and Geolocating Data in Java | Joachim Van d...Java Tech & Tools | Mapping, GIS and Geolocating Data in Java | Joachim Van d...
Java Tech & Tools | Mapping, GIS and Geolocating Data in Java | Joachim Van d...
 
Google Maps Api
Google Maps ApiGoogle Maps Api
Google Maps Api
 
Open@EDINA
Open@EDINAOpen@EDINA
Open@EDINA
 
Geolocation in Drupal
Geolocation in DrupalGeolocation in Drupal
Geolocation in Drupal
 
Trimming The Cruft
Trimming The CruftTrimming The Cruft
Trimming The Cruft
 
huhu
huhuhuhu
huhu
 
What's New in Android
What's New in AndroidWhat's New in Android
What's New in Android
 

More from John Paulett (8)

XNAT Case Study: DIAN QC Uploader
XNAT Case Study: DIAN QC UploaderXNAT Case Study: DIAN QC Uploader
XNAT Case Study: DIAN QC Uploader
 
XNAT Open Source Development
XNAT Open Source DevelopmentXNAT Open Source Development
XNAT Open Source Development
 
XNAT Tuning & Monitoring
XNAT Tuning & MonitoringXNAT Tuning & Monitoring
XNAT Tuning & Monitoring
 
Mercurial: Modern Source Control Management
Mercurial: Modern Source Control ManagementMercurial: Modern Source Control Management
Mercurial: Modern Source Control Management
 
PostgreSQL Scaling And Failover
PostgreSQL Scaling And FailoverPostgreSQL Scaling And Failover
PostgreSQL Scaling And Failover
 
Drools
DroolsDrools
Drools
 
Automated Testing
Automated TestingAutomated Testing
Automated Testing
 
Getting Started with (Distributed) Version Control
Getting Started with (Distributed) Version ControlGetting Started with (Distributed) Version Control
Getting Started with (Distributed) Version Control
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 

GeoDjango & HTML5 Geolocation