RSS Amplifier

Recent Questions - Meta Stack Exchange · Aug 17, 2026

How can I calculate dynamic NYC limo fare estimates using a distance matrix API?

0
Sign in to vote or save

This page did not load. You can still read it on the original site — the toolbar below keeps your place in the directory.

I'm working on a transportation booking system for New York and I'm trying to build a dynamic fare estimator for different pickup and drop-off locations. The application needs to calculate the driving distance and estimated travel time between two addresses using a distance matrix or routing API. Based on the returned distance, I then want to apply different pricing rules for a private car or limo…

I'm working on a transportation booking system for New York and I'm trying to build a dynamic fare estimator for different pickup and drop-off locations.

The application needs to calculate the driving distance and estimated travel time between two addresses using a distance matrix or routing API. Based on the returned distance, I then want to apply different pricing rules for a private car or limo service.

For example, the pricing logic could include:

A minimum/base fare A per-mile or per-kilometer rate Different rates for longer trips Optional airport or toll fees Additional charges based on vehicle type Rounding the final estimated fare to two decimal places

I'm considering using a distance matrix API to retrieve the actual driving distance rather than calculating the fare from straight-line distance.

A simplified calculation would be something like:

distance = API driving distance

if distance <= minimum_distance: fare = base_fare else: fare = base_fare + (distance - minimum_distance) * rate

What would be the recommended way to structure this calculation so that the distance returned by the API can be reliably converted into a dynamic fare?

I'm particularly interested in best practices for handling API responses, units (miles vs. kilometers), rounding, and separating the API distance calculation from the fare-pricing logic.

The application is related to bespoke transportation new York, but the technical problem is specifically about implementing the distance-based pricing logic.

I'm affiliated with the transportation business mentioned above, so I'm disclosing that relationship here.

Read on meta.stackexchange.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.