Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polyline: Station & Offset Calculation

Computes Station and Offset between an input point (Easting, Northing) and a polyline read from an ASCII CSV file.

  • Offset: smallest perpendicular distance from the Point to the polyline
  • Station: distance from the start of the polyline (along the polyline) to the closest point of intersection
  • Input: the Point (Easting, Northing)

Tech Stack

Backend

  • Python, Django, Django REST Framework
  • Unit tests: pytest

Frontend

  • React + TypeScript (Vite)
  • Unit tests: Vitest + Testing Library

Quickstart (Docker)

Prereqs: Docker Desktop installed and running.

From the repository root:

docker compose up --build

The url to access the API is: http://localhost:8000/ The frontend is available at: http://localhost:5173/

Local Development

Backend

cd backend
python -m venv venv

# Windows: 
venv\Scripts\activate
pip install -r requirements.txt
python manage.py runserver

Frontend

cd frontend
npm install
npm run dev

API

POST /api/station-offset/

Computes station/offset for a point relative to the uploaded polyline.

  • Request: multipart/form-data
  • file: CSV file, no header, each row x,y
  • point_x: number
  • point_y: number

Response 200

{
  "station": 14.0,
  "offset": 2.0,
  "closest_point": { "x": 10.0, "y": 4.0 },
  "segment_index": 1
}

Coordinate formats

Point input (point_x, point_y): accepts integers and floats.

The frontend normalizes comma decimals (e.g., 7,5) to dot decimals (7.5) before sending to the API.

CSV polyline: expects comma-separated columns (x,y). Decimal coordinates must use dot (.) to avoid ambiguity with the CSV delimiter.

Tests

Backend

cd backend python -m pytest -q

Frontend

cd frontend npm run test

Structure (high level)

  • backend/stationing/domain: domain value objects (e.g., Point)
  • backend/stationing/services: core station/offset computation (pure + unit tested)
  • backend/stationing/infrastructure: CSV parsing
  • backend/stationing/api: DRF serializers/views/urls
  • frontend/src/api: API client
  • frontend/src/components: UI components

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages