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)
Backend
- Python, Django, Django REST Framework
- Unit tests: pytest
Frontend
- React + TypeScript (Vite)
- Unit tests: Vitest + Testing Library
Prereqs: Docker Desktop installed and running.
From the repository root:
docker compose up --buildThe url to access the API is: http://localhost:8000/ The frontend is available at: http://localhost:5173/
cd backend
python -m venv venv
# Windows:
venv\Scripts\activate
pip install -r requirements.txt
python manage.py runserver
cd frontend
npm install
npm run dev
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
}
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.
cd backend python -m pytest -q
cd frontend npm run test
- 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