I. 목표
Nominatim를 이용하여 Geocoding및 Reverse Geocoding 처리를 해본다.
II. 연구 및 개발내용
1. PHP 설치
apt-get install php
apt-get install libapache2-mod-php php-pgsql php-mysql apt-get install postgresql-server-dev-12 |
2. 사용자 계정 추가
adduser nominatim |
3. POSTGRESSQL 튜닝
/etc/postgresql/12/main/postgressql.conf
shared_buffers = 2GB
maintenance_work_mem = 10GB autovacuum_work_mem = 2GB work_mem = 50MB effective_cache_size = 24GB synchronous_commit = off max_wal_size = 1GB checkpoint_timeout = 10min checkpoint_completion_target = 0.9
|
참고) 처음 Import 할때에는 아래 사항을 추가, 임포트가 끝나면 아래 사항을 제거
fsync = off
full_page_writes = off |
4. POSTGRES 사용자 추가
1) nominatim: 임포트용
2) www-data : 웹서버 액세스용(읽기전용)
sudo -u postgres createuser -s nominatim
sudo -u postgres createuser www-data |
5. Nominatim 빌드
nominatim@moram-linux:~$ mkdir Service
nominatim@moram-linux:~$ mkdir ./Service/Nominatim nominatim@moram-linux:~$ cd ./Service/Nominatim/ nominatim@moram-linux:~/Service/Nominatim$ wget https://nominatim.org/release/Nominatim-4.0.1.tar.bz2 nominatim@moram-linux:~/Service/Nominatim$ tar xf Nominatim-4.0.1.tar.bz2 |
nominatim@moram-linux:~/Service/Nominatim$ mkdir ./build
nominatim@moram-linux:~/Service/Nominatim$ cd ./build nominatim@moram-linux:~/Service/Nominatim/build$ cmake ../Nominatim-4.0.1 nominatim@moram-linux:~/Service/Nominatim/build$ make nominatim@moram-linux:~/Service/Nominatim/build$ sudo make install (또는 root로 로그인하여 make install) |
6. 웹서버 설정
1) 서비스 디렉토리 생성
geocode@moram-linux:~$ mkdir Service/GeocodeWebSolution
geocode@moram-linux:~$ mkdir Service/GeocodeWebSolution/geocode-web geocode@moram-linux:~$ |
2) 아파치 환경설정
cd /etc/apache2/sites-available/
vi geocode.mbizok.com.conf |
<VirtualHost *:80>
ServerAdmin admin@moramcnt.com DocumentRoot /home/geocode/Service/GeocodeWebSolution/geocode-web DirectoryIndex index.php ServerName geocode.mbizok.com <Directory /home/geocode/Service/GeocodeWebSolution/geocode-web> Options FollowSymLinks MultiViews AddType application/json .php DirectoryIndex search.php Require all granted </Directory> Alias /nominatim /home/geocode/Service/GeocodeWebSolution/geocode-web LogLevel warn ErrorLog /var/log/apache2/error-geocode.mbizok.com.log CustomLog /var/log/apache2/access-geocode.mbizok.com.log combined </VirtualHost> |
a2ensite geocode.mbizok.com.conf |
service apache2 restart |
3) Nomination설정
/usr/local/etc/nominatim/.env 파일 생성
NOMINATIM_FLATNODE_FILE=”/usr/local/etc/nominatim”
# base URL of the replication service NOMINATIM_REPLICATION_URL=”https://download.geofabrik.de/asia/south-korea-updates/” # How often upstream publishes diffs (in seconds) NOMINATIM_REPLICATION_UPDATE_INTERVAL=86400 # How long to sleep if no update found yet (in seconds) NOMINATIM_REPLICATION_RECHECK_INTERVAL=900
|
7. 데이터 임포트
1) Wikipedia/Wikidata 순위 : 약 400메가로, Nominatim 데이터베이스에 약 4GB를 추가
mkdir ./Serivce/GeocodeWebSolution/data
cd ./Service/GeocodeWebSolution/data wget https://www.nominatim.org/data/wikimedia-importance.sql.gz
|
2) 지도데이터
wget https://download.geofabrik.de/asia/south-korea-latest.osm.pbf |
3) Import
nominatim import –osm-file south-korea-latest.osm.pbf 2>&1 | tee setup.log |
몇시간동안 처리할수 있으며 처리완료시 ./website 라는 폴더생성
2023-06-05 19:37:57: Starting indexing postcodes using 24 threads 2023-06-05 19:37:57: Starting postcodes (location_postcode) (using batch size 20) 2023-06-05 19:37:59: Done 4880 in 2 @ 2401.034 per second – postcodes (location_postcode) ETA (seconds): 3.52 2023-06-05 19:38:02: Done 7280 in 5 @ 1444.560 per second – postcodes (location_postcode) ETA (seconds): 4.19 2023-06-05 19:38:05: Done 8720 in 7 @ 1120.482 per second – postcodes (location_postcode) ETA (seconds): 4.12 2023-06-05 19:38:08: Done 9840 in 11 @ 886.524 per second – postcodes (location_postcode) ETA (seconds): 3.95 2023-06-05 19:38:10: Done 10740 in 12 @ 850.881 per second – postcodes (location_postcode) ETA (seconds): 3.05 2023-06-05 19:38:11: Done 11580 in 13 @ 871.244 per second – postcodes (location_postcode) ETA (seconds): 2.02 2023-06-05 19:38:12: Done 12460 in 14 @ 854.248 per second – postcodes (location_postcode) ETA (seconds): 1.03 2023-06-05 19:38:14: Done 13300 in 16 @ 796.466 per second – postcodes (location_postcode) ETA (seconds): 0.05 2023-06-05 19:38:15: Done 13338/13338 in 17 @ 769.445 per second – FINISHED postcodes (location_postcode)
2023-06-05 19:39:39: Post-process tables 2023-06-05 19:41:24: Create search index for default country names. 2023-06-05 19:41:31: Recompute word counts 2023-06-05 19:47:07: Setup website at /home/nominatim/Service/GeocodeWebSolution/data/website
nominatim@moram-linux:~/Service/GeocodeWebSolution/data$ |
nominatim refresh –website |