`GPXMapping` is a subclass of `LayerMapping` that imports GPX files into 3D GeoDjango models (requires Django 1.2 or SVN r11742 and higher). Here's an example of GeoDjango models for GPX points and tracks, respectively:
from django.contrib.gis.db import models
class GPXPoint(models.Model):
timestamp = models.DateTimeField()
point = models.PointField(dim=3)
objects = models.GeoManager()
def __unicode__(self):
return unicode(self.timestamp)
class GPXTrack(models.Model):
track = models.MultiLineStringField(dim=3)
objects = models.GeoManager()
Assuming the above models, then `GPXMapping` may be used to load GPX tracks and waypoints (including elevation Z values):
track_point_mapping = {'timestamp' : 'time',
'point' : 'POINT',
}
track_mapping = {'track' : 'MULTILINESTRING'}
gpx_file = '/path/to/file.gpx'
lm = GPXMapping(GPXPoint, gpx_file, track_point_mapping, layer='track_points')
lm.save(verbose=True)
lm = GPXMapping(GPXTrack, gpx_file, track_mapping, layer='tracks')
lm.save(verbose=True)
- gis
- geodjango
- 3d
- gpx
- layermapping
Calls a view by request.method value.
To use this dispatcher write your urls.py like this:
urlpatterns = pattern('',
url(r'^foo/$', dispatch(head=callable1,
get=callable2,
delete=callable3)),
)
If `request.method` is equal to head, `callable1` will be called as your usual view function;
if it is `get`, `callable2` will be called; et cetera.
If the method specified in request.method is not one handled by `dispatch(..)`,
`HttpResponseNotAllowed` is returned.
Use HTTP Authorization to log in to django site.
If you use the FORCE_HTTP_AUTH=True in your settings.py, then ONLY Http Auth will be used, if you don't then either http auth or django's session-based auth will be used. This assumes that the regular auth middleware is already installed.
If you provide a HTTP_AUTH_REALM in your settings, that will be used as the realm for the challenge.
Having both a decorator and a middleware means that for site-wide http auth, you only need to specify it once, but the same code can be used as a decorator if you want part of your site protected using htty basic auth, and the other bits freely visible.
Of course, since this is basic auth, then you need to make sure your site is running under SSL (HTTPS), else your users passwords are effectively transmitted in the clear.
- middleware
- decorator
- http-auth
- basic-auth