2021/10,江端さんの技術メモ

「最短経路アルゴリズムを使って、近道を⾒つける」というのは、カーナビだけでなく、地理情報システム(GIS︓Geographic Information System)の定番ですが ―― 恐しく⾯倒くさいです。

そもそも、地図情報の座標⼊⼒なんぞ真⾯⽬にやっていたら、⼈⽣が終了してしまいます。といって、地図サービスプロバイダを使えば、権利や⽉額費⽤の他、使⽤できる範囲などの契約などでウンザリです。

仮に、それらをパスしたとしても、その膨⼤な地図情報のデータを使って、⾃⼒で、ダイクストラ法やら、ワーシャルフロイド法なんぞのアルゴリズムを実装していたら、⼈⽣が200年くらいあったとしても、⾜りないでしょう。

はっきり⾔いましょう。

―― 地理情報システム(GIS︓Geographic Information System)の⼿作りは⾯倒くさい

逆に⾔えば、簡単に⼿作りできれば、GISの研究やアプリ開発でラクができます。

本書は、「最短距離計算を⾏うダイクストラ法の使い⽅」をユースケースとして、『⼿作りGISの作り⽅と使い⽅』 を⼀通り説明するものです。

2021/10,江端さんの技術メモ

赤の線の方は

SELECT seq, edge, b.the_geom AS "the_geom" FROM pgr_dijkstra('SELECT gid as id, source, target, cost, reverse_cost FROM ways', 5, 11) a INNER JOIN ways b ON (a.edge = b.gid) ORDER BY seq;

の結果。

紫の線の方は、

SELECT seq, edge, b.the_geom AS "the_geom" FROM pgr_dijkstra('SELECT gid as id, source, target, cost FROM ways', 5, 11) a INNER JOIN ways b ON (a.edge = b.gid) ORDER BY seq;

の結果となった(revese_costが入っていないだけ)。

わからんなぁ。

これ「有向グラフ」と「無向グラフ」の差、らしいんだけど、紫の線の最短経路、というのはあり得ないと思います。ちょっと勉強します。

 

 

2021/10,江端さんの技術メモ

皆さん

Everyone.

朝の挨拶(のメール)が普通にできる交友関係は、ちゃんとキープしましょう。

Make sure to keep friendships where you can greet each other in the morning.

そうでないと、メールが届いていない原因が、

Otherwise, the cause of the missing emails could be

(1)(メール)システムの障害が原因なのか、

(1) Is the failure of the (e-mail) system the cause?

(2)自分の交友関係が原因なのか、

(2) Is it because of my friendships?

切り分けができません。

you can't isolate the cause of the problem.

『コールセンタまでもが、私(江端)の電話の着信拒否をしているのではないか』と、被害妄想が拡大すること ―― 受け合います。

The paranoia of "Isn't even the call center blocking my (Ebata's) calls? is growing.

2021/10,江端さんの技術メモ

ゴルゴ13を連載されてきた、「さいとうたかを」さんがお亡くなりになりました。

Mr. Takao Saito, the author of "Golgo 13", has passed away.

心からお悔やみ申し上げます。

My deepest condolences to him and his family.

ところで、ゴルゴ13は、米国で受けがよくなかった、という話を聞いたことがあります。

By the way, I have heard that Golgo 13 was not well received in the U.S.

その理由が『正義のヒーローではない』という理由だったと思います。

I think the reason was that he was 'not a hero of justice'.

『米国国民とは、なんという、能天気・・・もとい、正義感の強い国民なんだろう』

"What a good-natured...and righteous...people the American people are.

ということでした。

I thought it.

というか、

Or rather...

―― その正義とは、誰の正義だ?

"Whose justice is that?"

と尋ねくなったのを覚えています。

I wanted to ask it them.

-----

ゴルゴ13は、私に

Golgo 13 gave me

「正義とは相対的な概念であり、『絶対的正義』など存在しない」

"Justice is a relative concept, there is no such thing as 'absolute justice'"

ということを、ティーンの頃から教えてくれた哲学書だと思います。

I think this is a philosophy book that has taught me since I was a teenager that

で、私の場合、もう一回りして、

So, in my case, one more turn,

『他人の正義なんぞ知ったことではない。自分の(都合の良い)正義だけを考えて生きて良い』

"I don't care about other people's justice. I can live my life thinking only of my own (convenient) justice."

という様な、コスモポリタリズムとは真逆の世界観を自分の中に完成させて、今に至っております。

This is the opposite of cosmopolitanism, and it is my world view that I have perfected to this day.

-----

ゴルゴ13は、これからも連載は続いていくそうです。

I heard that Golgo 13 will continue to be serialized in the future.

つまり、ゴルゴ13の精神 ―― 普遍的正義の絶対的な否定 ―― を受け継ぐ後継者(の創作者)がいる、ということです。

In other words, there is a successor (creator) who inherits the spirit of Golgo 13 -- the absolute denial of universal justice.

ゴルゴ13には、これまで通り『孤高のテロリスト』として、いつまでも生き続けて欲しいです。

I hope that Golgo 13 will continue to live forever as a "lone terrorist" as he has always been.

-----

もし、『ゴルゴ13が、ある組織(国連軍とか日本国の自衛隊)などに属して、組織に忠誠を誓う』

"If Golgo 13 belongs to an organization (such as the United Nations or Japan's Self-Defense Forces) and pledges allegiance to that organization..."

てな、キャラクターに転向したりしたら、

I mean, if he turns into a character like that...

『私が、その出版社に、自爆テロを仕掛けるぞ』というくらいの覚悟があります(本当)。

I'm prepared to say, "I'm going to launch a suicide bombing attack on that publishing company.

2021/10,江端さんの技術メモ

gmailの送信ボタンが押せなくなって、メールが送信できなくなりました。

下書き保存をしておいて、iPadやIEを使った方では送信できたようなので、先ずは「chromoが怪しい」と当たりをつけて、「キャッシュをクリア」などもやってみたが、ダメでした。

私の場合、chromoをユーザをログアウトして、ログインしなおしたら動きました。

以上

2021/10,未分類,江端さんの技術メモ

$ psql -U postgres -p 15432
Password for user postgres:
psql (13.4, server 12.5 (Debian 12.5-1.pgdg100+1))
Type "help" for help.

  • データベースのリストを表示

postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+------------+------------+-----------------------
hiro_db | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)

  • データベース"hiro_db"とのコネクション確立

postgres=# \c hiro_db
psql (13.4, server 12.5 (Debian 12.5-1.pgdg100+1))
You are now connected to database "hiro_db" as user "postgres".

  • テーブルの一覧表示

hiro_db=# \dt
List of relations
Schema | Name | Type | Owner
--------+-------------------+-------+----------
public | configuration | table | postgres
public | pointsofinterest | table | postgres
public | spatial_ref_sys | table | postgres
public | ways | table | postgres
public | ways_vertices_pgr | table | postgres
(5 rows)

  • テーブルの属性の調査(テーブルに含まれるカラムの一覧を取得する)

hiro_db=# \d ways_vertices_pgr
Table "public.ways_vertices_pgr"
Column | Type | Collation | Nullable | Default
----------+----------------------+-----------+----------+-----------------------------------------------
id | bigint | | not null | nextval('ways_vertices_pgr_id_seq'::regclass)
osm_id | bigint | | |
eout | integer | | |
lon | numeric(11,8) | | |
lat | numeric(11,8) | | |
cnt | integer | | |
chk | integer | | |
ein | integer | | |
the_geom | geometry(Point,4326) | | |
Indexes:
"ways_vertices_pgr_pkey" PRIMARY KEY, btree (id)
"ways_vertices_pgr_osm_id_key" UNIQUE CONSTRAINT, btree (osm_id)
"ways_vertices_pgr_the_geom_idx" gist (the_geom)
Referenced by:
TABLE "ways" CONSTRAINT "ways_source_fkey" FOREIGN KEY (source) REFERENCES ways_vertices_pgr(id)
TABLE "ways" CONSTRAINT "ways_source_osm_fkey" FOREIGN KEY (source_osm) REFERENCES ways_vertices_pgr(osm_id)
TABLE "ways" CONSTRAINT "ways_target_fkey" FOREIGN KEY (target) REFERENCES ways_vertices_pgr(id)
TABLE "ways" CONSTRAINT "ways_target_osm_fkey" FOREIGN KEY (target_osm) REFERENCES ways_vertices_pgr(osm_id)

 

hiro_db=# CREATE TABLE "point_table" (
hiro_db(# id integer,
hiro_db(# longitude float,
hiro_db(# latitude float
hiro_db(# );
CREATE TABLE

 

hiro_db=# \copy point_table from 'c:\\Users\\ebata\\hirohakama\\100.csv' with csv
COPY 100

hiro_db=# select addGeometryColumn('point_table','the_geom',4326,'POINT',2);
addgeometrycolumn
----------------------------------------------------------
public.point_table.the_geom SRID:4326 TYPE:POINT DIMS:2
(1 row)

hiro_db=# \d point_table
Table "public.point_table"
Column | Type | Collation | Nullable | Default
-----------+----------------------+-----------+----------+---------
id | integer | | |
longitude | double precision | | |
latitude | double precision | | |
the_geom | geometry(Point,4326) | | |\

 

hiro_db=# UPDATE point_table SET the_geom = ST_GeomFromText('POINT(' || longitude || ' ' || latitude || ')',4326);
UPDATE 100

hiro_db=# select * from point_table;
id | longitude | latitude | the_geom
----+------------+-----------+----------------------------------------------------
0 | 139.460025 | 35.595017 | 0101000020E6100000F54A5986B86E614032C85D8429CC4140
1 | 139.463866 | 35.59894 | 0101000020E61000003E7782FDD76E61401422E010AACC4140
2 | 139.4717 | 35.593678 | 0101000020E6100000BE30992A186F6140662D05A4FDCB4140
3 | 139.467006 | 35.600335 | 0101000020E6100000252191B6F16E614074D2FBC6D7CC4140
4 | 139.476457 | 35.597946 | 0101000020E6100000691EC0223F6F61401363997E89CC4140
5 | 139.463482 | 35.599743 | 0101000020E61000001C0934D8D46E6140A180ED60C4CC4140
6 | 139.47421 | 35.594217 | 0101000020E6100000F52D73BA2C6F614016DD7A4D0FCC4140
7 | 139.46608 | 35.58624 | 0101000020E61000003BAA9A20EA6E6140B3CD8DE909CB4140
8 | 139.461828 | 35.591831 | 0101000020E6100000118C834BC76E614026E1421EC1CB4140
9 | 139.462946 | 35.588654 | 0101000020E61000000C3A2174D06E61406D54A70359CB4140
10 | 139.479771 | 35.593131 | 0101000020E61000003752B6485A6F6140349F73B7EBCB4140
11 | 139.462382 | 35.586075 | 0101000020E61000004A0856D5CB6E614069006F8104CB4140
12 | 139.460178 | 35.592046 | 0101000020E6100000D78A36C7B96E614023DDCF29C8CB4140
13 | 139.470633 | 35.595139 | 0101000020E610000063EDEF6C0F6F61407EC9C6832DCC4140

 

 

2021/09,江端さんの技術メモ

gcc + gdb on CUIで半生を過してきた(時々、Visual studioあり)私にとって、Visual Studio Code ですら十分に面倒くさいです。

が、そうも言ってられないので、腰をすえて環境作りをしています。
今回は、Visual Studio CodeでC/C++プログラミング を参考にさせて頂きました。

とにかく、

  • c_cpp_properties.json (IntelliSense設定)
  • tasks.json (Build設定)
  • launch.json (Debugger設定)

の3つを作らなければならないらしいです。

とりあえず、私固有の情報としては、

$ which gdb
/mingw64/bin/gdb

$ which gcc
/mingw64/bin/gcc

くらいですね。

あと関係あるかどうか不明ですが、[拡張機能]→"Code Runner"→歯車 →"拡張機能の設定"

から、Code-runner: Run in Terminal のチェックを入れて

適当な"setting.jsonで編集"をクリックして、

"code-runner.executorMap": {

"c": "cd $dir && gcc -g -fexec-charset=CP932 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",

を付け加えろ、と記載されたので、その通りにしました。

とりあえずデバッガは動いているようです。

以上

 

2021/09,江端さんの技術メモ

dockerをバージョンアップしたら、"docker-compose up -d" で、こんなエラーがでるようになった。
After upgrading docker, I got this error when I tried "docker-compose up -d".

 Error response from daemon: invalid mount config for type "volume": invalid mount path: 'db_data' mount path must be absolute

で、よく分からんのだけど
And I'm not sure.

volumes:
# - db_data   ← これをコメントアウトしたら動くようになった (I commented this out and it works now).
- ./control:/go/src/work # マウントディレクトリ指定
expose:
- 5432 # 兄弟コンテナから5432でアクセスできるようにする
ports:
- "8910-8911:5432"
tty: true # コンテナの起動永続化
db_data:
image: busybox
volumes:
- /data/db

もう、よく分からんけど動けばいいので。
I'm not sure anymore, but I just need to execute it.

2021/09,江端さんの技術メモ

『Word, Latexなどを使わないでMarkdownだけで本を作りたい』で、がんばっています。

Visual Studio Code(VSC)は、Golangでは上手く動かなくてイライラしてたのですが、Markdown用のエディタとしては優秀です。

今日、VSCから、いきなりPDFを作ったり、目次を追加したりできることが分かりましたので、メモを残しておきます。

  • PDFの作成

拡張機能(Ctrl+Shift+x)から、

をインストールして、Markdownの編集画面の上で右クリック

これで、PDFファイルが作成される

  • 目次の作成

拡張機能(Ctrl+Shift+x)から、

をインストールして、Markdownの編集画面の上で右クリック

これで、目次が作成される

  • 目次に見出し番号をつける
  1. ctrl + , で設定を開いて「markdown-toc」で検索
  2. 「Detect And Auto Set Section」と「Ordered List」にチェック

  • Headerを消してページ番号だけ残す