Last change
on this file since 9594 was 9594, checked in by rick, 13 years ago |
Nice hack for showing all nodes using geojson.
|
File size:
600 bytes
|
Line | |
---|
1 | from django.http import HttpResponse
|
---|
2 | from gheat.models import Node
|
---|
3 |
|
---|
4 | import json
|
---|
5 |
|
---|
6 |
|
---|
7 |
|
---|
8 | def nodes_json(request):
|
---|
9 | geojson = []
|
---|
10 | for node in Node.objects.filter(**request.REQUEST):
|
---|
11 | item = {
|
---|
12 | "type": "Feature",
|
---|
13 | "properties": {
|
---|
14 | 'name' : node.name,
|
---|
15 | },
|
---|
16 | "geometry": {
|
---|
17 | "type": "Point",
|
---|
18 | "coordinates": [
|
---|
19 | node.latitude,
|
---|
20 | node.longitude,
|
---|
21 | ]
|
---|
22 | }
|
---|
23 | }
|
---|
24 | geojson.append(item)
|
---|
25 | return HttpResponse(json.dumps({'type' : 'FeatureCollection', 'features' : geojson},indent=2), mimetype="text/plain")
|
---|
Note:
See
TracBrowser
for help on using the repository browser.