-
-
Notifications
You must be signed in to change notification settings - Fork 34
Smart origin/lot1 #4357
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
Closed
Closed
Smart origin/lot1 #4357
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 c8cce71
set our internal api url
lgourdin 3660d3f
trying debug features
lgourdin 3820318
Revert "trying debug features"
lgourdin 2704688
add transport box
Floriane-jandot a53d9f1
[new feature] Display all stop points on list and map
Floriane-jandot 355fd21
[new feature] Add card reaction with map
Floriane-jandot 63aba40
[new feature] add "is reachable by public transport" box
Floriane-jandot efafb83
[new feature] display multiple stop_point for 1 stop_area, with toggl…
Floriane-jandot c4ecf84
[new feature] add public transports view on routes
Floriane-jandot c34be83
[new feature] add no public transport result
Floriane-jandot f6f9db9
[new feature] add partial result case for many waypoints
Floriane-jandot de720c5
[new features] rename table, visuals corrections, map hover fixed, ad…
Floriane-jandot 47ae353
Merge branch 'dev/fj'
Floriane-jandot 236d328
[new features] add automatic scroll for card list, movement on map
Floriane-jandot 214149d
[fix] use text from translation file
Floriane-jandot 63cd8d5
[fix] Color and put the waypoint icon in front of stops icon
Floriane-jandot 4fc85b1
[fix] remove public transports to /waypoints
Floriane-jandot c48e8bf
[fix] fix shaking map
Floriane-jandot aeccc65
[fix] Minors fix : translations, fully cliquable isAccessible, orange…
Floriane-jandot 39ef733
[fix] Fix responsive design of partial accessibility topo
Floriane-jandot 0d8ebeb
Merge branch 'fj/dev'
Floriane-jandot 2a58ad1
[fix] correct card long click, card scrolling, remove pin button
Floriane-jandot 08edb69
Merge branch 'fj/recette'
Floriane-jandot c0a6c29
Merge remote-tracking branch 'SmartOrigin/main' into smart-origin/lot1
Floriane-jandot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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]; | ||
|
|
@@ -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 = { | ||
|
|
@@ -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 ( | ||
|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| } else if (type === 'a') { | ||
| return new ol.style.Style(); | ||
| } else { | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid accessing internal properties of OpenLayers features
The code accesses
feature.values_.document.typewhich 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
🤖 Prompt for AI Agents