Overview
TheStop class extends the Point class to represent a bus stop with additional metadata. Each stop has a unique identifier, belongs to a specific bus branch (route), and has a name.
Constructor
Parameters
An object containing stop information with the following properties:
Implementation
distance() method from the Point class, allowing distance calculations between stops or from stops to arbitrary geographic points.
Properties
Unique identifier for this bus stop
Identifier for the bus route/branch. Stops with the same branch_id are sequential stops on the same bus route.
The display name of the bus stop
Latitude coordinate (inherited from Point)
Longitude coordinate (inherited from Point)
Usage Examples
Creating a Stop
Calculating Distance to a Stop
Finding Nearby Stops
The route-finding algorithm uses stops to find which bus stops are within walking distance:Stop Sequences
Stops with the samebranch_id form a sequence along a bus route. The algorithm uses this to determine the next stop on a route:
Stops must be ordered correctly in the input data. The algorithm assumes that stops with the same
branch_id appear sequentially in the array, representing the order in which a bus visits them.Role in Route Finding
The Stop class plays a critical role in the route-finding algorithm:- Starting Points: Users begin their journey by walking to a nearby stop
- Route Building: Routes are constructed as sequences of stops
- Transfers: Users can walk between stops (different branch_ids) to transfer buses
- Validation: The algorithm prevents routes from visiting the same stop twice
Related Classes
- Point Class - Parent class providing geographic coordinate functionality
- Route Class - Uses Stop instances to construct routes
- Find Logic - Main algorithm that processes stops