Skip to content

About

This project implements a Delivery Fare Estimation System capable of processing large volumes of GPS data to calculate fare estimates for courier deliveries. It's designed to handle big chunk of input data efficiently using concurrent processing.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Delivery Fare Estimation System

Overview

This project implements a Delivery Fare Estimation System capable of processing large volumes of GPS data to calculate fare estimates for courier deliveries. It's designed to handle big chunk of input data efficiently using concurrent processing.

Features

  • Filters invalid GPS data points based on speed thresholds
  • Calculates fares based on distance, time, and moving/idle states
  • Applies different rates for day and night times
  • Handles minimum fare and flag charge
  • Utilizes concurrent processing for high performance
  • Provides CPU and memory profiling options

Requirements

  • Go 2.0 or higher
  • Git

Installation

  1. Clone the repository:

    git clone https://github.com/n9e6y/snappBoxChallengeForAlgorithmArena.git
    cd snappBoxChallengeForAlgorithmArena
    
  2. Build the project:

    go build -o SBCFAA cmd/main.go
    

Usage

Run the fare estimator with the following command:

./SBCFAA -input <input_file_path> -output <output_file_path> [options]

Command-line Options

  • -input: Path to the input CSV file (required)
  • -output: Path for the output CSV file (default: "fare_estimates.csv")
  • -cpuprofile: Write CPU profile to file
  • -memprofile: Write memory profile to file

Example

./SBCFAA -input sample_data.csv -output fare_estimate.csv

Input Data Format

The input CSV file should have the following format:

id_delivery,lat,lng,timestamp
1,40.7128,-74.0060,1609459200
1,40.7129,-74.0061,1609459260
2,40.7130,-74.0062,1609459320
...
  • id_delivery: Unique identifier for each delivery
  • lat: Latitude of the GPS point
  • lng: Longitude of the GPS point
  • timestamp: Unix timestamp of the GPS point

Output Data Format

The output CSV file will have the following format:

id_delivery,fare_estimate
1,15.75
2,22.30
...

Fare Calculation Rules

  • Flag charge: 1.30
  • Minimum fare: 3.47
  • Moving rate (day, 05:00-00:00): 0.74 per km
  • Moving rate (night, 00:00-05:00): 1.30 per km
  • Idle rate: 11.90 per hour
  • Moving speed threshold: 10.0 km/h

Performance Considerations

  • The system uses concurrent processing to handle large datasets efficiently.
  • For very large input files, consider using the profiling options to optimize performance.

Running Tests

To run the unit tests:

go test ./...

To run tests with coverage:

go test ./... -cover

About

This project implements a Delivery Fare Estimation System capable of processing large volumes of GPS data to calculate fare estimates for courier deliveries. It's designed to handle big chunk of input data efficiently using concurrent processing.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages