Code Monkey home page Code Monkey logo

ruian-api's Introduction

RUIAN API Server

Description

Public REST API for Czech RUIAN Database based on CSV exports

TODO

  • Automate load from CSV
  • Automate update from CSV
  • Generate exports - full (CSV, JSON, SQLite)
  • Generate exports - diff (CSV, JSON, SQLite)
  • Improvements...

Build

Download dependencies

dep ensure

Make

make

# or cross-compile for Linux amd64
make linux64

# or docker image
make docker

Run

Configuration ENV variables

Variables and default values

RUIAN_LISTEN_IP=0.0.0.0
RUIAN_LISTEN_PORT=8080
RUIAN_DB_HOSTNAME=localhost
RUIAN_DB_PORT=5432
RUIAN_DB_USER=postgres
RUIAN_DB_PASSWORD=password
RUIAN_DB_NAME=ruiandb
RUIAN_DB_RETRIES=10

Docker compose

  1. update docker-compose.yml environment variables values
  2. run docker-compose up -d

Standalone

RUIAN_DB_NAME=ruian_db_test ./ruian-api

Database setup

Requirements

  1. PostgreSQL + PostGIS
  2. Basic PostgreSQL extenstions

Setup

  1. download ziped CSV files
  2. extract .zip files
  3. join files and delete CSV headers with scripts
  4. update paths in import.sql script
  5. run import.sql script

Data URLs

  • Address Places:
  • Cadastral Teritories:

Usage

Rest API

API Call Examples

  • search for address based on part of address
curl 'localhost:8080/places/search?street=Sko&city=Zruč%20-%20S&city_part=Senec' | jq
[
  {
    "id": 9063811,
    "p": 78,
    "zip": "33008",
    "lng": 13.4180709920695,
    "lat": 49.7987100376894,
    "street": "Školní",
    "city": "Zruč-Senec",
    "city_part": "Senec",
    "address_string": "Školní 78, Senec, Zruč-Senec, 33008"
  },
  {
    "id": 9064001,
    "p": 97,
    "zip": "33008",
    "lng": 13.4185320615227,
    "lat": 49.7987472256835,
    "street": "Školní",
    "city": "Zruč-Senec",
    "city_part": "Senec",
    "address_string": "Školní 97, Senec, Zruč-Senec, 33008"
  },
  {
    "id": 9064028,
    "p": 99,
    "zip": "33008",
    "lng": 13.4185282829638,
    "lat": 49.7985229241633,
    "street": "Školní",
    "city": "Zruč-Senec",
    "city_part": "Senec",
    "address_string": "Školní 99, Senec, Zruč-Senec, 33008"
  },
  ...
]
  • search for address based on GPS coordinates and range
curl 'localhost:8080/places/search?latitude=49.8009&longitude=13.4193&range=500&limit=3' | jq
[
  {
    "id": 9063081,
    "p": 1,
    "zip": "33008",
    "lng": 13.4207954316166,
    "lat": 49.7937274728657,
    "street": "Senecká",
    "city": "Zruč-Senec",
    "city_part": "Senec",
    "address_string": "Senecká 1, Senec, Zruč-Senec, 33008"
  },
  {
    "id": 9063099,
    "p": 2,
    "zip": "33008",
    "lng": 13.4212828255798,
    "lat": 49.7933398312855,
    "street": "Senecká",
    "city": "Zruč-Senec",
    "city_part": "Senec",
    "address_string": "Senecká 2, Senec, Zruč-Senec, 33008"
  },
  {
    "id": 9063102,
    "p": 4,
    "zip": "33008",
    "lng": 13.4201734224913,
    "lat": 49.7928310973284,
    "street": "Strmá",
    "city": "Zruč-Senec",
    "city_part": "Senec",
    "address_string": "Strmá 4, Senec, Zruč-Senec, 33008"
  }
]
  • list streets based on street and city names name
curl 'localhost:8080/streets/search?street=Sko&city=Zruč%20-%20S' | jq
  • list cadastral territories based on name
curl 'localhost:8080/cadastral_territories/Holesovice' | jq
[
  {
    "id": 730122,
    "name": "Holešovice",
    "city": "Praha"
  },
  {
    "id": 641111,
    "name": "Holešovice u Chroustovic",
    "city": "Chroustovice"
  }
]

ruian-api's People

Contributors

jindrichskupa avatar svetlikr avatar

Watchers

 avatar

Forkers

svetlikr

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.