Skip to content

thykel/can-i-sleep-here

Repository files navigation

Wild Camping Legality Checker API

A Rails API that answers "Can I legally sleep here?" for any GPS coordinate using actual land classification data + legal rules.

Quick Start

# Start the containers
docker compose up -d

# Run migrations (first time only)
docker compose exec api bin/rails db:migrate

# Import the GeoJSON data
docker compose exec api rake import:all

# Test the API
curl "http://localhost:3000/check?lat=49.68&lng=13.82"

API Endpoints

GET /check?lat=X&lng=Y

Check if wild camping is allowed at a location.

Example:

curl "http://localhost:3000/check?lat=49.68&lng=13.82"

Response:

{
  "lat": 49.68,
  "lng": 13.82,
  "country": "CZ",
  "areas": [
    {
      "name": "CHKO Brdy",
      "protect_class": "5",
      "protection_title": "Chráněná krajinná oblast",
      "type": "protected_area"
    }
  ],
  "verdict": "gray",
  "explanation": "This is a Protected Landscape Area (CHKO). Bivouacking is generally tolerated if you stay one night, arrive late, leave early, and leave no trace. Not officially permitted."
}

Verdicts

Verdict Meaning
allowed Outside protected areas, generally tolerated
gray In protected area where bivouacking is tolerated but not officially permitted
forbidden Strictly prohibited, may result in fines

GET /map

Interactive map visualization with click-to-check functionality.

Frontend

The app includes an interactive web frontend at /map built with:

  • Leaflet.js for map rendering
  • OpenStreetMap tiles
  • Click-to-check functionality that queries the /check API
  • Visual display of protected areas and military zones
  • URL parameter support for sharing locations (/map?lat=49.68&lng=13.82)

The frontend displays separate verdicts for:

  • Bivouacking (sleeping without tent) - more permissive
  • Camping (with tent) - stricter rules apply

GET /up

Health check endpoint.

Stack

  • Ruby 3.4 / Rails 8.1
  • PostgreSQL 16 + PostGIS 3.4
  • activerecord-postgis gem for spatial queries
  • Docker Compose for containerization

Development

# Start services
docker compose up

# Rails console
docker compose exec api bin/rails console

# Re-import data
docker compose exec api rake import:all

# View logs
docker compose logs -f api

Data Sources

Protected area data from OpenStreetMap via Overpass Turbo, stored in chranene_oblasti.geojson.

About

Check whether you are able to camp at a given location (CZ only) (Claude Code testing)

Resources

License

Stars

Watchers

Forks

Contributors