Skip to content

Commit

Permalink
#551 Fix shmetro track sharing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
thekingofcity committed Jun 3, 2023
1 parent 361b869 commit ab9c840
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 20 deletions.
26 changes: 14 additions & 12 deletions src/svgs/shmetro/destination-shmetro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ const DestSHMetro = () => {
...new Set(
routes
.filter(route => route.includes(current_stn_id))
.map(route => {
const res = route.filter(stn_id => !['linestart', 'lineend'].includes(stn_id));
return direction === 'l' ? res[0] : res.reverse()[0];
})
// find the first/last station id other than linestart/lineend
.map(route => (direction === 'l' ? route.at(1)! : route.at(route.length - 2)!))
),
];
// get the name from the destination id(s)
Expand Down Expand Up @@ -94,9 +92,11 @@ const DestSHMetro = () => {

// destination names of loop line, `sh2020` type will always be two lines
const dest_names = get_dest_names(regular_dest_ids, !loop && !(info_panel_type === 'sh2020'));
console.log(dest_names);
const coline_dest_names = get_dest_names(coline_dest_ids, true);

// hide regular Dest when the current station is on the coline in a direction that can not go to main line
const only_coline = coline_dest_ids.length !== 0 && regular_dest_ids.length === 0;

// this will give the space for at most two lines of dest_names
const coline_dy = 250;
// get coline info from coline_dest_ids
Expand All @@ -114,13 +114,15 @@ const DestSHMetro = () => {
};
return (
<>
<Dest
dest_names={dest_names}
line_name={line_name}
line_color={[theme[2], theme[3]]}
coline={!!coline_dest_ids.length}
upper={!!coline_dest_ids.length}
/>
{!only_coline && (
<Dest
dest_names={dest_names}
line_name={line_name}
line_color={[theme[2], theme[3]]}
coline={!!coline_dest_ids.length}
upper={!!coline_dest_ids.length}
/>
)}
{coline_dest_ids.length &&
// multiple coline dest is not supported yet
coline_dest_ids.map(coline_dest_id => (
Expand Down
31 changes: 23 additions & 8 deletions src/svgs/shmetro/runin-shmetro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,34 @@ const TerminalStation = (props: { mode: 'terminal' | 'original'; prevStnIds: str
return (
<>
{mode === 'original' && (
<path
transform={`translate(0,${coline.length ? '198' : '220'})${coline.length ? 'scale(1,2)' : ''}`}
stroke={nextColineColor}
strokeWidth={12}
d={direction === 'l' ? `M ${svgWidth.runin - 24},16 H 36` : `M24,16 H ${svgWidth.runin - 36}`}
markerEnd="url(#slope)"
/>
<>
{nextColineColor !== 'var(--rmg-theme-colour)' && (
<marker id={`slope_${nextColineColor}`} viewBox="-1.5 0 3 1.5" refY={0.5}>
<path d="M0,0L1,1H-1z" fill={nextColineColor} />
</marker>
)}
<path
transform={`translate(0,${Object.keys(coline).length ? 198 : 220})${
Object.keys(coline).length ? 'scale(1,2)' : ''
}`}
stroke={nextColineColor}
strokeWidth={12}
d={direction === 'l' ? `M ${svgWidth.runin - 24},16 H 36` : `M24,16 H ${svgWidth.runin - 36}`}
markerEnd={
nextColineColor === 'var(--rmg-theme-colour)'
? 'url(#slope)'
: `url(#slope_${nextColineColor})`
}
/>
</>
)}

{mode === 'terminal' && (
<g filter={theme[2] === '#B5B5B6' ? 'url(#pujiang_outline)' : undefined}>
<path
transform={`translate(0,${coline.length ? '198' : '220'})${coline.length ? 'scale(1,2)' : ''}`}
transform={`translate(0,${Object.keys(coline).length ? 198 : 220})${
Object.keys(coline).length ? 'scale(1,2)' : ''
}`}
stroke="var(--rmg-grey)"
strokeWidth={12}
d={`M24,16 H ${svgWidth.runin - 24}`}
Expand Down

0 comments on commit ab9c840

Please sign in to comment.