diff --git a/Delafontaine_CV.pdf b/Delafontaine_CV.pdf deleted file mode 100644 index bda9567..0000000 Binary files a/Delafontaine_CV.pdf and /dev/null differ diff --git a/about/Delafontaine_CV.pdf b/about/Delafontaine_CV.pdf new file mode 100644 index 0000000..1df99ba Binary files /dev/null and b/about/Delafontaine_CV.pdf differ diff --git a/css/base.css b/about/css/base.css similarity index 100% rename from css/base.css rename to about/css/base.css diff --git a/css/font-awesome/css/font-awesome.css b/about/css/font-awesome/css/font-awesome.css similarity index 100% rename from css/font-awesome/css/font-awesome.css rename to about/css/font-awesome/css/font-awesome.css diff --git a/css/font-awesome/css/font-awesome.min.css b/about/css/font-awesome/css/font-awesome.min.css similarity index 100% rename from css/font-awesome/css/font-awesome.min.css rename to about/css/font-awesome/css/font-awesome.min.css diff --git a/css/font-awesome/fonts/FontAwesome.otf b/about/css/font-awesome/fonts/FontAwesome.otf similarity index 100% rename from css/font-awesome/fonts/FontAwesome.otf rename to about/css/font-awesome/fonts/FontAwesome.otf diff --git a/css/font-awesome/fonts/fontawesome-webfont.eot b/about/css/font-awesome/fonts/fontawesome-webfont.eot similarity index 100% rename from css/font-awesome/fonts/fontawesome-webfont.eot rename to about/css/font-awesome/fonts/fontawesome-webfont.eot diff --git a/css/font-awesome/fonts/fontawesome-webfont.svg b/about/css/font-awesome/fonts/fontawesome-webfont.svg similarity index 100% rename from css/font-awesome/fonts/fontawesome-webfont.svg rename to about/css/font-awesome/fonts/fontawesome-webfont.svg diff --git a/css/font-awesome/fonts/fontawesome-webfont.ttf b/about/css/font-awesome/fonts/fontawesome-webfont.ttf similarity index 100% rename from css/font-awesome/fonts/fontawesome-webfont.ttf rename to about/css/font-awesome/fonts/fontawesome-webfont.ttf diff --git a/css/font-awesome/fonts/fontawesome-webfont.woff b/about/css/font-awesome/fonts/fontawesome-webfont.woff similarity index 100% rename from css/font-awesome/fonts/fontawesome-webfont.woff rename to about/css/font-awesome/fonts/fontawesome-webfont.woff diff --git a/css/fonts.css b/about/css/fonts.css similarity index 100% rename from css/fonts.css rename to about/css/fonts.css diff --git a/css/main.css b/about/css/main.css similarity index 100% rename from css/main.css rename to about/css/main.css diff --git a/css/micons/fonts/icomoon.eot b/about/css/micons/fonts/icomoon.eot similarity index 100% rename from css/micons/fonts/icomoon.eot rename to about/css/micons/fonts/icomoon.eot diff --git a/css/micons/fonts/icomoon.svg b/about/css/micons/fonts/icomoon.svg similarity index 100% rename from css/micons/fonts/icomoon.svg rename to about/css/micons/fonts/icomoon.svg diff --git a/css/micons/fonts/icomoon.ttf b/about/css/micons/fonts/icomoon.ttf similarity index 100% rename from css/micons/fonts/icomoon.ttf rename to about/css/micons/fonts/icomoon.ttf diff --git a/css/micons/fonts/icomoon.woff b/about/css/micons/fonts/icomoon.woff similarity index 100% rename from css/micons/fonts/icomoon.woff rename to about/css/micons/fonts/icomoon.woff diff --git a/css/micons/micons.css b/about/css/micons/micons.css similarity index 100% rename from css/micons/micons.css rename to about/css/micons/micons.css diff --git a/css/vendor.css b/about/css/vendor.css similarity index 100% rename from css/vendor.css rename to about/css/vendor.css diff --git a/favicon.png b/about/favicon.png similarity index 100% rename from favicon.png rename to about/favicon.png diff --git a/fonts/lora/lora-bold-webfont.eot b/about/fonts/lora/lora-bold-webfont.eot similarity index 100% rename from fonts/lora/lora-bold-webfont.eot rename to about/fonts/lora/lora-bold-webfont.eot diff --git a/fonts/lora/lora-bold-webfont.svg b/about/fonts/lora/lora-bold-webfont.svg similarity index 100% rename from fonts/lora/lora-bold-webfont.svg rename to about/fonts/lora/lora-bold-webfont.svg diff --git a/fonts/lora/lora-bold-webfont.ttf b/about/fonts/lora/lora-bold-webfont.ttf similarity index 100% rename from fonts/lora/lora-bold-webfont.ttf rename to about/fonts/lora/lora-bold-webfont.ttf diff --git a/fonts/lora/lora-bold-webfont.woff b/about/fonts/lora/lora-bold-webfont.woff similarity index 100% rename from fonts/lora/lora-bold-webfont.woff rename to about/fonts/lora/lora-bold-webfont.woff diff --git a/fonts/lora/lora-bolditalic-webfont.eot b/about/fonts/lora/lora-bolditalic-webfont.eot similarity index 100% rename from fonts/lora/lora-bolditalic-webfont.eot rename to about/fonts/lora/lora-bolditalic-webfont.eot diff --git a/fonts/lora/lora-bolditalic-webfont.svg b/about/fonts/lora/lora-bolditalic-webfont.svg similarity index 100% rename from fonts/lora/lora-bolditalic-webfont.svg rename to about/fonts/lora/lora-bolditalic-webfont.svg diff --git a/fonts/lora/lora-bolditalic-webfont.ttf b/about/fonts/lora/lora-bolditalic-webfont.ttf similarity index 100% rename from fonts/lora/lora-bolditalic-webfont.ttf rename to about/fonts/lora/lora-bolditalic-webfont.ttf diff --git a/fonts/lora/lora-bolditalic-webfont.woff b/about/fonts/lora/lora-bolditalic-webfont.woff similarity index 100% rename from fonts/lora/lora-bolditalic-webfont.woff rename to about/fonts/lora/lora-bolditalic-webfont.woff diff --git a/fonts/lora/lora-italic-webfont.eot b/about/fonts/lora/lora-italic-webfont.eot similarity index 100% rename from fonts/lora/lora-italic-webfont.eot rename to about/fonts/lora/lora-italic-webfont.eot diff --git a/fonts/lora/lora-italic-webfont.svg b/about/fonts/lora/lora-italic-webfont.svg similarity index 100% rename from fonts/lora/lora-italic-webfont.svg rename to about/fonts/lora/lora-italic-webfont.svg diff --git a/fonts/lora/lora-italic-webfont.ttf b/about/fonts/lora/lora-italic-webfont.ttf similarity index 100% rename from fonts/lora/lora-italic-webfont.ttf rename to about/fonts/lora/lora-italic-webfont.ttf diff --git a/fonts/lora/lora-italic-webfont.woff b/about/fonts/lora/lora-italic-webfont.woff similarity index 100% rename from fonts/lora/lora-italic-webfont.woff rename to about/fonts/lora/lora-italic-webfont.woff diff --git a/fonts/lora/lora-regular-webfont.eot b/about/fonts/lora/lora-regular-webfont.eot similarity index 100% rename from fonts/lora/lora-regular-webfont.eot rename to about/fonts/lora/lora-regular-webfont.eot diff --git a/fonts/lora/lora-regular-webfont.svg b/about/fonts/lora/lora-regular-webfont.svg similarity index 100% rename from fonts/lora/lora-regular-webfont.svg rename to about/fonts/lora/lora-regular-webfont.svg diff --git a/fonts/lora/lora-regular-webfont.ttf b/about/fonts/lora/lora-regular-webfont.ttf similarity index 100% rename from fonts/lora/lora-regular-webfont.ttf rename to about/fonts/lora/lora-regular-webfont.ttf diff --git a/fonts/lora/lora-regular-webfont.woff b/about/fonts/lora/lora-regular-webfont.woff similarity index 100% rename from fonts/lora/lora-regular-webfont.woff rename to about/fonts/lora/lora-regular-webfont.woff diff --git a/fonts/lora/stylesheet.css b/about/fonts/lora/stylesheet.css similarity index 100% rename from fonts/lora/stylesheet.css rename to about/fonts/lora/stylesheet.css diff --git a/fonts/poppins/poppins-bold-webfont.eot b/about/fonts/poppins/poppins-bold-webfont.eot similarity index 100% rename from fonts/poppins/poppins-bold-webfont.eot rename to about/fonts/poppins/poppins-bold-webfont.eot diff --git a/fonts/poppins/poppins-bold-webfont.svg b/about/fonts/poppins/poppins-bold-webfont.svg similarity index 100% rename from fonts/poppins/poppins-bold-webfont.svg rename to about/fonts/poppins/poppins-bold-webfont.svg diff --git a/fonts/poppins/poppins-bold-webfont.ttf b/about/fonts/poppins/poppins-bold-webfont.ttf similarity index 100% rename from fonts/poppins/poppins-bold-webfont.ttf rename to about/fonts/poppins/poppins-bold-webfont.ttf diff --git a/fonts/poppins/poppins-bold-webfont.woff b/about/fonts/poppins/poppins-bold-webfont.woff similarity index 100% rename from fonts/poppins/poppins-bold-webfont.woff rename to about/fonts/poppins/poppins-bold-webfont.woff diff --git a/fonts/poppins/poppins-bold-webfont.woff2 b/about/fonts/poppins/poppins-bold-webfont.woff2 similarity index 100% rename from fonts/poppins/poppins-bold-webfont.woff2 rename to about/fonts/poppins/poppins-bold-webfont.woff2 diff --git a/fonts/poppins/poppins-light-webfont.eot b/about/fonts/poppins/poppins-light-webfont.eot similarity index 100% rename from fonts/poppins/poppins-light-webfont.eot rename to about/fonts/poppins/poppins-light-webfont.eot diff --git a/fonts/poppins/poppins-light-webfont.svg b/about/fonts/poppins/poppins-light-webfont.svg similarity index 100% rename from fonts/poppins/poppins-light-webfont.svg rename to about/fonts/poppins/poppins-light-webfont.svg diff --git a/fonts/poppins/poppins-light-webfont.ttf b/about/fonts/poppins/poppins-light-webfont.ttf similarity index 100% rename from fonts/poppins/poppins-light-webfont.ttf rename to about/fonts/poppins/poppins-light-webfont.ttf diff --git a/fonts/poppins/poppins-light-webfont.woff b/about/fonts/poppins/poppins-light-webfont.woff similarity index 100% rename from fonts/poppins/poppins-light-webfont.woff rename to about/fonts/poppins/poppins-light-webfont.woff diff --git a/fonts/poppins/poppins-light-webfont.woff2 b/about/fonts/poppins/poppins-light-webfont.woff2 similarity index 100% rename from fonts/poppins/poppins-light-webfont.woff2 rename to about/fonts/poppins/poppins-light-webfont.woff2 diff --git a/fonts/poppins/poppins-medium-webfont.eot b/about/fonts/poppins/poppins-medium-webfont.eot similarity index 100% rename from fonts/poppins/poppins-medium-webfont.eot rename to about/fonts/poppins/poppins-medium-webfont.eot diff --git a/fonts/poppins/poppins-medium-webfont.svg b/about/fonts/poppins/poppins-medium-webfont.svg similarity index 100% rename from fonts/poppins/poppins-medium-webfont.svg rename to about/fonts/poppins/poppins-medium-webfont.svg diff --git a/fonts/poppins/poppins-medium-webfont.ttf b/about/fonts/poppins/poppins-medium-webfont.ttf similarity index 100% rename from fonts/poppins/poppins-medium-webfont.ttf rename to about/fonts/poppins/poppins-medium-webfont.ttf diff --git a/fonts/poppins/poppins-medium-webfont.woff b/about/fonts/poppins/poppins-medium-webfont.woff similarity index 100% rename from fonts/poppins/poppins-medium-webfont.woff rename to about/fonts/poppins/poppins-medium-webfont.woff diff --git a/fonts/poppins/poppins-medium-webfont.woff2 b/about/fonts/poppins/poppins-medium-webfont.woff2 similarity index 100% rename from fonts/poppins/poppins-medium-webfont.woff2 rename to about/fonts/poppins/poppins-medium-webfont.woff2 diff --git a/fonts/poppins/poppins-regular-webfont.eot b/about/fonts/poppins/poppins-regular-webfont.eot similarity index 100% rename from fonts/poppins/poppins-regular-webfont.eot rename to about/fonts/poppins/poppins-regular-webfont.eot diff --git a/fonts/poppins/poppins-regular-webfont.svg b/about/fonts/poppins/poppins-regular-webfont.svg similarity index 100% rename from fonts/poppins/poppins-regular-webfont.svg rename to about/fonts/poppins/poppins-regular-webfont.svg diff --git a/fonts/poppins/poppins-regular-webfont.ttf b/about/fonts/poppins/poppins-regular-webfont.ttf similarity index 100% rename from fonts/poppins/poppins-regular-webfont.ttf rename to about/fonts/poppins/poppins-regular-webfont.ttf diff --git a/fonts/poppins/poppins-regular-webfont.woff b/about/fonts/poppins/poppins-regular-webfont.woff similarity index 100% rename from fonts/poppins/poppins-regular-webfont.woff rename to about/fonts/poppins/poppins-regular-webfont.woff diff --git a/fonts/poppins/poppins-regular-webfont.woff2 b/about/fonts/poppins/poppins-regular-webfont.woff2 similarity index 100% rename from fonts/poppins/poppins-regular-webfont.woff2 rename to about/fonts/poppins/poppins-regular-webfont.woff2 diff --git a/fonts/poppins/poppins-semibold-webfont.eot b/about/fonts/poppins/poppins-semibold-webfont.eot similarity index 100% rename from fonts/poppins/poppins-semibold-webfont.eot rename to about/fonts/poppins/poppins-semibold-webfont.eot diff --git a/fonts/poppins/poppins-semibold-webfont.svg b/about/fonts/poppins/poppins-semibold-webfont.svg similarity index 100% rename from fonts/poppins/poppins-semibold-webfont.svg rename to about/fonts/poppins/poppins-semibold-webfont.svg diff --git a/fonts/poppins/poppins-semibold-webfont.ttf b/about/fonts/poppins/poppins-semibold-webfont.ttf similarity index 100% rename from fonts/poppins/poppins-semibold-webfont.ttf rename to about/fonts/poppins/poppins-semibold-webfont.ttf diff --git a/fonts/poppins/poppins-semibold-webfont.woff b/about/fonts/poppins/poppins-semibold-webfont.woff similarity index 100% rename from fonts/poppins/poppins-semibold-webfont.woff rename to about/fonts/poppins/poppins-semibold-webfont.woff diff --git a/fonts/poppins/poppins-semibold-webfont.woff2 b/about/fonts/poppins/poppins-semibold-webfont.woff2 similarity index 100% rename from fonts/poppins/poppins-semibold-webfont.woff2 rename to about/fonts/poppins/poppins-semibold-webfont.woff2 diff --git a/fonts/poppins/stylesheet.css b/about/fonts/poppins/stylesheet.css similarity index 100% rename from fonts/poppins/stylesheet.css rename to about/fonts/poppins/stylesheet.css diff --git a/images/bg.jpg b/about/images/bg.jpg similarity index 100% rename from images/bg.jpg rename to about/images/bg.jpg diff --git a/images/intro-bg.jpg b/about/images/intro-bg.jpg similarity index 100% rename from images/intro-bg.jpg rename to about/images/intro-bg.jpg diff --git a/images/logo.png b/about/images/logo.png similarity index 100% rename from images/logo.png rename to about/images/logo.png diff --git a/about/images/victor.jpg b/about/images/victor.jpg new file mode 100644 index 0000000..0ac46d1 Binary files /dev/null and b/about/images/victor.jpg differ diff --git a/inc/sendEmail.php b/about/inc/sendEmail.php similarity index 100% rename from inc/sendEmail.php rename to about/inc/sendEmail.php diff --git a/about/index.html b/about/index.html new file mode 100644 index 0000000..54e445a --- /dev/null +++ b/about/index.html @@ -0,0 +1,422 @@ + + + +
+ + + ++ Robotic software engineer +
+ +
+
+ Experienced and adaptable Embedded Software Lead with nearly 5 years of hands-on and strategic experience in the drone delivery industry for medical logistics. + Playing a key role in scaling the software team from 3 to 10 engineers, establishing a robust release pipeline and delivering production-grade software globally. + Combines deep technical expertise in C++, ROS2, and Linux with team leadership and agile delivery practices.
+Septembre 2020 - Present
+Started as intern, and moved up to a key role in the company, with a broad set of responsibilities: SCRUM master, networking expert, IT manager, software developer, support engineer. Combines a deep technical expertise in C++, ROS2, and Linux with team leadership and Agile delivery practices.
+
Technical Leadership: Lead architecture and development for scalable systems, guiding a growing team of developers with a focus on best practices and high-quality delivery.
+
Collaboration: Organize the Scrum events with stakeholders (software, product, customer success), and guide progress towards successful releases deployed globally. Conduct code review and provide expertise on merge requests.
+
Process & Quality: Drive Agile practices, CI/CD adoption, and automated testing to improve delivery and reliability.
+
Regulatory: Oversee regulatory paperwork for certifications compliance.
+
February - August 2019
+I worked for six months at the Swisscom Digital Lab for my master thesis on the subject of precise localization or a LoRa beacon using communication signal strength.
+ By developing the solution from the ground up, I applied some of the methods and tools I had seen during my studies and learned some new ones.
+ This is the case for example of basic backend/frontend development that I had to learn from zero when I had to create a user interface for my system.
+
For more details about the project, head to the portfolio section.
+
Sept. 2017 - Aug. 2019
+My major was in robotics, with a course curriculum shared between robotics and systems engineering. + As much as possible I put the focus on mobile robotics and took some management courses to be able to understand better the engineering industry.
+Sept. 2016 - Jul. 2017
+Academic and cultural exchange done in replacement of the 3rd year of Bachelor at EPFL. + Enabled me to find some courses that I wouldn't have been able to take at EPFL and discover new work methods in another country. +
+Sept. 2013 - Jul. 2017
+Curriculum shared equally between computer, electrical and mechanical engineering. The bachelor is for students aiming for a Master on the subject of + robotics, micro/nanosystems or optical engineering. The diversity of courses makes for a good knowledge base regardless of the path chosen later on.
+I'm available mostly by mail or through LinkedIn messages.
+ +076 345 99 01
+vicdelafont@gmail.com
+in/victor-delafontaine/
+- Robotic software engineer -
- -
-
- Victor Delafontaine. Robotic engineer with academic and professional experience with ROS+ROS2, C++, Docker and Python. Eager to - learn new tools and apply them to the growing world of mobile robotics.
-Septembre 2020 - Present
-In the time spent at RigiTech I learned about the reality of growing start-ups where there is always something new to improve or implement. - Small teams also enables the work to be done in close communication with the hardware engineering team to ensure reliability and portability on the drone. - My work was focussed on the VTOL drone's onboard C++ ROS software and the communication with cloud, video stream and safety features, - as well as establishing a good working structure for me and my collegues (Docker structure, ROS2 networking) -
-February - August 2019
-I worked for six months at the Swisscom Digital Lab for my master thesis on the subject of precise localization or a LoRa beacon using communication signal strength.
- By developing the solution from the ground up, I applied some of the methods and tools I had seen during my studies and learned some new ones.
- This is the case for example of basic backend/frontend development that I had to learn from zero when I had to create a user interface for my system.
-
For more details about the project, head to the portfolio section.
-
Sept. 2017 - Aug. 2019
-My major was in robotics, with a course curriculum shared between robotics and systems engineering. - As much as possible I put the focus on mobile robotics and took some management courses to be able to understand better the engineering industry.
-Sept. 2016 - Jul. 2017
-Academic and cultural exchange done in replacement of the 3rd year of Bachelor at EPFL. - Enabled me to find some courses that I wouldn't have been able to take at EPFL and discover new work methods in another country. -
-Sept. 2013 - Jul. 2017
-Curriculum shared equally between computer, electrical and mechanical engineering. The bachelor is for students aiming for a Master on the subject of - robotics, micro/nanosystems or optical engineering. The diversity of courses makes for a good knowledge base regardless of the path chosen later on.
-Projects are where most of the learning is done. Here are the most notable I worked on - during my years at EPFL and Chalmers. They were done in very diverse courses and made me apply as well as learn a plethora of skills.
- -I'm available mostly by mail or through LinkedIn messages.
- -076 345 99 01
-vicdelafont@gmail.com
-in/victor-delafontaine/
-Try visiting /about instead.
- - \ No newline at end of file + diff --git a/topo-app/README.md b/topo-app/README.md new file mode 100644 index 0000000..f6e8c06 --- /dev/null +++ b/topo-app/README.md @@ -0,0 +1,17 @@ +# Playbook + +### Strava activities + +Go to [Strava API](https://www.strava.com/settings/api), then setup a token. Then run the `get_activities.sh` script and input them. This should create a file with the client ID in data. + +### Roads +If you want roads: go to [Overpass](https://overpass-turbo.eu/#), then add this input (for all drivable roads in Lausanne) +``` +[out:json][timeout:25]; +area["name"="Lausanne"]->.searchArea; +( way["highway"~"^(motorway|trunk|primary|secondary|tertiary|unclassified|residential|living_street)$"](area.searchArea); +); +out geom; +``` + +Then export as GeoJSON, save in `data/lausanne_roads.geojson` \ No newline at end of file diff --git a/topo-app/app.js b/topo-app/app.js new file mode 100644 index 0000000..a883038 --- /dev/null +++ b/topo-app/app.js @@ -0,0 +1,350 @@ +const LOCAL_ROADS = './data/lausanne_roads.geojson'; +const ACTIVITIES_MANIFEST = './data/manifest.json'; +const PASSWORD = 'mapsarecool'; + +let activeBaseLayer = null; +let roadLayer; // Declare it globally if needed outside initMap() +let stravaLayerGroup = L.layerGroup(); // Layer group for Strava traces +const stravaLayers = { + Cycling: L.layerGroup(), + HikingWalking: L.layerGroup(), + Running: L.layerGroup(), + Other: L.layerGroup() +}; +const layerRegistry = {}; // global layer lookup + +function initMap() { + console.log('init map') + const map = L.map('map').setView([46.5, 6.6], 10); + map.createPane('roadsPane'); + map.getPane('roadsPane').style.zIndex = 390; + + const topo = L.tileLayer( + 'https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.pixelkarte-grau/default/current/3857/{z}/{x}/{y}.jpeg', + {attribution: '© Swisstopo', maxZoom: 18}); + + const world = L.tileLayer( + ' https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png', + {attribution: '© OpenStreetMap contributors', maxZoom: 19}); + + const satellite = L.tileLayer( + ' https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', + {attribution: '© Esri', maxZoom: 18}); + + const hiking = L.tileLayer( + 'https://wmts.geo.admin.ch/1.0.0/ch.astra.wanderland/default/current/3857/{z}/{x}/{y}.png', + {opacity: 0.7}); + + const cycling = L.tileLayer( + 'https://wmts.geo.admin.ch/1.0.0/ch.astra.veloland/default/current/3857/{z}/{x}/{y}.png', + {opacity: 0.7}); + + const wanderwege = L.tileLayer( + 'https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.swisstlm3d-wanderwege/default/current/3857/{z}/{x}/{y}.png', + {opacity: 0.7, attribution: '© Swisstopo', maxZoom: 18}); + + roadLayer = L.geoJSON( + null, + {pane: 'roadsPane', style: {color: 'black', weight: 2, opacity: 0.6}}); + + // Add to registry + layerRegistry.topo = topo; + layerRegistry.world = world; + layerRegistry.satellite = satellite; + layerRegistry.hiking = hiking; + layerRegistry.cycling = cycling; + layerRegistry.wanderwege = wanderwege; + layerRegistry.stravaCycling = stravaLayers.Cycling; + layerRegistry.stravaHikingWalking = stravaLayers.HikingWalking; + layerRegistry.stravaRunning = stravaLayers.Running; + layerRegistry.stravaOther = stravaLayers.Other; + layerRegistry.roads = roadLayer; + + topo.addTo(map); + activeBaseLayer = topo; + + const baseMaps = { + 'Topographic (CH)': topo, + 'World': world, + 'Satellite': satellite + }; + + const overlayMaps = { + 'SwissMobile Hiking': hiking, + 'SwissMobile Cycling': cycling, + 'SwissTLM3D Hiking Trails': wanderwege, + 'Cycling Activities': stravaLayers.Cycling, + 'Hiking/Walking Activities': stravaLayers.HikingWalking, + 'Running Activities': stravaLayers.Running, + 'Other Activities': stravaLayers.Other, + 'Lausanne Roads': roadLayer + }; + + const control = L.control.layers(baseMaps, overlayMaps).addTo(map); + const originalUpdate = control._update; + control._update = function() { + originalUpdate.call(this); + setTimeout(() => addLayerControls(control), 0); + }; + + map.on('baselayerchange', function(e) { + activeBaseLayer = e.layer; + console.log('Base layer changed to:', e.name); + }); + + return map; +} + +function addLayerControls(control) { + const container = control.getContainer(); + container.querySelectorAll('input.opacity-slider, input.linewidth-slider') + .forEach(el => el.remove()); + + const overlays = + container.querySelectorAll('.leaflet-control-layers-overlays label'); + const bases = + container.querySelectorAll('.leaflet-control-layers-base label'); + const allLabels = [...bases, ...overlays]; + + allLabels.forEach(label => { + const text = label.textContent.trim().toLowerCase(); + let key = null; + + if (text.includes('world')) key = 'world'; + if (text.includes('topographic')) key = 'topo'; + if (text.includes('satellite')) key = 'satellite'; + if (text.includes('swisstlm3d')) key = 'wanderwege'; + if (text.includes('swissmobile hiking')) key = 'hiking'; + if (text.includes('swissmobile cycling')) key = 'cycling'; + if (text.includes('cycling activities')) key = 'stravaCycling'; + if (text.includes('hiking/walking activities')) key = 'stravaHikingWalking'; + if (text.includes('running activities')) key = 'stravaRunning'; + if (text.includes('other activities')) key = 'stravaOther'; + if (text.includes('lausanne')) key = 'roads'; + + const layer = layerRegistry[key]; + if (!key || !layer) return; + + // Opacity slider + const opacitySlider = document.createElement('input'); + opacitySlider.className = 'opacity-slider'; + opacitySlider.type = 'range'; + opacitySlider.min = 0; + opacitySlider.max = 1; + opacitySlider.step = 0.05; + opacitySlider.value = 1.0; + opacitySlider.style.marginLeft = '8px'; + opacitySlider.style.width = '70px'; + opacitySlider.title = 'Opacity'; + + opacitySlider.addEventListener('input', () => { + const value = parseFloat(opacitySlider.value); + if (typeof layer.setOpacity === 'function') { + layer.setOpacity(value); + } else if (layer.eachLayer) { + layer.eachLayer(l => { + if (typeof l.setStyle === 'function') { + l.setStyle({opacity: value, fillOpacity: value}); + } + }); + } + }); + + label.appendChild(opacitySlider); + + // Line width slider (only for strava and roads) + const supportsLineWidth = key.startsWith('strava') || key === 'roads'; + if (supportsLineWidth) { + const widthSlider = document.createElement('input'); + widthSlider.className = 'linewidth-slider'; + widthSlider.type = 'range'; + widthSlider.min = 1; + widthSlider.max = 10; + widthSlider.step = 1; + widthSlider.value = 3; + widthSlider.style.marginLeft = '6px'; + widthSlider.style.width = '60px'; + widthSlider.title = 'Line Width'; + + widthSlider.addEventListener('input', () => { + const weight = parseInt(widthSlider.value); + if (layer.eachLayer) { + layer.eachLayer(l => { + if (typeof l.setStyle === 'function') { + l.setStyle({weight}); + } + }); + } else if (typeof layer.setStyle === 'function') { + layer.setStyle({weight}); + } + }); + + label.appendChild(widthSlider); + } + }); +} + +function drawActivities(map, activities, filterType = null) { + // Clear old + Object.values(stravaLayers).forEach(layer => layer.clearLayers()); + + // Group by type + const groups = {Cycling: [], HikingWalking: [], Running: [], Other: []}; + + // Plot them + let skipped = 0; + activities.forEach(activity => { + const polylineStr = activity.map?.summary_polyline; + if (!polylineStr || polylineStr.trim() === '') { + console.warn( + `⛔ Skipping "${activity.name}" (ID: ${activity.id}) – no polyline`); + skipped++; + return; + } + let coords; + try { + coords = polyline.decode(polylineStr); + } catch (e) { + console.warn(`Skipping bad polyline for activity "${activity.name}"`); + return; + } + if (!coords || coords.length === 0) return; + const latlngs = coords.map(([lat, lng]) => [lat, lng]); + + let group = 'Other'; + let color = 'purple'; + if (activity.type === 'Ride') { + group = 'Cycling'; + color = 'blue'; + } else if (activity.type === 'Run') { + group = 'Running'; + color = 'red'; + } else if (activity.type === 'Hike' || activity.type === 'Walk') { + group = 'HikingWalking'; + color = 'green'; + } + + const polylineLayer = + L.polyline(latlngs, {color: color, weight: 3, opacity: 0.8}); + + const popupContent = ` + ${activity.name}