Verified Commit 524a66b4 authored by Elger Jonker's avatar Elger Jonker

wip: creating markedcluster

parent 5a79e193
Pipeline #27662418 failed with stage
in 16 minutes and 26 seconds
......@@ -417,10 +417,10 @@ def get_osm_data(country: str= "NL", organization_type: str= "municipality"):
# if the file has been downloaded recently, don't do that again.
four_hours_ago = time.time() - 14400
if os.path.isfile(filename + ".geojson") and four_hours_ago < os.path.getmtime(filename):
if os.path.isfile(filename + ".polygons") and four_hours_ago < os.path.getmtime(filename):
log.debug("Already downloaded a coordinate file in the past four hours. Using that one.")
log.debug(filename + ".geojson")
return json.load(open(filename + ".geojson"))
log.debug(filename + ".polygons")
return json.load(open(filename + ".polygons"))
"""
The overpass query interface can be found here: https://overpass-turbo.eu/
......@@ -466,16 +466,16 @@ def get_osm_data(country: str= "NL", organization_type: str= "municipality"):
f.write(block)
f.flush()
log.info("Converting OSM file to geojson. This also can take a while...")
log.info("Converting OSM file to polygons. This also can take a while...")
try:
with open(filename + ".geojson", "w") as outfile:
with open(filename + ".polygons", "w") as outfile:
subprocess.call(["osmtogeojson", filename], stdout=outfile)
except subprocess.CalledProcessError:
log.exception("Error while converting to geojson.")
log.exception("Error while converting to polygons.")
except OSError:
log.exception("osmtogeojson tool not found.")
return json.load(open(filename + ".geojson"))
return json.load(open(filename + ".polygons"))
def osmtogeojson_available():
......
.marker-cluster-small {
background-color: rgba(181, 226, 140, 0.6);
}
.marker-cluster-small div {
background-color: rgba(110, 204, 57, 0.6);
}
.marker-cluster-medium {
background-color: rgba(241, 211, 87, 0.6);
}
.marker-cluster-medium div {
background-color: rgba(240, 194, 12, 0.6);
}
.marker-cluster-large {
background-color: rgba(253, 156, 115, 0.6);
}
.marker-cluster-large div {
background-color: rgba(241, 128, 23, 0.6);
}
/* IE 6-8 fallback colors */
.leaflet-oldie .marker-cluster-small {
background-color: rgb(181, 226, 140);
}
.leaflet-oldie .marker-cluster-small div {
background-color: rgb(110, 204, 57);
}
.leaflet-oldie .marker-cluster-medium {
background-color: rgb(241, 211, 87);
}
.leaflet-oldie .marker-cluster-medium div {
background-color: rgb(240, 194, 12);
}
.leaflet-oldie .marker-cluster-large {
background-color: rgb(253, 156, 115);
}
.leaflet-oldie .marker-cluster-large div {
background-color: rgb(241, 128, 23);
}
.marker-cluster {
background-clip: padding-box;
border-radius: 20px;
}
.marker-cluster div {
width: 30px;
height: 30px;
margin-left: 5px;
margin-top: 5px;
text-align: center;
border-radius: 15px;
font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
}
.marker-cluster span {
line-height: 30px;
}
\ No newline at end of file
.marker-cluster-unknown {
background-color: rgba(226, 225, 213, 0.6);
}
.marker-cluster-unknown div {
background-color: rgba(200, 204, 197, 0.6);
}
.marker-cluster-green {
background-color: rgba(181, 226, 140, 0.6);
}
.marker-cluster-green div {
background-color: rgba(110, 204, 57, 0.6);
}
.marker-cluster-orange {
background-color: rgba(241, 211, 87, 0.6);
}
.marker-cluster-orange div {
background-color: rgba(240, 132, 38, 0.6);
}
.marker-cluster-red {
background-color: rgba(253, 156, 115, 0.6);
}
.marker-cluster-red div {
background-color: rgba(241, 40, 37, 0.6);
}
/* IE 6-8 fallback colors */
.leaflet-oldie .marker-cluster-green {
background-color: rgb(181, 226, 140);
}
.leaflet-oldie .marker-cluster-green div {
background-color: rgb(110, 204, 57);
}
.leaflet-oldie .marker-cluster-orange {
background-color: rgb(241, 211, 87);
}
.leaflet-oldie .marker-cluster-orange div {
background-color: rgb(240, 194, 12);
}
.leaflet-oldie .marker-cluster-red {
background-color: rgb(253, 156, 115);
}
.leaflet-oldie .marker-cluster-red div {
background-color: rgb(241, 128, 23);
}
.marker-cluster {
background-clip: padding-box;
border-radius: 20px;
}
.marker-cluster div {
width: 30px;
height: 30px;
margin-left: 5px;
margin-top: 5px;
text-align: center;
border-radius: 15px;
font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
}
.marker-cluster span {
line-height: 30px;
}
\ No newline at end of file
This diff is collapsed.
......@@ -8472,7 +8472,7 @@ var GeoJSON = FeatureGroup.extend({
// @function geometryToLayer(featureData: Object, options?: GeoJSON options): Layer
// Creates a `Layer` from a given GeoJSON feature. Can use a custom
// [`pointToLayer`](#geojson-pointtolayer) and/or [`coordsToLatLng`](#geojson-coordstolatlng)
// [`pointToLayer`](#polygons-pointtolayer) and/or [`coordsToLatLng`](#polygons-coordstolatlng)
// functions if provided as options.
function geometryToLayer(geojson, options) {
......@@ -8538,7 +8538,7 @@ function coordsToLatLng(coords) {
// @function coordsToLatLngs(coords: Array, levelsDeep?: Number, coordsToLatLng?: Function): Array
// Creates a multidimensional array of `LatLng`s from a GeoJSON coordinates array.
// `levelsDeep` specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default).
// Can use a custom [`coordsToLatLng`](#geojson-coordstolatlng) function.
// Can use a custom [`coordsToLatLng`](#polygons-coordstolatlng) function.
function coordsToLatLngs(coords, levelsDeep, _coordsToLatLng) {
var latlngs = [];
......@@ -8554,7 +8554,7 @@ function coordsToLatLngs(coords, levelsDeep, _coordsToLatLng) {
}
// @function latLngToCoords(latlng: LatLng, precision?: Number): Array
// Reverse of [`coordsToLatLng`](#geojson-coordstolatlng)
// Reverse of [`coordsToLatLng`](#polygons-coordstolatlng)
function latLngToCoords(latlng, precision) {
precision = typeof precision === 'number' ? precision : 6;
return latlng.alt !== undefined ?
......@@ -8563,7 +8563,7 @@ function latLngToCoords(latlng, precision) {
}
// @function latLngsToCoords(latlngs: Array, levelsDeep?: Number, closed?: Boolean): Array
// Reverse of [`coordsToLatLngs`](#geojson-coordstolatlngs)
// Reverse of [`coordsToLatLngs`](#polygons-coordstolatlngs)
// `closed` determines whether the first point should be appended to the end of the array to close the feature, only used when `levelsDeep` is 0. False by default.
function latLngsToCoords(latlngs, levelsDeep, closed, precision) {
var coords = [];
......@@ -8587,7 +8587,7 @@ function getFeature(layer, newGeometry) {
asFeature(newGeometry);
}
// @function asFeature(geojson: Object): Object
// @function asFeature(polygons: Object): Object
// Normalize GeoJSON geometries/features into GeoJSON features.
function asFeature(geojson) {
if (geojson.type === 'Feature' || geojson.type === 'FeatureCollection') {
......@@ -8720,7 +8720,7 @@ LayerGroup.include({
});
// @namespace GeoJSON
// @factory L.geoJSON(geojson?: Object, options?: GeoJSON options)
// @factory L.geoJSON(polygons?: Object, options?: GeoJSON options)
// Creates a GeoJSON layer. Optionally accepts an object in
// [GeoJSON format](http://geojson.org/geojson-spec.html) to display on the map
// (you can alternatively add it later with `addData` method) and an `options` object.
......
......@@ -1026,9 +1026,9 @@ function views() {
// this will go wrong when we group points / use other layers.
// this will crash the first time...
if ((failmap !== undefined) && (failmap.geojson.clearLayers !== undefined)) {
failmap.geojson.clearLayers();
failmap.geojson = null;
if ((failmap !== undefined) && (failmap.polygons.clearLayers !== undefined)) {
failmap.polygons.clearLayers();
failmap.polygons = null;
}
}
},
......@@ -1073,27 +1073,8 @@ function views() {
$.getJSON('/data/map/' + this.country + '/' + this.category + '/' + week + '/' +
self.desired_url_scans + '/' + self.desired_endpoint_scans + '/', function (mapdata) {
self.loading = true;
// if there is one already, overwrite the attributes...
if (failmap.geojson) {
// here we add all features that are not part of the current map at all
// and delete the ones that are not in the current set
failmap.clean_map(mapdata);
// here we can update existing layers (and add ones with the same name)
failmap.geojson.eachLayer(function (layer) {failmap.recolormap(mapdata, layer)});
} else {
// first time load.
failmap.geojson = L.geoJson(mapdata, {
style: failmap.style,
pointToLayer: failmap.pointToLayer,
onEachFeature: failmap.onEachFeature
}).addTo(failmap.map); // only if singleton, its somewhat dirty.
// fit the map automatically, regardless of the initial positions
if (mapdata.features.length > 0) {
failmap.map.fitBounds(failmap.geojson.getBounds());
}
}
failmap.plotdata(mapdata);
// make map features (organization data) available to other vues
// do not update this attribute if an empty list is returned as currently
......
......@@ -40,7 +40,7 @@
<link rel="stylesheet" type="text/css" href="{% static 'css/vendor/leaflet.fullscreen.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/vendor/fa-svg-with-js.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/vendor/MarkerCluster.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/vendor/MarkerCluster.Default.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/vendor/MarkerCluster.Failmap.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/overrides.css' %}">
{% endcompress %}
......
......@@ -490,6 +490,8 @@ COMPRESS_STORAGE = (
# Disable caching during development and production.
# Django only emits caching headers, the webserver/caching-proxy makes sure the rest of the caching is handled.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
......@@ -764,9 +766,18 @@ CONSTANCE_CONFIG_FIELDSETS = OrderedDict([
('Reporting', ('REPORT_INCLUDE_DNS_DNSSEC', 'REPORT_INCLUDE_HTTP_TLS_QUALYS', 'REPORT_INCLUDE_HTTP_MISSING_TLS',
'REPORT_INCLUDE_HTTP_HEADERS_HSTS',
'REPORT_INCLUDE_HTTP_HEADERS_XFO', 'REPORT_INCLUDE_HTTP_HEADERS_X_XSS',
'REPORT_INCLUDE_HTTP_HEADERS_X_CONTENT')),
'REPORT_INCLUDE_HTTP_HEADERS_X_CONTENT', 'REPORT_INCLUDE_FTP')),
('Chat (using gitter)', ('GITTER_CHAT_ENABLE', 'GITTER_CHAT_CHANNEL'))
])
# Check for constance configuration issues:
# See also: https://github.com/jazzband/django-constance/issues/293
variables_in_fieldsets = [i for sub in [CONSTANCE_CONFIG_FIELDSETS[x] for x in CONSTANCE_CONFIG_FIELDSETS] for i in sub]
variables_in_config = [x for x in CONSTANCE_CONFIG]
missing = set(variables_in_config) - set(variables_in_fieldsets)
if missing:
raise EnvironmentError("Constance config variables %s are missing in constance config fieldsets." % missing)
# End constance settings
########
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment