惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Project Zero
Project Zero
Security Archives - TechRepublic
Security Archives - TechRepublic
C
Cyber Attacks, Cyber Crime and Cyber Security
Security Latest
Security Latest
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
Vulnerabilities – Threatpost
C
CERT Recently Published Vulnerability Notes
S
Schneier on Security
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
D
Darknet – Hacking Tools, Hacker News & Cyber Security
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
F
Full Disclosure
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
WordPress大学
WordPress大学
Microsoft Azure Blog
Microsoft Azure Blog
H
Help Net Security
大猫的无限游戏
大猫的无限游戏
MyScale Blog
MyScale Blog
Hacker News: Ask HN
Hacker News: Ask HN
G
Google Developers Blog
H
Heimdal Security Blog
O
OpenAI News
Hugging Face - Blog
Hugging Face - Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LangChain Blog
C
Cisco Blogs
云风的 BLOG
云风的 BLOG
IT之家
IT之家
Cyberwarzone
Cyberwarzone
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Know Your Adversary
Know Your Adversary
博客园 - 聂微东
The Cloudflare Blog
C
Check Point Blog
K
Kaspersky official blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
月光博客
月光博客
T
Tor Project blog
T
Threat Research - Cisco Blogs
T
Tailwind CSS Blog
P
Proofpoint News Feed
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
A
About on SuperTechFans
小众软件
小众软件
Cloudbric
Cloudbric
A
Arctic Wolf

herrkaefer

"Vibe planning \u003e vibe coding" "Anything to Markdown" "Built anocus: anonymous commenting for static sites" "日记与小说 -- AI 续写小说欣赏" "Any-podcast: from newsletters to a podcast" "Made MicPipe: a simple voice input tool using ChatGPT dictation" "关于 Tools 和 Skills 的一点感想" "Realtime monitoring of ComEd hourly price" "Introducing SwiftEdgeTTS" "Thoughts on the philosophy of building AI-native apps" "jelly鼻屎" "等饭的人" "Use home assistant to motivate my kid to brush teeth" "Migrated Blog to Hugo and Cloudflare Pages" "Easy Aspen monitoring for Chicago parents" "Introducing HabitBuilder: A simple Telegram bot for habit tracking" "鼓捣" "Open folder or file with Sublime Text from Finder toolbar" "Python dev workflow on macOS" "Create new text file from Finder toolbar" "Uno reinvented for 3-year-old kids" "Uno变身儿童数字游戏" "自动转发Twitter到微博" "Handle annoying operations of objects in Realm DB" "Move Jekyll blog to Ubuntu VPS" "Introducing Mole" "Note taking without note taking app" "Deploy Python web application on Ubuntu server" "Setup Shadowsocks / VPN on Ubuntu Server" "Linode Notes - Basic Setup" "CLASS Style Adapted for Embedded Systems" "psycopgr Tutorial" "PostgreSQL Notes" "阿城三王" "这一年,这一把日子" "另一面的发现——读《坟》" "定理" "封面与腰封" "Google book下载" "lulu最新写真出炉" "The Big Bang Theory第三季" "自拍婚纱照1" "日全食" "期待动画片" "《麦兜响当当》动画电影主题曲" "转:饶毅--“杂志拜物教”:何时发Cell Nature Science 论文害你" "转:饶毅--提醒年轻人:何时SCI害你?" "西安" "3d打印机" "Dropbox" "刷牙" "贴几张照片" "6156167" "永久和凤凰" "老板的想法" "春" "原来奥巴马也是个朗读者" "应邀发Freeware List 2.0" "史上最能睡的淘宝老板" "至少出名的效果是达到了" "错怪了msn" "独立游戏节2009" "114" "馒头" "Crayon Physics Deluxe" "2008,2009" "盖章记" "小虎队附身许巍" "怎么给word文档加索引:排序问题" "怎么给word文档加索引Q\u0026amp;A" "怎么给Word文档加索引" "教我如何不疯掉" "二则" "P" "哦!报告" "蓝天" "萧翰" "lm" "故宫印象" "转:美国历任总统像" "time can kill itself" "嗯" "建议,只是建议哦" "奥地利行记3" "奥地利行记2" "奥地利行记1" "叶子" "GayBoy" "天使教你扔frisbie" "门徒因何面容愁?" "手机教堂" "丝竹管弦之盛" "残奥" "争座位" "秋意浅" "总理府" "流觞曲水" "映带左右引以为" "咚咚咚 续" "茂林修竹又有"
"pgRouting Notes"
"herrkaefer" · 2016-08-30 · via herrkaefer

Install PostGIS and pgRouting

On Mac

The following will install pgRouting and its dependencies including PostGIS, and PostgreSQL if not installed:

On Linux

(to add)

Install osm2pgrouting

osm2pgrouting is for importing OSM data into PostgreSQL database, and creating routable topology.

It is said that osm2pgrouting has limitation:

> Can’t process “large” files, continents, big countries, or very large states.

For large files, we can use osm2po.

Install via homebrew (Mac)




brew install osm2pgrouting

Note that a mapconfig.xml file is at: /usr/local/Cellar/osm2pgrouting/[version]/share/osm2pgrouting/mapconfig.xml

Manually install the lastest version

(The following notes are based on version 2.1. Now with homebrew you can already install the latest version.)

  1. Download code from repo

  2. Modify CMakeLists.txt to install app to /usr/local/bin and other files to /usr/local/share

  • line 5 —> set (SHARE_DIR “/usr/local/share/osm2pgrouting”)

  • line 36 —> RUNTIME DESTINATION “/usr/local/bin”

  1. Add the following headers to src/way.h (otherwise there will be errors)



#include



#include



#include
  1. Build and install



cmake -H. -Bbuild



cd build/



make



make install

Workflow

Prepare database

Create new database if needed:

For each database that postgis and pgrouting are used, we should install corresponding extensions:




psql routing -c "create extension postgis"



psql routing -c "create extension pgrouting"

For test of installation:




psql routing -c "SELECT postgis_full_version()"



psql routing -c "SELECT pgr_version()"

Import OpenStreetMap data

OSM map data can be downloaded in many places. We are interested in the OSM XML format.

To import map data to database:




osm2pgrouting --file beijing_china.osm \



--conf /usr/local/Cellar/osm2pgrouting/[version]/share/osm2pgrouting/mapconfig.xml \



--dbname routing \



--username [username] \



--clean

If you are adding data, do not use flag --clean.

We could browse the tables with psql or pgAdmin.

Notes for tables

Two main tables:

  • ways: stores the edges

  • ways_vertices_pgr: stores the end nodes of edges

Meanings of ways columns length, length_m, cost, reverse_cost, cost_s, reverse_cost_s. According to post here:

  • length is length of the segment in degree units

  • cost and reverse_cost is the length in degree units. (include the negative values for wrong way)

  • length_m is in meters (there is no cost_m or reverse_cost_m)

  • cost_s and reverse_cost_s is in time: seconds units (using the maxspeed value that is in km/hr transforming it to meters/second and using the length_m)

Do routings in SQL

Now we can calculate routes with pgRouting. For example, to calculate one-to-one shortest path:




SELECT * FROM pgr_dijkstra(



'SELECT gid as id, source, target, cost, reverse_cost FROM ways',



100, 200,



TRUE



);

pgRouting Manuals

Do routings in Python

I bet that You don’t want to write SQLs. Good news here if you like writing Python! I wrote a psycopgr Python module to encapsulate database connection (via psycopg2) and pgRouting callings. Here is a tutorial.