Skip to content

Commit

Permalink
Commenting code that is no longer useful
Browse files Browse the repository at this point in the history
  • Loading branch information
JustineFricou committed Apr 24, 2024
1 parent 2b694d7 commit 7e1392b
Show file tree
Hide file tree
Showing 3 changed files with 316 additions and 351 deletions.
21 changes: 0 additions & 21 deletions geotrek/core/static/core/geotrek.forms.topology.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,27 +123,6 @@ MapEntity.GeometryField.TopologyField = MapEntity.GeometryField.extend({
this.load();
return;
}

// Path layer is ready, load graph !
this._pathsLayer.fire('data:loading');
var url = window.SETTINGS.urls.path_graph;
$.getJSON(url, this._onGraphLoaded.bind(this))
.error(graphError.bind(this));

function graphError(jqXHR, textStatus, errorThrown) {
this._pathsLayer.fire('data:loaded');
$(this._map._container).addClass('map-error');
console.error("Could not load url '" + window.SETTINGS.urls.path_graph + "': " + textStatus);
console.error(errorThrown);
}
},

_onGraphLoaded: function (graph) {
// Load graph
this._lineControl.setGraph(graph);
this.load();
// Stop spinning !
this._pathsLayer.fire('data:loaded');
},

load: function () {
Expand Down
74 changes: 30 additions & 44 deletions geotrek/core/static/core/multipath.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,11 @@ L.Control.LineTopology = L.Control.extend({
},

initialize: function (map, guidesLayer, field, options) {
console.log("guidesLayer", guidesLayer)
L.Control.prototype.initialize.call(this, options);
this.handler = new L.Handler.MultiPath(map, guidesLayer, options);
},

setGraph: function (graph) {
/**
* Set the Dikjstra graph
*/
this.handler.setGraph(graph);
this.activable(true);
},

onAdd: function (map) {
this._container = L.DomUtil.create('div', 'leaflet-draw leaflet-control leaflet-bar leaflet-control-zoom');
var link = L.DomUtil.create('a', 'leaflet-control-zoom-out linetopology-control', this._container);
Expand All @@ -192,7 +185,7 @@ L.Control.LineTopology = L.Control.extend({
.addListener(link, 'click', L.DomEvent.preventDefault)
.addListener(link, 'click', this.toggle, this);

// Control is not activable until paths and graph are loaded
// Control is not activable until paths are loaded
this.activable(false);

return this._container;
Expand Down Expand Up @@ -243,8 +236,6 @@ L.Handler.MultiPath = L.Handler.extend({
this._guidesLayer = guidesLayer;
this.options = options;

this.graph = null;

// markers
this.markersFactory = this.getMarkers();

Expand Down Expand Up @@ -273,6 +264,7 @@ L.Handler.MultiPath = L.Handler.extend({
var self = this;
(function() {
function dragstart(e) {

//var next_step_idx = self.draggable_marker.group_layer.step_idx + 1;
self.addViaStep(self.draggable_marker, next_step_idx);
}
Expand All @@ -295,10 +287,6 @@ L.Handler.MultiPath = L.Handler.extend({
this.on('fetched_route', this.onFetchedRoute, this);
},

setGraph: function (graph) {
this.graph = graph;
},

setState: function(state, autocompute) {
autocompute = autocompute === undefined ? true : autocompute;
var self = this;
Expand Down Expand Up @@ -336,8 +324,6 @@ L.Handler.MultiPath = L.Handler.extend({

// reset state
this.steps = [];
this.computed_paths = [];
this.all_edges = [];

this.marker_source = this.marker_dest = null;
},
Expand Down Expand Up @@ -376,7 +362,7 @@ L.Handler.MultiPath = L.Handler.extend({
},


// On click on a layer with the graph
// On click on a layer
_onClick: function(e) {
if (this.steps.length >= 2) return;
var self = this;
Expand Down Expand Up @@ -477,13 +463,13 @@ L.Handler.MultiPath = L.Handler.extend({
return this.steps.indexOf(step);
},

getStepIdxFromMarker: function(marker) {
for (var i = 0; i < this.steps.length; i++) {
if (this.steps[i].marker === marker)
return i;
}
return -1;
},
// getStepIdxFromMarker: function(marker) {
// for (var i = 0; i < this.steps.length; i++) {
// if (this.steps[i].marker === marker)
// return i;
// }
// return -1;
// },


getCookie: function(name) {
Expand Down Expand Up @@ -768,24 +754,24 @@ L.Handler.MultiPath = L.Handler.extend({
}
}

/* var MIN_DIST = 30;
var layerPoint = a.layerPoint
, min_dist = Number.MAX_VALUE
, closest_point = null
, matching_group_layer = null;
topology && topology.eachLayer(function(group_layer) {
console.log(group_layer)
group_layer.eachLayer(function(layer) {
var p = layer.closestLayerPoint(layerPoint);
if (p && p.distance < min_dist && p.distance < MIN_DIST) {
min_dist = p.distance;
closest_point = p;
matching_group_layer = group_layer;
}
});
}); */
// var MIN_DIST = 30;

// var layerPoint = a.layerPoint
// , min_dist = Number.MAX_VALUE
// , closest_point = null
// , matching_group_layer = null;

// topology && topology.eachLayer(function(group_layer) {
// console.log(group_layer)
// group_layer.eachLayer(function(layer) {
// var p = layer.closestLayerPoint(layerPoint);
// if (p && p.distance < min_dist && p.distance < MIN_DIST) {
// min_dist = p.distance;
// closest_point = p;
// matching_group_layer = group_layer;
// }
// });
// });

if (this.pathLayer) {
var closest_point = this.pathLayer.closestLayerPoint(a.layerPoint);
Expand Down Expand Up @@ -861,6 +847,6 @@ Geotrek.PointOnPolyline.prototype.toggleActivate = function(activate) {
marker[method]('unsnap', markerEvents.unsnap, this);
};

Geotrek.PointOnPolyline.prototype.isValid = function(graph) {
Geotrek.PointOnPolyline.prototype.isValid = function() {
return (this.ll && this.polyline);
};
Loading

0 comments on commit 7e1392b

Please sign in to comment.