postGIS(Windows版)をインストールして町内を表示して、ダイクストラで最短距離計算をして、QGISで表示する
"Create spatial database"を選ぶ
D:\PostgreSQL\pg96\ をインストール先にする
postgresのパスワードを入力する
Spatial Database Informationの名前はデフォルトで
この辺は適当に"はい"で
この警告が出てインストールに失敗する
ここで、C:\Users\ebata\AppData\Local\Temp\postgis_installer\create_spatial_db_error.txt を実際に見てみると、こんな感じ
"DROP DATABASE postgis_24_sample"でデータベースを強制的に消す
再度インストール
面倒なので、D:\PostgreSQL\pg96\share\extensionの内容を、 "D:/PostgreSQL/pg96/../pg96/share/postgresql/extension/にまるごとコピーしてみる
次に、D:\PostgreSQL\pg96\libのファイルを、D:\PostgreSQL\pg96\lib\postgresql にコピー
適当なファイル名をつけて、omsファイルを保存する。
SELECT * FROM pgr_version();
"mapconfig_for_cars.xml"は出力ファイルではないので注意のこと(これで嵌った)
(ポート番号、パスワード付きの場合)osm2pgrouting -f "D:\postGIS\kashiwanoha.osm" -c "D:\PostgreSQL\10\bin\mapconfig_for_cars.xml" -W passXXXXword -p 5433 -d kashiwanoha_routing -U postgres -h localhost
■
SELECT seq, node, edge, cost FROM pgr_dijkstra('SELECT gid as id, source, target,length as cost FROM ways',100, 600, false);
■
■
SELECT seq, node, edge, cost FROM pgr_dijkstra('SELECT gid as id, source_osm AS source, target_osm AS target,length as cost FROM ways', 1590338369, 1806691363, false);
■
SELECT seq, edge, rpad(b.the_geom::text,60,' ') AS "the_geom (truncated)" FROM pgr_dijkstra('SELECT gid as id, source, target, length as cost FROM ways', 100, 600, false ) a INNER JOIN ways b ON (a.edge = b.gid) ORDER BY seq;
SELECT seq, node, edge, cost FROM pgr_dijkstra('SELECT gid as id, source, target, cost_s As cost, reverse_cost_s AS reverse_cost FROM ways', 100, 600, true );
■
同心円
select id, ST_Buffer(ST_GeomFromText('POINT(139.4746429 35.5988350)'), id*0.0001456) geom from unnest(ARRAY[1,2,3,4]) id;
ルート表示
SELECT seq, edge, rpad(b.the_geom::text,60,' ') AS "the_geom (truncated)" FROM pgr_dijkstra('SELECT gid as id, source, target, length as cost FROM ways', 100, 600, false ) a INNER JOIN ways b ON (a.edge = b.gid) ORDER BY seq;
やっと動きました
犯人は、「rpad(b.the_geom::text,60,' ') 」でした
SELECT seq, edge, b.the_geom AS "the_geom" FROM pgr_dijkstra('SELECT gid as id, source, target, length as cost FROM ways', 100, 600, false ) a INNER JOIN ways b ON (a.edge = b.gid) ORDER BY seq;
ELECT ST_AsText(ST_Centroid('MULTIPOINT ( -1 0, -1 2, -1 3, -1 4, -1 7, 0 1, 0 3, 1 1, 2 0, 6 0, 7 8, 9 8, 10 6 )'));
INSERT INTO geo (geo_id , name, geo) values (1, 'はてな京都本社', geomFromText('POINT(135.761919 35.011141)'));
INSERT INTO geo (geo_id , name , geo) values (2, '地下鉄烏丸御池', geomFromText('POINT(135.759666 35.010745)'));
INSERT INTO geo (geo_id , name , geo) values (3, '東洞院通り上る', geomFromText('LINESTRING(135.761050 35.012165,135.761050 35.011040)'));
INSERT INTO geo (geo_id , name , geo) values (4, 'ハートンホテル', polygonFromText('POLYGON((135.760497 35.012033,135.760497 35.011655, 135.760970 35.011655, 135.760970 35.012033,135.760497 35.012033))'));