Skip to content

Cronjob to synchronize RÚIAN (Czech geolocation data) into local MySQL every month

Notifications You must be signed in to change notification settings

vpithart/ruian2mysql-sync

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RUIAN to MySQL synchronization cron job

Cronjob to synchronize RÚIAN (Czech geolocation data) into local MySQL every month.

The Czech Office for Surveying, Mapping and Cadastre (ČÚZK) offers a simple CSV file to download every month. It covers all the country's street addresses including gegraphic coordinates. The file is typically available on 1st or 2nd day of every month.

This script, import-ruian.sh, downloads and imports the new file as soon as it's ready, and then does nothing for rest of the month.

Installation

  1. clone, or unpack the archive into /opt
cd /opt
git clone https://github.com/vpithart/ruian2mysql-sync.git
  1. configure your MySQL server credentials
CREATE DATABASE ruian;
CREATE USER `ruian-import`@localhost IDENTIFIED BY "Haven't I told you to keep it secret?";
GRANT ALL on ruian.* TO `ruian-import`@localhost;
  1. give the MySQL connection credentials to the script
cd /opt/ruian2mysql-sync
cp .env.example .env
# Example of /opt/ruian2mysql-sync/.env
USER="ruian-import"
PASSWORD="haven't I told you to keep it secret?"
DB="ruian"
HOST="localhost"
PORT=3306
  1. edit your crontab (crontab -e) and add following line:
00 06   * * *     cd /opt/ruian2mysql-sync && ./import/import-ruian.sh 2>&1 | logger -t ruian2mysql-sync

Troubleshooting

  • Can you access the CUZK website from the server you have this script installed on?
wget -O- http://vdp.cuzk.cz/vymenny_format/csv/20180831_OB_ADR_csv.zip
  • It's safe to run the script as many times as you want
cd /opt/ruian2mysql-sync && ./import/import-ruian.sh
  • Still not there?
cd /opt/ruian2mysql-sync && bash -x import/import-ruian.sh

What's under the hood

Where the data comes from? See http://nahlizenidokn.cuzk.cz/StahniAdresniMistaRUIAN.aspx

Where the data goes to? Into your local MySQL database. The importer populates following tables:

  • ruain.obec (municipalities)
  • ruian.cobce (neighbourhoods)
  • ruian.ulice (streets)
  • ruian.adresa (street addresses)

About

Cronjob to synchronize RÚIAN (Czech geolocation data) into local MySQL every month

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 79.2%
  • Perl 20.8%