Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trackview review #38

Merged
merged 4 commits into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions demo/addons/trackview/js/trackview.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ var trackview = (function () {
// Conversion of the current point in other projection for a better manipulation
let currentPointConvert = ol.proj.transform(currentPoint, 'EPSG:3857', 'EPSG:4326');

// only after first point
// Only after first point
if (i > 0) {

const distanceCalc = (turf.distance(previousPointConvert, currentPointConvert) * 1000); // Distance between the current point and the previous one
Expand All @@ -224,7 +224,7 @@ var trackview = (function () {
const distanceManquante = (markerDistance - distanceTotalForSegment) / 1000; // We calculate the missing distance
markerDistance += 1000;

// get coords for the wanted distance
// Get coords for the wanted distance
const segmentTurf = turf.lineString([previousPointConvert, currentPointConvert]);
const along = turf.along(segmentTurf, distanceManquante);
const pointCoords = along.geometry.coordinates;
Expand All @@ -244,7 +244,7 @@ var trackview = (function () {
idKilometre++;
}

// create segment with point
// Create segment with point
var segment = new ol.geom.LineString([previousPoint, currentPoint]);
// Set high with pointEnd Z
distanceTotalForSegment += distanceCalc;
Expand All @@ -263,7 +263,7 @@ var trackview = (function () {

}
finalData[i] = [distanceTotalForSegment, featureZ]; // Add distance and point in finalData array
// currentPoint.set('distance', distance);
// CurrentPoint.set('distance', distance);

previousPoint = currentPoint;
previousPointConvert = currentPointConvert;
Expand Down Expand Up @@ -421,10 +421,10 @@ var trackview = (function () {
*/
var _initTool = function () {

// trackview-parcours
// Trackview-parcours dropdown
let dropdown = document.getElementById("trackview-parcours");

// Here we create the drop-down list
// Here we create the dropdown list
for (let i = 0; i < tracksList.length; i++) {
const li = document.createElement("li");
li.value = i;
Expand All @@ -433,11 +433,12 @@ var trackview = (function () {
dropdown.appendChild(li);
}

// TODO put after parcours init
// Here we check if the dropdown is clicked ( used )
document.querySelector("#trackview-parcours").addEventListener("click", (e) => {
let itemSelected = e.target;
let itemValue = itemSelected.getAttribute("value");

// If an element is selected in the list
if (itemValue) {

_clearTool();
Expand All @@ -461,9 +462,9 @@ var trackview = (function () {

mviewer.getMap().once("rendercomplete", function (e) {

_zoomOnFeature();
_createFeatures();
initDropdown();
_zoomOnFeature(); // Calling fonction for zoom on the features
_createFeatures(); // Calling fonction for create all of the features
initDropdown(); // Calling the init of the dropdown

/*********** Detect feature on the map ***********/
mviewer.getMap().on("pointermove", function (event) {
Expand All @@ -475,10 +476,8 @@ var trackview = (function () {
currentSelectedSegmentId = feature.getProperties().properties.id;
dataGraph.update();
vectorLayerSegment.changed();
//console.log("dans le if");
//console.log(currentSelectedSegmentId);
}
}, { hitTolerance: currentTracks.param.tolerance.value });
}, { hitTolerance: currentTracks.param.tolerance.value }); // Value in pixel
});
});
};
Expand Down
Loading