first "map of maps" experiment

dev-mapofmaps
Hartmut Holzgraefe 2017-07-03 07:22:30 +00:00
rodzic 9d88f7d72b
commit a91091b904
6 zmienionych plików z 120 dodań i 2 usunięć

Wyświetl plik

@ -29,6 +29,9 @@
"leaflet-areaselect": "*",
"leaflet-locationfilter": "*",
"leaflet-providers": "^1.1.15",
"leaflet.locatecontrol": "^0.62.0"
"leaflet.locatecontrol": "^0.62.0",
"leaflet.deflate": "^0.2.1",
"leaflet.markercluster": "^1.0.6",
"leaflet.markercluster.layersupport": "^1.0.4"
}
}

Wyświetl plik

@ -38,6 +38,9 @@ import ocitysmap
from www.maposmatic import helpers, forms, nominatim, models
import www.settings
from itertools import *
from django.db import connection
LOG = logging.getLogger('maposmatic')
try:
@ -48,6 +51,22 @@ except ImportError:
except ImportError:
from json import write as json_encode
def query_to_dicts(query_string, *query_args):
"""Run a simple query and produce a generator
that returns the results as a bunch of dictionaries
with keys for the column values selected.
"""
cursor = connection.cursor()
cursor.execute(query_string, query_args)
col_names = [desc[0] for desc in cursor.description]
while True:
row = cursor.fetchone()
if row is None:
break
row_dict = dict(izip(col_names, row))
yield row_dict
return
def index(request):
"""The main page."""
form = forms.MapSearchForm(request.GET)
@ -174,6 +193,19 @@ def maps(request):
'pages': helpers.get_pages_list(maps, paginator) },
context_instance=RequestContext(request))
def mapofmaps(request):
results = query_to_dicts("""
select id
, maptitle
, lon_upper_left AS lon1
, lat_upper_left AS lat1
, lon_bottom_right AS lon2
, lat_bottom_right AS lat2
from maposmatic_maprenderingjob
where status=2;
""")
return render_to_response('maposmatic/mapofmaps.html', { 'results': results }, context_instance=RequestContext(request))
def recreate(request):
if request.method == 'POST':

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -68,7 +68,15 @@
<link rel="stylesheet" href="/media/bower/leaflet.locatecontrol/dist/L.Control.Locate.min.css" />
<script src="/media/bower/leaflet.locatecontrol/dist/L.Control.Locate.min.js" charset="utf-8"></script>
</head>
<script src="/media/bower/leaflet.deflate/dist/L.Deflate.js"></script>
<link rel="stylesheet" href="/media/bower/leaflet.markercluster/dist/MarkerCluster.css" />
<link rel="stylesheet" href="/media/bower/leaflet.markercluster/dist/MarkerCluster.Default.css" />
<script src="/media/bower/leaflet.markercluster/dist/leaflet.markercluster-src.js"></script>
<script src="/media/js/leaflet.markercluster.layersupport.js"></script>
</head>
<body class="{% block body-class %}{% endblock %}">
<div class="navbar navbar-inverse navbar-fixed-top">

Wyświetl plik

@ -0,0 +1,65 @@
{% extends "maposmatic/base.html" %}
{% comment %}
coding: utf-8
maposmatic, the web front-end of the MapOSMatic city map generation system
Copyright (C) 2012 David Decotigny
Copyright (C) 2012 Frédéric Lehobey
Copyright (C) 2012 Pierre Mauduit
Copyright (C) 2012 David Mentré
Copyright (C) 2012 Maxime Petazzoni
Copyright (C) 2012 Thomas Petazzoni
Copyright (C) 2012 Gaël Utard
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
{% endcomment %}
{% load i18n %}
{% load extratags %}
{% block body-class %}maps{% endblock %}
{% block menu-maps %}active{% endblock %}
{% block title %}{% trans "Map of maps" %}{% endblock %}
{% block page %}
<h1>Hallo!</h1>
<div id='foomap' style="width: 600px; height: 400px;"></div>
{% endblock %}
{% block extrajs %}
var map = create_map($('#foomap'));
map.fitWorld();
var featureGroup = L.featureGroup();
featureGroup.addTo(map);
L.Deflate({minSize: 10, featureGroup: featureGroup}).addTo(map);
{% for result in results %}
featureGroup.addLayer(L.rectangle([[{{result.lat1}},{{result.lon1}}],[{{result.lat2}},{{result.lon2}}]]).addTo(map));
{% endfor %}
var markerGroup = L.markerClusterGroup.layerSupport()
markerGroup.addTo(map);
markerGroup.checkIn(featureGroup);
// Dirty hack; otherwise the cluster won't appear on the map.
map.zoomIn(0);
map.zoomOut(0);
map.fitBounds(featureGroup.getBounds());
{% endblock %}

Wyświetl plik

@ -58,6 +58,10 @@ urlpatterns = patterns('',
maposmatic.views.maps,
name='maps'),
url(r'^mapofmaps/$',
maposmatic.views.mapofmaps,
name='mapofmaps'),
url(r'^about/$',
maposmatic.views.about,
name='about'),