overpass-api和overpass-turbo安装(ubuntu16.04)

来源:互联网 发布:怎么可以增加淘宝店的 编辑:程序博客网 时间:2024/05/29 13:25

overpass-api和overpass-turbo安装

  • 介绍
  • overpass-api安装
  • overpass-turbo安装
  • 问题记录

介绍

overpass-api用于查询openstreemap的node,way和area,官网的overpass-api访问较慢,所以选择装在自己电脑上,安装需要的存储空间比较大,最少几十G。

overpass-api安装

安装步骤参考官网http://wiki.openstreetmap.org/wiki/Overpass_API/Installation
1)安装依赖项

sudo apt-get install g++ make expat libexpat1-dev zlib1g-dev

2)安装overpass-api

wget http://dev.overpass-api.de/releases/osm-3s_v[latest_version].tar.gztar -zxvf osm-3s_v*.tar.gzcd osm-3s_v*./configure CXXFLAGS="-O2" --prefix=$EXEC_DIRmake install

3)安装数据库

./download_clone.sh --db-dir=database_dir --source=http://dev.overpass-api.de/api_drolbr/ --meta=no

上述–meta有三种选项,yes|no|attic,分别表示有元数据/无元数据/历史版本,元数据指作者,日期,版本等
4)验证

$EXEC_DIR/bin/osm3s_query --db-dir=$DB_DIR<query type="node"><bbox-query n="51.0" s="50.9" w="6.9" e="7.0"/><has-kv k="amenity" v="pub"/></query><print/>CTRL+D

5)安装web-api

nohup $EXEC_DIR/bin/dispatcher --osm-base --db-dir=$DB_DIR &sudo apt-get install apache2sudo a2enmod cgicd /etc/apache2/sites-availablevi default.config(可能是别的名字),编辑内容如下:<VirtualHost *:80>    ServerAdmin webmaster@localhost    ExtFilterDefine gzip mode=output cmd=/bin/gzip    DocumentRoot [YOUR_HTML_ROOT_DIR]    # This directive indicates that whenever someone types http://www.mydomain.com/api/     # Apache2 should refer to what is in the local directory [YOUR_EXEC_DIR]/cgi-bin/    ScriptAlias /api/ [YOUR_EXEC_DIR]/cgi-bin/    # This specifies some directives specific to the directory: [YOUR_EXEC_DIR]/cgi-bin/    <Directory "[YOUR_EXEC_DIR]/cgi-bin/">                AllowOverride None                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch                # For Apache 2.4:                #  Order allow,deny                # For Apache > 2.4:                  Require all granted                #SetOutputFilter gzip                #Header set Content-Encoding gzip    </Directory>    ErrorLog /var/log/apache2/error.log    # Possible values include: debug, info, notice, warn, error, crit, alert, emerg    LogLevel warn    CustomLog /var/log/apache2/access.log combined</VirtualHost>
sudo a2enmod cgia2enmod ext_filter/etc/init.d/apache2 restartsudo nohup $EXEC_DIR/bin/dispatcher --osm-base --db-dir=$DB_DIR &

验证

wget --output-document=test.xml http://[your_domain_or_IP_address]/api/interpreter?data=%3Cprint%20mode=%22body%22/%3E

输出如下:

<?xml version="1.0" encoding="UTF-8"?><osm-derived>  <note>    The data included in this document is from www.openstreetmap.org. It has there been collected     by a large group of contributors. For individual attribution of each item please refer to     http://www.openstreetmap.org/api/0.6/[node|way|relation]/#id/history   </note>  <meta osm_base=""/></osm-derived>

6)area-creation
如果没有rules文件夹,从https://github.com/drolbr/Overpass-API下载

cp -pR "../rules" $DB_DIRnohup $EXEC_DIR/bin/dispatcher --areas --db-dir=$DB_DIR &chmod 666 "../db/osm3s_v0.7.*_areas"nohup $EXEC_DIR/bin/rules_loop.sh $DB_DIR &ps -ef | grep rulesrenice -n 19 -p PIDionice -c 2 -n 7 -p PID

PID指 belonging to the processes rules_loop.sh and ./osm3s_query –progress –rules

overpass-turbo安装

1)下载,需下载在var/www/html目录下(可能不一样)

git clone --recursive https://github.com/tyrasd/overpass-turbo.git

2)安装npm
sudo apt-get install nodejs
sudo apt-get install npm
3)安装overpass-turbo

npm installnpm start npm run build for a minified build in ./build

3)验证
打开localhost:8080显示overpass-turbo则安装无误

问题

1)overpass-api常见问题如官网所述:
http://wiki.openstreetmap.org/wiki/Overpass_API/Installation
2)安装overpass-turbo遇到问题
问题

npm ERR! registry error parsing json

解决

npm config set registry http://registry.cnpmjs.org或者还需要export PATH=$PATH:directory-to-add

问题

Error: shasum check failed for /tmp/npm-1316662414557/1316662415993-

解决

Just add sudo before npm install to resolve the issue.
原创粉丝点击