Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f158d2f
adapt nginx config for so preprod
lgourdin Jan 24, 2025
c8cce71
set our internal api url
lgourdin Jan 27, 2025
3660d3f
trying debug features
lgourdin Jan 27, 2025
3820318
Revert "trying debug features"
lgourdin Jan 27, 2025
2704688
add transport box
Floriane-jandot Jan 31, 2025
a53d9f1
[new feature] Display all stop points on list and map
Floriane-jandot Mar 3, 2025
355fd21
[new feature] Add card reaction with map
Floriane-jandot Mar 4, 2025
63aba40
[new feature] add "is reachable by public transport" box
Floriane-jandot Mar 4, 2025
efafb83
[new feature] display multiple stop_point for 1 stop_area, with toggl…
Floriane-jandot Mar 5, 2025
c4ecf84
[new feature] add public transports view on routes
Floriane-jandot Mar 5, 2025
c34be83
[new feature] add no public transport result
Floriane-jandot Mar 6, 2025
f6f9db9
[new feature] add partial result case for many waypoints
Floriane-jandot Mar 6, 2025
de720c5
[new features] rename table, visuals corrections, map hover fixed, ad…
Floriane-jandot Mar 7, 2025
47ae353
Merge branch 'dev/fj'
Floriane-jandot Mar 7, 2025
236d328
[new features] add automatic scroll for card list, movement on map
Floriane-jandot Mar 18, 2025
214149d
[fix] use text from translation file
Floriane-jandot Mar 18, 2025
63cd8d5
[fix] Color and put the waypoint icon in front of stops icon
Floriane-jandot Mar 18, 2025
4fc85b1
[fix] remove public transports to /waypoints
Floriane-jandot Mar 19, 2025
c48e8bf
[fix] fix shaking map
Floriane-jandot Mar 19, 2025
aeccc65
[fix] Minors fix : translations, fully cliquable isAccessible, orange…
Floriane-jandot Mar 19, 2025
39ef733
[fix] Fix responsive design of partial accessibility topo
Floriane-jandot Mar 19, 2025
0d8ebeb
Merge branch 'fj/dev'
Floriane-jandot Mar 19, 2025
2a58ad1
[fix] correct card long click, card scrolling, remove pin button
Floriane-jandot Apr 15, 2025
08edb69
Merge branch 'fj/recette'
Floriane-jandot Apr 22, 2025
c0a6c29
Merge remote-tracking branch 'SmartOrigin/main' into smart-origin/lot1
Floriane-jandot May 7, 2025
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
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
],
"reportUnusedDisableDirectives": true,
"rules": {
"prettier/prettier": ["warn", { "endOfLine": "auto" }],
"no-unused-vars": "warn",
"no-console": "warn",
"vue/no-v-html": "off",
Expand Down
3 changes: 2 additions & 1 deletion docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
server {
listen ${PORT} proxy_protocol;
listen ${PORT};
#listen ${PORT} proxy_protocol;
server_name ${SERVER_NAME};
root /usr/share/nginx/html;
index index.html;
Expand Down
3 changes: 3 additions & 0 deletions src/assets/img/boxes/public_transport.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/assets/img/boxes/toggle_minus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/assets/img/boxes/toggle_plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions src/assets/img/boxes/transport_not_found.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 77 additions & 2 deletions src/components/map/OlMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1064,8 +1064,7 @@ export default {
resultFeature = feature;
return true;
});

this.setHighlightedFeature(resultFeature);
this.setHighlightedFeature(resultFeature); ///////////
this.$emit('highlight-document', resultFeature ? resultFeature.get('document') : null);
},

Expand Down Expand Up @@ -1094,6 +1093,13 @@ export default {

if (feature) {
const document = feature.get('document');
if (document && document.type === 'z') {
return;
}
if (document && document.type === 's') {
this.$emit('stop-clicked', document.document_id);
return;
}
if (document) {
if (this.documents.length === 1 && document.document_id === this.documents[0].document_id) {
return;
Expand Down Expand Up @@ -1256,6 +1262,75 @@ export default {
);
this.editMapLink = `https://www.openstreetmap.org/#map=13/${coords[1]}/${coords[0]}`;
},

highlightStop(stopId) {
this.resetStopStyles();
const stopFeature = this.findStopPoint(stopId);

if (!stopFeature) {
console.warn(`Stop with ID ${stopId} not found.`);
return;
}

const title = stopFeature.get('document').stoparea_name;
stopFeature.setStyle(getDocumentPointStyle(stopFeature.get('document'), title, true));
},

goAndZoomOnStop(stopId) {
const stopFeature = this.findStopPoint(stopId);

if (!stopFeature) {
console.warn(`Stop with ID ${stopId} not found.`);
return;
}
const geometry = stopFeature.getGeometry();
if (geometry) {
const coordinate = geometry.getCoordinates();

const view = this.map.getView();
view.cancelAnimations();

view.animate({
center: coordinate,
zoom: Math.max(view.getZoom(), 15),
duration: 300,
});
}
},

resetStopStyles() {
const documentsSource = this.documentsLayer.getSource();
const waypointsSource = this.waypointsLayer.getSource();

documentsSource.forEachFeature((feature) => {
if (feature.values_.document.type !== 'w' && feature.values_.document.type !== 'z') {
feature.setStyle(feature.get('normalStyle'));
}
});

waypointsSource.forEachFeature((feature) => {
feature.setStyle(feature.get('normalStyle'));
});
},
Comment on lines +1301 to +1314

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid accessing internal properties of OpenLayers features

The code accesses feature.values_.document.type which uses OpenLayers' internal property structure. This is fragile and could break with library updates.

       documentsSource.forEachFeature((feature) => {
-        if (feature.values_.document.type !== 'w' && feature.values_.document.type !== 'z') {
+        const document = feature.get('document');
+        if (document && document.type !== 'w' && document.type !== 'z') {
           feature.setStyle(feature.get('normalStyle'));
         }
       });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
resetStopStyles() {
const documentsSource = this.documentsLayer.getSource();
const waypointsSource = this.waypointsLayer.getSource();
documentsSource.forEachFeature((feature) => {
if (feature.values_.document.type !== 'w' && feature.values_.document.type !== 'z') {
feature.setStyle(feature.get('normalStyle'));
}
});
waypointsSource.forEachFeature((feature) => {
feature.setStyle(feature.get('normalStyle'));
});
},
resetStopStyles() {
const documentsSource = this.documentsLayer.getSource();
const waypointsSource = this.waypointsLayer.getSource();
documentsSource.forEachFeature((feature) => {
+ const document = feature.get('document');
+ if (document && document.type !== 'w' && document.type !== 'z') {
feature.setStyle(feature.get('normalStyle'));
+ }
});
waypointsSource.forEachFeature((feature) => {
feature.setStyle(feature.get('normalStyle'));
});
},
🤖 Prompt for AI Agents
In src/components/map/OlMap.vue around lines 1301 to 1314, the code accesses the
internal property feature.values_.document.type, which is fragile and may break
with OpenLayers updates. To fix this, replace the direct access to values_ with
the official OpenLayers API method feature.get('document') to retrieve the
document object, then check its type property safely. This avoids relying on
internal properties and ensures compatibility with future OpenLayers versions.


findStopPoint(stopId) {
const documentsSource = this.documentsLayer.getSource();
const documentFeature = documentsSource.getFeatureById(stopId);

if (documentFeature) {
return documentFeature;
}

const waypointsSource = this.waypointsLayer.getSource();
const waypointFeature = waypointsSource.getFeatureById(stopId);

if (waypointFeature) {
return waypointFeature;
}

console.warn(`Stop with ID ${stopId} not found.`);
return null;
},
},
};
</script>
Expand Down
52 changes: 48 additions & 4 deletions src/components/map/map-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,38 @@ export const buildDiffStyle = function (isOld) {
const buildPointStyle = function (title, svgSrc, color, highlight) {
const imgSize = highlight ? 30 : 20;
const circleRadius = highlight ? 20 : 15;
const zIndexValue = highlight ? 101 : 1;

if (svgSrc.includes('bus')) {
svgSrc = svgSrc.replace('fill="currentColor"', 'fill="white"');
} else {
svgSrc = svgSrc.replace('fill="currentColor"', `fill="${color}"`);
}

svgSrc = svgSrc.replace('<svg ', `<svg width="${imgSize}px" height="${imgSize}px" `);
svgSrc = svgSrc.replace('fill="currentColor"', `fill="${color}"`);

const iconStyle = new ol.style.Style({
image: new ol.style.Icon({
src: 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svgSrc),
}),
text: buildTextStyle(title, highlight),
zIndex: zIndexValue + 1,
});

let circleFillColor = 'rgba(255, 255, 255, 0.5)';
let circleStrokeColor = '#ddd';

if (svgSrc.includes('bus')) {
circleFillColor = highlight ? '#4baf50' : '#337ab7';
}

const circleStyle = new ol.style.Style({
image: new ol.style.Circle({
radius: circleRadius,
fill: new ol.style.Fill({ color: 'rgba(255, 255, 255, 0.5)' }),
stroke: new ol.style.Stroke({ color: '#ddd', width: 2 }),
fill: new ol.style.Fill({ color: circleFillColor }),
stroke: new ol.style.Stroke({ color: circleStrokeColor, width: 2 }),
}),
zIndex: zIndexValue,
});

return [circleStyle, iconStyle];
Expand All @@ -85,6 +100,8 @@ const svgSrcByDocumentType = {
r: icon({ prefix: 'fas', iconName: 'route' }).html[0],
u: icon({ prefix: 'fas', iconName: 'user' }).html[0],
x: icon({ prefix: 'fas', iconName: 'flag-checkered' }).html[0],
s: icon({ prefix: 'fas', iconName: 'bus' }).html[0],
z: icon({ prefix: 'waypoint', iconName: 'access' }).html[0],
};

const colorByConditionRating = {
Expand All @@ -107,7 +124,7 @@ export const getDocumentPointStyle = function (document, title, highlight) {
color = colorByConditionRating[document.condition_rating];
}

if (type === 'i' || type === 'u' || type === 'x' || type === 'o' || type === 'r') {
if (type === 'i' || type === 'u' || type === 'x' || type === 'o' || type === 'r' || type === 's') {
svgSrc = svgSrcByDocumentType[type];
} else if (type === 'w') {
if (
Expand All @@ -119,6 +136,33 @@ export const getDocumentPointStyle = function (document, title, highlight) {
color = '#4baf50';
}
svgSrc = icon({ prefix: 'waypoint', iconName: document.waypoint_type || 'misc' }).html[0];
} else if (type === 'z') {
svgSrc = svgSrcByDocumentType['z'] || icon({ prefix: 'waypoint', iconName: 'access' }).html[0];

if (document.public_transportation_rating && document.public_transportation_rating !== 'no service') {
color = '#4baf50';
} else {
color = '#F93';
}

const styles = buildPointStyle(title, svgSrc, color, highlight);

styles.forEach((style) => {
const image = style.getImage();

if (image instanceof ol.style.Circle) {
image.getFill().setColor('rgba(255, 255, 255, 1)');
image.getStroke().setColor('#4baf50');

style.setZIndex(highlight ? 101 : 50);
}

if (image instanceof ol.style.Icon) {
style.setZIndex(highlight ? 102 : 51);
}
});

return styles;
Comment on lines +139 to +165

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Extract magic numbers as constants and optimize style iteration

The code uses magic numbers for z-index values and iterates through styles inefficiently.

Add constants at the top of the file:

const Z_INDEX = {
  NORMAL: { CIRCLE: 1, ICON: 2 },
  HIGHLIGHT: { CIRCLE: 101, ICON: 102 },
  ACCESS_NORMAL: { CIRCLE: 50, ICON: 51 },
  ACCESS_HIGHLIGHT: { CIRCLE: 101, ICON: 102 }
};

Then refactor the type 'z' logic:

-    const styles = buildPointStyle(title, svgSrc, color, highlight);
-
-    styles.forEach((style) => {
-      const image = style.getImage();
-
-      if (image instanceof ol.style.Circle) {
-        image.getFill().setColor('rgba(255, 255, 255, 1)');
-        image.getStroke().setColor('#4baf50');
-
-        style.setZIndex(highlight ? 101 : 50);
-      }
-
-      if (image instanceof ol.style.Icon) {
-        style.setZIndex(highlight ? 102 : 51);
-      }
-    });
-
-    return styles;
+    const styles = buildPointStyle(title, svgSrc, color, highlight);
+    const [circleStyle, iconStyle] = styles;
+    
+    // Customize circle style
+    const circleImage = circleStyle.getImage();
+    circleImage.getFill().setColor('rgba(255, 255, 255, 1)');
+    circleImage.getStroke().setColor('#4baf50');
+    circleStyle.setZIndex(highlight ? Z_INDEX.ACCESS_HIGHLIGHT.CIRCLE : Z_INDEX.ACCESS_NORMAL.CIRCLE);
+    
+    // Customize icon style
+    iconStyle.setZIndex(highlight ? Z_INDEX.ACCESS_HIGHLIGHT.ICON : Z_INDEX.ACCESS_NORMAL.ICON);
+    
+    return styles;
🤖 Prompt for AI Agents
In src/components/map/map-utils.js between lines 139 and 165, replace all
hardcoded z-index numbers with named constants for clarity and maintainability.
Define a Z_INDEX constant object at the top of the file with properties for
normal and highlight states for both circle and icon styles as suggested. Then
update the style iteration logic to use these constants instead of magic numbers
when calling style.setZIndex, ensuring the correct z-index is applied based on
whether the style is highlighted and the type of image (Circle or Icon).

} else if (type === 'a') {
return new ol.style.Style();
} else {
Expand Down
Loading
Loading