Skip to content

Commit

Permalink
Remove no longer used methods
Browse files Browse the repository at this point in the history
  • Loading branch information
justinefricou committed Jun 12, 2024
1 parent 179020c commit 561a44b
Showing 1 changed file with 0 additions and 138 deletions.
138 changes: 0 additions & 138 deletions geotrek/core/static/core/multipath.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,30 +325,6 @@ L.Handler.MultiPath = L.Handler.extend({
this.on('invalid_route', this.onInvalidRoute, this);
},

setState: function(state, autocompute) {
autocompute = autocompute === undefined ? true : autocompute;
var self = this;

// Ensure we got a fresh start
this.disable();
this.reset();
this.enable();
console.debug('setState('+JSON.stringify({start:{pk:state.start_layer.properties.id,
latlng:state.start_ll.toString()},
end: {pk:state.end_layer.properties.id,
latlng:state.end_ll.toString()}})+')');

this._onClick({latlng: state.start_ll, layer:state.start_layer});
this._onClick({latlng: state.end_ll, layer:state.end_layer});

state.via_markers && $.each(state.via_markers, function(idx, via_marker) {
console.debug('Add via marker (' + JSON.stringify({pk: via_marker.layer.properties.id,
latlng: via_marker.marker.getLatLng().toString()}) + ')');
self.addViaStep(via_marker.marker, idx + 1);
self.forceMarkerToLayer(via_marker.marker, via_marker.layer);
});
},

// Reset the whole state
reset: function() {
var self = this;
Expand Down Expand Up @@ -654,120 +630,6 @@ L.Handler.MultiPath = L.Handler.extend({
}
},

restoreTopology: function (topo) {
// TODO: check if this is still used

/*
* Topo is a list of sub-topologies.
*
* X--+--+---O-------+----O--+---+--X
*
* Each sub-topoogy is a way between markers. The first marker
* of the first sub-topology is the beginning, the last of the last is the end.
* All others are intermediary points (via markers)
*/
var self = this;


// Only first and last positions
if (topo.length == 1 && topo[0].paths.length == 1) {
// There is only one path, both positions values are relevant
// and each one represents a marker
var topo = topo[0]
, paths = topo.paths
, positions = topo.positions;

var first_pos = positions[0][0];
var last_pos = positions[0][1];

var start_layer = this.idToLayer(paths[0]);
var end_layer = this.idToLayer(paths[paths.length - 1]);

var start_ll = L.GeometryUtil.interpolateOnLine(this.map, start_layer, first_pos).latLng;
var end_ll = L.GeometryUtil.interpolateOnLine(this.map, end_layer, last_pos).latLng;

var state = {
start_ll: start_ll,
end_ll: end_ll,
start_layer: start_layer,
end_layer: end_layer
};
this.setState(state);
}
else {
var start_layer_ll = {}
, end_layer_ll = {}
, via_markers = [];

// var pos2latlng = function (pos, layer) {
// var used_pos = pos;
// if (pos instanceof Array) {
// used_pos = pos[1]; // Default is second position (think of last path of topology)
// if (pos[0] == 0.0 && pos[1] != 1.0)
// used_pos = pos[1];
// if (pos[0] == 1.0 && pos[1] != 0.0)
// used_pos = pos[1];
// if (pos[0] != 1.0 && pos[1] == 0.0)
// used_pos = pos[0];
// if (pos[0] != 0.0 && pos[1] == 1.0)
// used_pos = pos[0];
// console.log("Chose " + used_pos + " for " + pos);
// }
// var interpolated = L.GeometryUtil.interpolateOnLine(self.map, layer, used_pos);
// if (!interpolated) {
// throw ('Could not interpolate ' + used_pos + ' on layer ' + layer.properties.id);
// }
// return interpolated.latLng;
// };

for (var i=0; i<topo.length; i++) {
var subtopo = topo[i]
, firsttopo = i==0
, lasttopo = i==topo.length-1;

var paths = subtopo.paths
, positions = subtopo.positions || {}
, lastpath = paths.length-1;

// Safety check.
if (!('0' in positions)) positions['0'] = [0.0, 1.0];
if (!(lastpath in positions)) positions[lastpath] = [0.0, 1.0];

var firstlayer = self.idToLayer(paths[0])
, lastlayer = self.idToLayer(paths[lastpath]);

if (firsttopo) {
start_layer_ll.layer = firstlayer;
start_layer_ll.ll = pos2latlng(positions['0'][0], firstlayer);
}
if (lasttopo) {
end_layer_ll.layer = lastlayer;
end_layer_ll.ll = pos2latlng(positions[lastpath][1], lastlayer);
}
else {
var layer = lastlayer
, ll = pos2latlng(positions[lastpath], layer);
// Add a via marker
via_markers.push({
layer: layer,
marker: self.markersFactory.drag(ll, null, true)
});
}
}

var state = {
start_ll: start_layer_ll.ll,
end_ll: end_layer_ll.ll,
start_layer: start_layer_ll.layer,
end_layer: end_layer_ll.layer,
via_markers: via_markers
};

// Restore state as if a user clicks.
this.setState(state);
}
},

restoreGeometry: function (serializedTopology) {
var self = this;

Expand Down

0 comments on commit 561a44b

Please sign in to comment.