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

Stop Grouping with Distance Range and (General) Directional filter #193

Closed
wants to merge 7 commits into from

Conversation

chengkeith
Copy link
Contributor

@chengkeith chengkeith commented Jul 5, 2024

Group bus stops in the vicinity to show ETAs together (although having different stop id)

Feature: Bus stops toward opposite direction are not shown
Current design:

  • search bus stops within 50m recursively
  • filter bus stops having any routes with next stop in same direction (45 degrees off-course to the left or right are allowed)

Example screenshot (宋皇臺公園)

Before change (only 796X is shown)
image

After change (more routes are shown)
image

Summary by CodeRabbit

  • New Features

    • Enhanced stop grouping functionality based on route IDs, improving the precision of stop suggestions.
  • Bug Fixes

    • Fixed issues related to stop proximity and direction calculations, ensuring more accurate stop listings.
  • Refactor

    • Updated internal logic to use new hooks and interfaces for better code maintainability and readability.

chengkeith and others added 4 commits July 4, 2024 19:57
Copy link

coderabbitai bot commented Jul 5, 2024

Walkthrough

The recent changes introduce a new routeId property to the StopRouteList component. This property enables the component to fetch stop groups more accurately by utilizing the useStopGroup hook, which now supports filtering by routeId. The useStopGroup function and the StopRouteList component have been updated accordingly to accommodate this new functionality.

Changes

Files Change Summary
src/components/bookmarked-stop/StopRouteList.tsx Added routeId property to StopRouteList component to utilize useStopGroup hook for fetching stop groups.
src/hooks/useStopGroup.tsx, src/stopGroup.ts Enhanced useStopGroup function and related interfaces to support filtering stop groups by routeId.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant StopRouteList
    participant useStopGroup
    participant getStopGroup

    User->>StopRouteList: Render with {stops, routeId, isFocus}
    StopRouteList->>useStopGroup: Call with {stopKeys, routeId}
    useStopGroup->>getStopGroup: Fetch stop group with routeId filtering
    getStopGroup->>useStopGroup: Return filtered stop group
    useStopGroup->>StopRouteList: Return stop group
    StopRouteList->>User: Render stop group
Loading

Poem

Amid the code, where changes bloom,
A routeId whispers, clears the gloom.
Stops align, like stars in sight,
Groups refined, with filtered light.
🎉✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1212440 and e72f154.

Files selected for processing (6)
  • src/components/bookmarked-stop/StopRouteList.tsx (1 hunks)
  • src/components/bookmarked-stop/SwipeableStopList.tsx (1 hunks)
  • src/components/route-eta/StopDialog.tsx (2 hunks)
  • src/hooks/useStopGroup.tsx (1 hunks)
  • src/pages/RouteEta.tsx (1 hunks)
  • src/utils.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/components/bookmarked-stop/SwipeableStopList.tsx
Additional context used
Biome
src/hooks/useStopGroup.tsx

[error] 51-54: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 92-106: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)

GitHub Check: build (21.x)
src/hooks/useStopGroup.tsx

[warning] 178-178:
React Hook useMemo has missing dependencies: 'getAllRouteStopsBearings' and 'isBearingInRange'. Either include them or remove the dependency array

GitHub Check: build (20.x)
src/hooks/useStopGroup.tsx

[warning] 178-178:
React Hook useMemo has missing dependencies: 'getAllRouteStopsBearings' and 'isBearingInRange'. Either include them or remove the dependency array

Additional comments not posted (22)
src/components/bookmarked-stop/StopRouteList.tsx (4)

3-3: Import Approved.

The useStopGroup hook import is necessary for the functionality.


9-9: Prop Addition Approved.

The routeId prop is necessary for the new functionality of grouping stops based on route.


13-13: Prop Addition with Default Value Approved.

The routeId prop is added with a default value of undefined, ensuring backward compatibility.


14-14: Hook Usage Approved.

The useStopGroup hook is correctly used to get the stop group based on stopKeys and routeId.

src/components/route-eta/StopDialog.tsx (3)

26-26: Prop Addition Approved.

The routeId prop is necessary for the new functionality of grouping stops based on route.


31-31: Prop Addition Approved.

The routeId prop is correctly added to the StopDialog component, ensuring the StopRouteList component receives it.


87-87: Component Usage Approved.

The StopRouteList component is correctly used with the routeId prop.

src/pages/RouteEta.tsx (1)

256-256: Component Usage Approved.

The StopDialog component is correctly used with the routeId prop.

src/hooks/useStopGroup.tsx (14)

1-1: Import Approved.

The useContext and useMemo hooks are necessary for the functionality.


2-2: Import Approved.

The Company type is necessary for the functionality.


3-3: Import Approved.

The StopListEntry type is necessary for the functionality.


4-4: Import Approved.

The DbContext is necessary for the functionality.


5-5: Import Approved.

The getDistance and getBearing functions are necessary for the functionality.


7-10: Interface Definition Approved.

The useStopGroupProps interface definition is correct and necessary for type safety.


11-15: Interface Definition Approved.

The StopListEntryExtended interface definition is correct and necessary for the functionality.


16-20: Interface Definition Approved.

The RouteStopCoSeq interface definition is correct and necessary for the functionality.


23-25: Function Definition Approved.

The useStopGroup function definition is correct and aligns with the new functionality.


26-28: Context Usage Approved.

The DbContext is correctly used to access routeList and stopList.


30-33: Constants Definition Approved.

The constants DISTANCE_THRESHOLD, BEARING_THRESHOLD, and STOP_LIST_LIMIT are necessary for the functionality and the values seem reasonable.


35-40: Function Definitions Approved.

The getDistanceStop and getBearingStops functions are correctly defined to calculate distance and bearing between stops.


59-87: Logic for Route Stops Approved.

The logic for route stops based on routeId is correct and aligns with the new functionality.


108-181: **Add Missing Dependencies to `use

Tools
GitHub Check: build (21.x)

[warning] 178-178:
React Hook useMemo has missing dependencies: 'getAllRouteStopsBearings' and 'isBearingInRange'. Either include them or remove the dependency array

GitHub Check: build (20.x)

[warning] 178-178:
React Hook useMemo has missing dependencies: 'getAllRouteStopsBearings' and 'isBearingInRange'. Either include them or remove the dependency array

Comment on lines +37 to +48
export const getBearing = (a: GeoLocation, b: GeoLocation) => {
// Reference: https://www.movable-type.co.uk/scripts/latlong.html
const φ1 = a.lat * Math.PI / 180; // φ, λ = lat, lon in radians
const φ2 = b.lat * Math.PI / 180;
const λ1 = a.lng * Math.PI / 180; // φ, λ = lat, lon in radians
const λ2 = b.lng * Math.PI / 180;
const y = Math.sin(λ2 - λ1) * Math.cos(φ2);
const x = Math.cos(φ1) * Math.sin(φ2) - Math.sin(φ1) * Math.cos(φ2) * Math.cos(λ2-λ1);
const θ = Math.atan2(y, x);
const brng = (θ * 180 / Math.PI + 360) % 360; // in degrees
return brng;
};
Copy link

Choose a reason for hiding this comment

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

Optimize variable declarations and add comments for clarity.

The function is correctly implemented but can be optimized and improved for readability by combining the variable declarations and adding comments to explain the steps.

export const getBearing = (a: GeoLocation, b: GeoLocation) => {
  // Reference: https://www.movable-type.co.uk/scripts/latlong.html
- const φ1 = a.lat * Math.PI / 180; // φ, λ = lat, lon in radians
- const φ2 = b.lat * Math.PI / 180;
- const λ1 = a.lng * Math.PI / 180; // φ, λ = lat, lon in radians
- const λ2 = b.lng * Math.PI / 180;
- const y = Math.sin(λ2 - λ1) * Math.cos(φ2);
- const x = Math.cos(φ1) * Math.sin(φ2) - Math.sin(φ1) * Math.cos(φ2) * Math.cos(λ2-λ1);
- const θ = Math.atan2(y, x);
- const brng = (θ * 180 / Math.PI + 360) % 360; // in degrees
- return brng;
+ const φ1 = a.lat * Math.PI / 180, φ2 = b.lat * Math.PI / 180;
+ const λ1 = a.lng * Math.PI / 180, λ2 = b.lng * Math.PI / 180;
+ 
+ // Calculate the differences
+ const Δλ = λ2 - λ1;
+ const y = Math.sin(Δλ) * Math.cos(φ2);
+ const x = Math.cos(φ1) * Math.sin(φ2) - Math.sin(φ1) * Math.cos(φ2) * Math.cos(Δλ);
+ 
+ // Calculate the bearing
+ const θ = Math.atan2(y, x);
+ return (θ * 180 / Math.PI + 360) % 360; // in degrees
};
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
export const getBearing = (a: GeoLocation, b: GeoLocation) => {
// Reference: https://www.movable-type.co.uk/scripts/latlong.html
const φ1 = a.lat * Math.PI / 180; // φ, λ = lat, lon in radians
const φ2 = b.lat * Math.PI / 180;
const λ1 = a.lng * Math.PI / 180; // φ, λ = lat, lon in radians
const λ2 = b.lng * Math.PI / 180;
const y = Math.sin(λ2 - λ1) * Math.cos(φ2);
const x = Math.cos(φ1) * Math.sin(φ2) - Math.sin(φ1) * Math.cos(φ2) * Math.cos(λ2-λ1);
const θ = Math.atan2(y, x);
const brng = (θ * 180 / Math.PI + 360) % 360; // in degrees
return brng;
};
export const getBearing = (a: GeoLocation, b: GeoLocation) => {
// Reference: https://www.movable-type.co.uk/scripts/latlong.html
const φ1 = a.lat * Math.PI / 180, φ2 = b.lat * Math.PI / 180;
const λ1 = a.lng * Math.PI / 180, λ2 = b.lng * Math.PI / 180;
// Calculate the differences
const Δλ = λ2 - λ1;
const y = Math.sin(Δλ) * Math.cos(φ2);
const x = Math.cos(φ1) * Math.sin(φ2) - Math.sin(φ1) * Math.cos(φ2) * Math.cos(Δλ);
// Calculate the bearing
const θ = Math.atan2(y, x);
return (θ * 180 / Math.PI + 360) % 360; // in degrees
};

Comment on lines 42 to 57
const getAllRouteStopsBearings = (routeStops : RouteStopCoSeq[]) => {
// routeStop example: {"routeKey":"101+1+KENNEDY TOWN+KWUN TONG (YUE MAN SQUARE)","co":"ctb","seq":12}
return routeStops.map(routeStop => {
const { routeKey, co, seq } = routeStop;
const stopLength = routeList[routeKey].stops[co].length;
let stopA, stopB;
if(seq == stopLength - 1) { // last stop
// no next stop, hence no forward bearing, just use -1 as dummy value then discard it later
return -1;
} else {
stopA = stopList[routeList[routeKey].stops[co][seq]];
stopB = stopList[routeList[routeKey].stops[co][seq + 1]];
}
return getBearingStops(stopA, stopB);
}).filter(brng => brng !== -1);
}
Copy link

Choose a reason for hiding this comment

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

Optimize the getAllRouteStopsBearings Function.

The function definition is correct but can be optimized by removing the unnecessary else clause.

-  if(seq == stopLength - 1) { // last stop
-    // no next stop, hence no forward bearing, just use -1 as dummy value then discard it later
-    return -1;
-  } else {
-    stopA = stopList[routeList[routeKey].stops[co][seq]];
-    stopB = stopList[routeList[routeKey].stops[co][seq + 1]];
-  }
+  if(seq == stopLength - 1) return -1; // last stop
+  stopA = stopList[routeList[routeKey].stops[co][seq]];
+  stopB = stopList[routeList[routeKey].stops[co][seq + 1]];
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
const getAllRouteStopsBearings = (routeStops : RouteStopCoSeq[]) => {
// routeStop example: {"routeKey":"101+1+KENNEDY TOWN+KWUN TONG (YUE MAN SQUARE)","co":"ctb","seq":12}
return routeStops.map(routeStop => {
const { routeKey, co, seq } = routeStop;
const stopLength = routeList[routeKey].stops[co].length;
let stopA, stopB;
if(seq == stopLength - 1) { // last stop
// no next stop, hence no forward bearing, just use -1 as dummy value then discard it later
return -1;
} else {
stopA = stopList[routeList[routeKey].stops[co][seq]];
stopB = stopList[routeList[routeKey].stops[co][seq + 1]];
}
return getBearingStops(stopA, stopB);
}).filter(brng => brng !== -1);
}
const getAllRouteStopsBearings = (routeStops : RouteStopCoSeq[]) => {
// routeStop example: {"routeKey":"101+1+KENNEDY TOWN+KWUN TONG (YUE MAN SQUARE)","co":"ctb","seq":12}
return routeStops.map(routeStop => {
const { routeKey, co, seq } = routeStop;
const stopLength = routeList[routeKey].stops[co].length;
let stopA, stopB;
if(seq == stopLength - 1) return -1; // last stop
stopA = stopList[routeList[routeKey].stops[co][seq]];
stopB = stopList[routeList[routeKey].stops[co][seq + 1]];
return getBearingStops(stopA, stopB);
}).filter(brng => brng !== -1);
}
Tools
Biome

[error] 51-54: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)

Comment on lines 88 to 106
const bearingTargets = getAllRouteStopsBearings(routeStops);
const isBearingInRange = (bearing : number) => {
if(BEARING_THRESHOLD >= 180 || bearingTargets.length == 0) {
return true;
} else {
for(let i = 0; i < bearingTargets.length; ++i) {
let bearingMin = bearingTargets[i] - BEARING_THRESHOLD;
let bearingMax = bearingTargets[i] + BEARING_THRESHOLD;
if(bearingMin < 0)
bearingMin += 360;
if(bearingMax > 360)
bearingMax -= 360;
if((bearingMin <= bearingMax && bearingMin <= bearing && bearing <= bearingMax)
|| (bearingMin > bearingMax && (bearingMin <= bearing || bearing <= bearingMax))) // crossing 0/360° mark, eg min=340°,max=020°
return true;
}
return false;
}
}
Copy link

Choose a reason for hiding this comment

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

Optimize the isBearingInRange Function.

The function definition is correct but can be optimized by removing the unnecessary else clause.

-  if(BEARING_THRESHOLD >= 180 || bearingTargets.length == 0) {
-    return true;
-  } else {
-    for(let i = 0; i < bearingTargets.length; ++i) {
-      let bearingMin = bearingTargets[i] - BEARING_THRESHOLD;
-      let bearingMax = bearingTargets[i] + BEARING_THRESHOLD;
-      if(bearingMin < 0)
-        bearingMin += 360;
-      if(bearingMax > 360)
-        bearingMax -= 360;
-      if((bearingMin <= bearingMax && bearingMin <= bearing && bearing <= bearingMax)
-      || (bearingMin > bearingMax && (bearingMin <= bearing || bearing <= bearingMax))) // crossing 0/360° mark, eg min=340°,max=020°
-        return true;
-    }
-    return false;
-  }
+  if(BEARING_THRESHOLD >= 180 || bearingTargets.length == 0) return true;
+  for(let i = 0; i < bearingTargets.length; ++i) {
+    let bearingMin = bearingTargets[i] - BEARING_THRESHOLD;
+    let bearingMax = bearingTargets[i] + BEARING_THRESHOLD;
+    if(bearingMin < 0) bearingMin += 360;
+    if(bearingMax > 360) bearingMax -= 360;
+    if((bearingMin <= bearingMax && bearingMin <= bearing && bearing <= bearingMax)
+    || (bearingMin > bearingMax && (bearingMin <= bearing || bearing <= bearingMax))) // crossing 0/360° mark, eg min=340°,max=020°
+      return true;
+  }
+  return false;
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
const bearingTargets = getAllRouteStopsBearings(routeStops);
const isBearingInRange = (bearing : number) => {
if(BEARING_THRESHOLD >= 180 || bearingTargets.length == 0) {
return true;
} else {
for(let i = 0; i < bearingTargets.length; ++i) {
let bearingMin = bearingTargets[i] - BEARING_THRESHOLD;
let bearingMax = bearingTargets[i] + BEARING_THRESHOLD;
if(bearingMin < 0)
bearingMin += 360;
if(bearingMax > 360)
bearingMax -= 360;
if((bearingMin <= bearingMax && bearingMin <= bearing && bearing <= bearingMax)
|| (bearingMin > bearingMax && (bearingMin <= bearing || bearing <= bearingMax))) // crossing 0/360° mark, eg min=340°,max=020°
return true;
}
return false;
}
}
const bearingTargets = getAllRouteStopsBearings(routeStops);
const isBearingInRange = (bearing : number) => {
if(BEARING_THRESHOLD >= 180 || bearingTargets.length == 0) return true;
for(let i = 0; i < bearingTargets.length; ++i) {
let bearingMin = bearingTargets[i] - BEARING_THRESHOLD;
let bearingMax = bearingTargets[i] + BEARING_THRESHOLD;
if(bearingMin < 0) bearingMin += 360;
if(bearingMax > 360) bearingMax -= 360;
if((bearingMin <= bearingMax && bearingMin <= bearing && bearing <= bearingMax)
|| (bearingMin > bearingMax && (bearingMin <= bearing || bearing <= bearingMax))) // crossing 0/360° mark, eg min=340°,max=020°
return true;
}
return false;
}
Tools
Biome

[error] 92-106: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e72f154 and 24427df.

Files selected for processing (1)
  • src/hooks/useStopGroup.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/hooks/useStopGroup.tsx

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 24427df and eb5313f.

Files selected for processing (1)
  • src/hooks/useStopGroup.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/hooks/useStopGroup.tsx

@chengkeith chengkeith marked this pull request as draft July 10, 2024 10:01
@chengkeith
Copy link
Contributor Author

Temporarily changing status of this PR to "draft" as I found a critical problem (react keeps fetching data infinitely), seems react keep re-rendering infinitely.

I suggest deploy the code to alpha site first if alpha site is available.

- rename useStopGroup method as simple util method getStopGroup
- use useMemo to cache result of getStopGroup to prevent infinite rendering
@chengkeith chengkeith marked this pull request as ready for review July 11, 2024 11:02
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between eb5313f and 4f70eaa.

Files selected for processing (2)
  • src/components/bookmarked-stop/StopRouteList.tsx (1 hunks)
  • src/stopGroup.ts (1 hunks)
Additional comments not posted (13)
src/components/bookmarked-stop/StopRouteList.tsx (3)

3-3: Import statement approved.

The getStopGroup function is correctly imported from ../../stopGroup.


11-11: Interface update approved.

The routeId property is correctly added to the StopRouteListProps interface with the appropriate type string | undefined.


15-20: Component update approved.

The StopRouteList component correctly uses the routeId prop and calls the getStopGroup function with the new prop. The use of useMemo ensures that the stop group is only recalculated when necessary, optimizing performance.

src/stopGroup.ts (10)

1-3: Import statements approved.

The necessary types and utility functions are correctly imported.


5-10: Interface useStopGroupProps approved.

The useStopGroupProps interface is correctly defined with appropriate property types.


11-15: Interface StopListEntryExtended approved.

The StopListEntryExtended interface is correctly defined with appropriate additional properties.


16-20: Interface RouteStopCoSeq approved.

The RouteStopCoSeq interface is correctly defined with appropriate property types.


23-25: Function signature approved.

The getStopGroup function signature is correctly defined with appropriate parameters.


27-37: Constants and helper functions approved.

The constants for distance, bearing, and stop list limits are appropriately set. The helper functions for distance and bearing calculations are correctly implemented.


39-52: getAllRouteStopsBearings function approved.

The function correctly calculates bearings for route stops and filters out invalid bearings.


54-82: Route stops collection logic approved.

The logic for collecting route stops based on the presence of routeId and stop keys is correctly implemented.


103-139: searchNearbyStops function approved.

The function correctly searches for nearby stops within distance and bearing thresholds and adds them to the list if they meet the criteria.


145-175: Main logic of getStopGroup approved.

The function correctly implements the main logic for recursively searching for nearby stops, sorting them by distance, and returning the stop group.

@chengkeith
Copy link
Contributor Author

This PR is "ready to reivew" again. The bug mentioned yesterday is solved by new commit. Can we deploy it to "alpha" site for testing just to play safee?

By the way this PR should be linked to #160

@chengkeith
Copy link
Contributor Author

This PR is being closed and will be replaced by new PR created at hkbus/hk-bus-crawling#26

@chengkeith chengkeith closed this Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant