From c5c937d814e2a623294745dc761b7b870882e04c Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 3 Oct 2016 00:56:46 +0200 Subject: Remove unecessary library - python3 / django 1.8 adaptations --- chimere/static/chimere/js/clustering.js | 278 --------------------- chimere/templates/chimere/blocks/head_chimere.html | 1 - chimere/widgets.py | 35 +-- chimere_example_project/settings.py | 6 +- 4 files changed, 24 insertions(+), 296 deletions(-) delete mode 100644 chimere/static/chimere/js/clustering.js diff --git a/chimere/static/chimere/js/clustering.js b/chimere/static/chimere/js/clustering.js deleted file mode 100644 index b3a142c..0000000 --- a/chimere/static/chimere/js/clustering.js +++ /dev/null @@ -1,278 +0,0 @@ -/* - Add a recluster to Cluster class. - probably part of OpenLayers 2.13 -*/ - - -OpenLayers.Strategy.Cluster = OpenLayers.Class(OpenLayers.Strategy, { - - /** - * APIProperty: distance - * {Integer} Pixel distance between features that should be considered a - * single cluster. Default is 20 pixels. - */ - distance: 20, - - /** - * APIProperty: threshold - * {Integer} Optional threshold below which original features will be - * added to the layer instead of clusters. For example, a threshold - * of 3 would mean that any time there are 2 or fewer features in - * a cluster, those features will be added directly to the layer instead - * of a cluster representing those features. Default is null (which is - * equivalent to 1 - meaning that clusters may contain just one feature). - */ - threshold: null, - - /** - * Property: features - * {Array()} Cached features. - */ - features: null, - - /** - * Property: clusters - * {Array()} Calculated clusters. - */ - clusters: null, - - /** - * Property: clustering - * {Boolean} The strategy is currently clustering features. - */ - clustering: false, - - /** - * Property: resolution - * {Float} The resolution (map units per pixel) of the current cluster set. - */ - resolution: null, - - /** - * Constructor: OpenLayers.Strategy.Cluster - * Create a new clustering strategy. - * - * Parameters: - * options - {Object} Optional object whose properties will be set on the - * instance. - */ - - /** - * APIMethod: activate - * Activate the strategy. Register any listeners, do appropriate setup. - * - * Returns: - * {Boolean} The strategy was successfully activated. - */ - activate: function() { - var activated = OpenLayers.Strategy.prototype.activate.call(this); - if(activated) { - this.layer.events.on({ - "beforefeaturesadded": this.cacheFeatures, - "moveend": this.cluster, - scope: this - }); - } - return activated; - }, - - /** - * APIMethod: deactivate - * Deactivate the strategy. Unregister any listeners, do appropriate - * tear-down. - * - * Returns: - * {Boolean} The strategy was successfully deactivated. - */ - deactivate: function() { - var deactivated = OpenLayers.Strategy.prototype.deactivate.call(this); - if(deactivated) { - this.clearCache(); - this.layer.events.un({ - "beforefeaturesadded": this.cacheFeatures, - "moveend": this.cluster, - scope: this - }); - } - return deactivated; - }, - - /** - * Method: cacheFeatures - * Cache features before they are added to the layer. - * - * Parameters: - * event - {Object} The event that this was listening for. This will come - * with a batch of features to be clustered. - * - * Returns: - * {Boolean} False to stop features from being added to the layer. - */ - cacheFeatures: function(event) { - var propagate = true; - if(!this.clustering) { - this.clearCache(); - this.features = event.features; - this.cluster(); - propagate = false; - } - return propagate; - }, - - /** - * Method: clearCache - * Clear out the cached features. - */ - clearCache: function() { - this.features = null; - }, - - /** - * Method: cluster - * Cluster features based on some threshold distance. - * - * Parameters: - * event - {Object} The event received when cluster is called as a - * result of a moveend event. - */ - cluster: function(event) { - if((!event || event.zoomChanged || (event && event.recluster)) && this.features) { - var resolution = this.layer.map.getResolution(); - if(resolution != this.resolution || !this.clustersExist() || (event && event.recluster)) { - this.resolution = resolution; - var clusters = []; - var feature, clustered, cluster; - for(var i=0; i=0; --j) { - cluster = clusters[j]; - if(this.shouldCluster(cluster, feature)) { - this.addToCluster(cluster, feature); - clustered = true; - break; - } - } - if(!clustered) { - clusters.push(this.createCluster(this.features[i])); - } - } - } - this.layer.removeAllFeatures(); - if(clusters.length > 0) { - if(this.threshold > 1) { - var clone = clusters.slice(); - clusters = []; - var candidate; - for(var i=0, len=clone.length; i 0 && - this.clusters.length == this.layer.features.length) { - exist = true; - for(var i=0; i} A cluster. - * feature - {} A feature. - * - * Returns: - * {Boolean} The feature should be included in the cluster. - */ - shouldCluster: function(cluster, feature) { - var cc = cluster.geometry.getBounds().getCenterLonLat(); - var fc = feature.geometry.getBounds().getCenterLonLat(); - var distance = ( - Math.sqrt( - Math.pow((cc.lon - fc.lon), 2) + Math.pow((cc.lat - fc.lat), 2) - ) / this.resolution - ); - return (distance <= this.distance); - }, - - /** - * Method: addToCluster - * Add a feature to a cluster. - * - * Parameters: - * cluster - {} A cluster. - * feature - {} A feature. - */ - addToCluster: function(cluster, feature) { - cluster.cluster.push(feature); - cluster.attributes.count += 1; - }, - - /** - * Method: createCluster - * Given a feature, create a cluster. - * - * Parameters: - * feature - {} - * - * Returns: - * {} A cluster. - */ - createCluster: function(feature) { - var center = feature.geometry.getBounds().getCenterLonLat(); - var cluster = new OpenLayers.Feature.Vector( - new OpenLayers.Geometry.Point(center.lon, center.lat), - {count: 1} - ); - cluster.cluster = [feature]; - return cluster; - }, - - CLASS_NAME: "OpenLayers.Strategy.Cluster" -}); diff --git a/chimere/templates/chimere/blocks/head_chimere.html b/chimere/templates/chimere/blocks/head_chimere.html index a33424b..6e42c4c 100644 --- a/chimere/templates/chimere/blocks/head_chimere.html +++ b/chimere/templates/chimere/blocks/head_chimere.html @@ -4,7 +4,6 @@ {% endfor %} {% endif %} {% if routing %}{% endif %} -{% if enable_clustering %}{% endif %} \n" help_msg = _("If you change the above form don't forget to refresh " diff --git a/chimere_example_project/settings.py b/chimere_example_project/settings.py index 8b55a2d..de386cd 100644 --- a/chimere_example_project/settings.py +++ b/chimere_example_project/settings.py @@ -161,9 +161,9 @@ CHIMERE_MODIF_EMAIL = _(u"Hello, I would like to propose you a modification " u"about this item: ") CHIMERE_ROUTING_WARN_MESSAGE = "

Attention

"\ - "

Cet itineraire comporte des passages dangereux, nous vous conseillons"\ + "

Cet itinéraire comporte des passages dangereux, nous vous conseillons"\ " de modifier votre recherche, en ajoutant par exemple un ou des points "\ - "d'etape à votre parcours pour eviter les zones de danger.

" + "d'étape à votre parcours pour éviter les zones de danger.

" CHIMERE_CSV_ENCODING = 'ISO-8859-1' @@ -283,7 +283,7 @@ except ImportError as e: print('Unable to load local_settings.py:', e) if CHIMERE_SEARCH_ENGINE: - INSTALLED_APPS.insert(INSTALLED_APPS.index('south'), 'haystack') + INSTALLED_APPS.append('haystack') if 'LOGGING' not in globals(): global LOGGING -- cgit v1.2.3