2022/05,江端さんの忘備録

今となってなっては、当然のように存在している、OSS(オープンソースソフトウェア)ですが、その起源は、fetchmail、emacs、そして、Linuxに遡れると思います。

OSS (Open Source Software) is now a commonplace, but its origins can be traced back to fetchmail, emacs, and Linux.

OSSが、「単なる善意のソースコードの開示ではなく、優れたソフトウェア開発モデルである」ということを提示した、最初の論(というか、コラム)が、エリック・デイモンドさんが開示した、「伽藍とバザール」だったと思います。

I think the first argument (or rather, column) that presented OSS as "not just a bona fide source code disclosure, but a good software development model" was Eric Daymond's disclosure, "The Cathedral and the Bazaar".

今日、これを読み直してみたのですが、ここには、OSSのビジネスモデルに関する言及はなかったようです。

I re-read this today and did not find any reference to the OSS business model here.

が、今や、これらについては、すでに様々なビジネスモデルが実現されており、十分な実績があります。

However, various business models have now been realized and are already well established.

-----

まあ、OSSが、当初、どれだけ酷い取り扱いをされてきたかについては、こちらの記事の、

Well, to see how badly OSS was treated in the beginning, please refer to this article.

'今となっては、ITに詳しくない人ですら知っている用語、OSS(オープンソースソフトウェア) ―― この概念が世間に公表された時、世界中のITエンジニア(私も含めて)から「アホじゃないか」と、あきれたものです'

'Nowadays, even people who are not familiar with IT know the term, OSS (Open Source Software) -- when this concept was announced to the world, IT engineers around the world (myself included) gasped and said, "Isn't that stupid?'

'プログラムのソースコードは、ソフトウェア技術の集大成です。そのソースコードを誰でも見られるようにオープンにしたら、自分の仕事をわざわざ他人にくれてやっているようなものです'

'The source code of a program is the culmination of software technology. If you make that source code open for anyone to see, it is like giving your work all the way to someone else.

あるいは、

Others include,

'その当時、Linuxのカーネルコンパイルなんかやっていたら、「江端ぁ! オモチャのOSで、遊んでんじゃねーぞ!!」と叱られたものです(本当)'

At that time, when I was compiling the Linux kernel, my boss said to me, "Ebata! Don't play with a toy OS! I was scolded by him.

などを、読んで頂ければ、分かるかと思います。

-----

で、最近、私は思うのですが

And lately, I think...

―― ソースコードが開示されたところで、所詮、他人の書いたコードは、自分には読めない

"Even if the source code is disclosed, I can't read the code written by others after all"

という、『オープンソース ≒ クローズドソース論』を、主張したいと思います。

I would like to argue that a theory of "Open Source is nearly equal to Closed Source".

I know well, that,

―― オープンソースコードの理解にかかるコストは、オープンソースコードをスクラッチから作り直す程度のコストに匹敵する

"The cost of understanding open source code is comparable to the cost of rebuilding open source code from scratch"

のです。

今回、これを逆の方向から理解できたのが、今朝の深夜でした。

It was late this morning that I was able to understand this from the opposite direction this time, by the fact of

『他人の100行のコードは理解できないのに、5年前に書いた自分の1000行のコードを、一瞬で思い出すことができた』

'I couldn't understand a hundred lines of someone else's code, but I could instantly recall a thousand lines of my own code that I wrote five years ago.'

からです。

つまり、『オープンソースコードは、その開発者とセットになった時、その価値を最大限に発揮する』ということです。

In other words, 'open source code maximizes its value when it is paired with its developers.

実際のところ、他人のオープンソースを使っていてバグが生じていたとしても、それをデバックする気持ちなど全く発生しません。

As a matter of fact, if I am using someone else's open source and a bug arises, I have no desire to debug that code at all.

このような場合、私の対応は、(1)運用で対処する、(2)そのコードの利用を断念する、(3)そのバグが、学会のワークショップで出てこないことを祈る、の3つ程度です。

In such cases, my response is about three things: (1) deal with the problem in operation, (2) abandon the use of the code, or (3) hope the bug does not come up in a workshop at a conference.

-----

もちろん、この経験は、これまで検討されてきたOSSの開発モデルやビジネスモデルを、1mmも否定するものではありません。

Of course, this my experience does not negate a single millimeter of the OSS development and business models that have been discussed.

しかし、私にとって、私のOSSとは、

But for me, my OSS is about

『過去の私と現在の私の間で行われる、共同開発』

"Collaborative development between me in the past and me in the present"

という意義が、一番大きいです。

is the most significant.

------

シュタインズゲートゼロ第18話の、レスケネン教授の

Professor Leskenen's line from Steins;Gate Zero episode 18,

「これは、私と、私による合作なんだよ ―― 時を越えた」

"This is a timeless collaboration between me and me"

は、OSS開発の意義として、加えられるべきであると思います。

should be added to the significance of OSS development.

2022/05,江端さんの忘備録

ロシアは、現在、国際連合から非難決議を受けております。

Russia is currently under a condemnation resolution from the United Nations.

かつて日本は、国際連盟から自ら脱退しました(1933)。

In the past, Japan withdrew itself from the League of Nations (1933).

ロシアは、経済制裁を受けておりますが、世界のエネルギー資源の産出国であり、中国は(事実上の)同盟国です。

Russia is under economic sanctions, but it is the world's energy resource producer and China is a (de facto) ally.

かつての日本も、世界中から経済制裁を受けました(1941年から100%の経済制裁)。

In the past, Japan was also subjected to economic sanctions from all over the world (100% economic sanctions since 1941).

おまけに、我が国のエネルギーの産出量は10%程度で、同盟国はヨーロッパの二ヵ国(ドイツとイタリア)だけで、どちらも、エネルギー供給国ではなく、エネルギーを融通できる輸送ルートもありませんでした(*)。

In addition, our country's energy production was only about 10%, and our only allies were two European countries (Germany and Italy), neither of which was an energy supplier or had transportation routes that could accommodate energy (*).

(*)今回調べてみて驚いたのですが、当時の日本は、結構、原油の生産があったようです。

(*)To my surprise when I looked into this issue, it seems that Japan was producing quite a bit of crude oil at that time.

―― それでも、当時の我が国の国民は、4年間の戦争を耐え凌いだ

-- Yet, the people of our country at that time endured four years of war

もし東京大空襲がなれば、もし原爆投下がなければ、もしソ連の平和条約の一方的破棄がなければ ―― たぶん、もっと長い期間耐えていただろう、と思います。

If it had not been for the air raid on Tokyo, if it had not been for the atomic bombings, if it had not been for the Soviet Union's unilateral abrogation of the peace treaty -- maybe they would have endured for a longer period of time, I think.

ちなみに、国民の戦争に関する厭世気分が発生したのは、空襲が頻発化し始めた戦争の最後の半年程度で、それまで、政府の支持率は、比較的良好でした。

Incidentally, public disillusionment with the war occurred only in the last six months of the war, when air raids began to become more frequent, and until then, government approval ratings had been relatively favorable.

戦争中の政府の支持率は「高い」 ―― これ、結構、常識です(例えば、自殺率が恐しく改善します)。

Support for government during war is "high" -- this is pretty much common knowledge (e.g., suicide rates improve horribly).

日本は戦争に負けましが、ベトナムなんて20年間戦い続けて、最後には米国に勝ちましたし、キューバなんて1960年から経済制裁を受けていて、今なお耐えています。

Japan lost the war, but Vietnam was fought for 20 years and finally won against the U.S. Cuba has been under economic sanctions since 1960 and is still enduring them.

-----

「ロシアによるウクライナ侵攻」について、マスメディアの見解を一方的に受信するだけではなく、自力で調べて、自分で考えた方が良いと思います。

I think you should do your own research and think for yourself about the "Russian invasion of Ukraine" instead of just receiving one-sided views from the mass media.

今回、私は「過去の我が国の太平洋戦争との比較」という観点で考えてみましたが、他にも色々なアプローチがあると思います。

I have looked into this issue from the perspective of "comparisons with our country's past wars in the Pacific," but I am sure there are many other approaches.

2022/05,江端さんの忘備録

BS世界のドキュメンタリー 「女王陛下の戴冠式」を見ていました。

I was watching the BS World Documentary "The Coronation of Her Majesty the Queen".

エリザベス2世と、当時の関係者のコメント付きの、戴冠式のイベントに至るまでの16ヶ月間の準備の記録ドキュメンタリーです。

This documentary chronicles the 16 months of preparation leading up to the coronation event, with comments from Queen Elizabeth II and others involved at the time.

私、こういう、イベントの裏側の話が大好きで、楽しく見ていました。

I love these behind-the-scenes stories of events and enjoyed watching them.

-----

長女が、「これって、女王にいくらギャラ払われるのかな」と言っていました。

My senior daughter said, "I wonder how much the queen will be paid for this".

「多分、女王陛下は、ギャラ受けとっていないと思うぞ」と、私は答えました。

I replied, "I don't think Her Majesty the Queen is getting paid."

長女:「なんで、英国では、こういう番組を作れるんだろう」

Senior Daughter: "Why, in the UK, can they make these programs?"

江端:「多分、まあ、良い意味でも、悪い意味でも、英国皇室は、国民に対して『開かれている』のは確かだろう」

Ebata: "Perhaps, well, in a good way or a bad way, the British imperial family is certainly 'open' to the public."

離婚後とは言え、『元皇太子妃殿下を、パパラッチが追い回して交通事故死を至らしめる』なんてことは、日本の皇室では、ちょっと想像できません。

Even after the divorce, it is hard to imagine the paparazzi chasing the former Crown Princess to death in a car accident in the Japanese Imperial Family.

-----

江端:「個人的には、10年後でもいいけど、私は、天皇陛下即位の儀の記録ドキュメンタリー見たいな」

Ebata: "Personally, I'd like to watch a documentary recording the Emperor's accession to the throne, even if it's 10 years later."

というと、嫁さんは、

On the other hand, the wife said.

『私は、見たくないな』

"I don't want to watch that."

と言っていました。

まあ、皇室の『開閉度』は、皇室や宮内庁の判断だけでなく、私たち国民の意識も、大きなパラメタなんだろうな、と、思いました。

Well, I thought that the "degree of opening and closing" of the Imperial Family is not only the judgment of the Imperial Family and the Imperial Household Agency, but also our public awareness might be a major parameter.

2022/05,江端さんの忘備録

連休中ですが、普段より働いている気がします ―― 疲労を感じます。

I'm on holiday, but I feel like I'm working more than usual -- I feel tired.

「『手を抜くため』の努力は惜しまない」という方針で、以下のようなことで、ずっと悩んでいます。

Based on my policy of "making every effort to 'cut corners'" , I am struggling with following issues.

お願い:PostGISで、曲線のジオメトリをそのまま使って、始点と距離を与えて、終点の座標を得たいです

そういえば、今回、自分で作った本が、自分を助けてくれて、本当に助かっています。

Come to think of it, the book I made myself before really helped me out.

『ありがとう!過去の私!!』と、時空を越えて、自分に感謝しております。

'Thank you, past me!' And I thank myself for crossing time and space.

------

私、最近、teratail(https://teratail.com/)という技術系の質問掲示板を使わせて頂いておりまして ―― 質問ばかりしています。

I have recently been using a technical question board called teratail (https://teratail.com/) -- I ask a lot of questions.

あまりにも申し訳ないので、私でも、答えられることには回答したいと思っています。

I am too sorry to do this, but even I would like to answer what I can.

それが『トレードオフ』・・・ではなくて、えーっと、『共助共存』というやつですよね、うん、そう。

That's the 'trade-off'...No, I don't mean that. Let's see, it's called 'mutual aid coexistence', yes, yes.

しかし、私が答えられそうなことは、「回答済み」か「解決済み」になっており、私に口を出せる余地がありません。

However, anything I might be able to answer is either "answered" or "resolved", leaving no room for me to speak.

-----

『いつか、あなたを助けるから、今はちょっと勘弁ね』と呟きながら ――

With muttering, 'Someday, I'll help you, just not right now,'

今日も、パソコンの前で、宇都宮市のGISデータベース構築と利用方法に、頭を抱えています。

Today, I am sitting in front of my computer with giving my headache, and trying the construction and use of the GIS database for Utsunomiya City.

2022/04,江端さんの技術メモ

OpenStreetMapのデータからosmiumを使って鉄道だけを抽出しPostGISに入力する方法(宇都宮周辺の鉄道データを使った例)

を、参考にさせて頂いて、試しているのですが、うちのosmiumは、

root@c517fca5dec0:/usr/bin# osmium export -f pg -o utsunomiya-railway-latest.pg utsunomiya-railway-latest.osm.pbf
Set output format with --output-format or -f to 'geojson', 'geojsonseq', or 'text'.

といって、pgファイルを作ってくれません。色々調べたのですが、どうにも上手くいかずに、別の方法を探しています。

で、ちょっと興味本位で、

root@c517fca5dec0:/usr/bin# apt install osm2pgsql

をやってみたら、コンテナの中に、サクッとインストールされたので、これを使う方向で検討しています。

------

>docker container exec -it utsunomiya_db_1 bash

で入ったのですが、osm2pgsqlとかosmiumはインストールできなかったのですが、apt update, apt install, apt upgrade, などを叩き込んで、

>apt install osm2pgsql

>apt install osmium-tool  (×osmium)

>apt install postgresql

を強行しました。

こうしたら、上記のエラー(Set output format with --output-format or -f to 'geojson', 'geojsonseq', or 'text'.)が見えなくなりましたので、osm2pgsqlの方向は見合わせることにしました

よし、続行だ。

この後、アップデートすると動かなくなるので、アップデートを中途半端に行って(完璧にしない)で、pgファイルを作って、インストールに成功。

その後、上記参照ページのSさんから教えて頂いた

utsu_rail_db=# select geom, tags->>'railway' as railway, tags->>'name' as name from utunomiya where tags->>'name' like '%宇都宮ライトレール';

を実施しました。

| construction | (仮称)宇都宮ライトレール
0102000020E6100000070000000725CCB43D7D61408EA2186A5E474240E9CD4D40387D61406409C61C5F474240C6490625317D61407055230560474240197DBBDB2B7D6140A5AA645B61474240BB1171CE237D614050BA3EBD63474240970E8C721F7D6140A95B2CFB644742
4055FBCFF5187D6140B3171B0467474240

| construction | (仮称)宇都宮ライトレール
0102000020E610000008000000BE5B0F15197D61400686072868474240B3075A81217D6140BA50549165474240419B1C3E297D6140B53D30366347424063AD461B2C7D6140685E697462474240CC7C073F317D6140638DC4156147424009E29755337D6140ECB886BE604742
405A2A6F47387D6140E7CD3C146047424069520ABA3D7D6140B130444E5F474240

| construction | (仮称)宇都宮ライトレール
(74 rows)

と、出てきました。

ーーーようやく、宇都宮GISデータベース目処が付きました。

2022/04,江端さんの技術メモ

「OpenStreetMapのデータから鉄道だけを抽出してGeoJSONで出力する方法」を試してみた件

を前提として、osmから道路と鉄道路線のみを残して残りは消去する方法を探してみました。

どうやら、これでできるようです。

まず、宇都宮地区を抽出します。

osmium extract --bbox 139.76675736787732,36.47004171587971,140.1596765021647,36.659949299138 -o utunomiya.osm.pbf kanto-latest.osm.pbf

次に、以下を行います。

root@2e317961f1d0:/tmp# osmium tags-filter utunomiya.osm.pbf nw/railway nw/highway=motorway,service,primary,secondary,tertiary,unclassified,residential -o utunomiya-lrt-latest.osm.pbf

上記のコマンドのnw(r)は、以下のような意味になっています。

nwr は、OpenStreetMapの nodewayrelationsを指定しています。

nw/(キー)=(タグ),(タグ),(タグ),(タグ),(タグ).....

という記述をします。

(キー)は、https://taginfo.openstreetmap.org/keys を参照

(タグ)は、https://taginfo.openstreetmap.org/tags を参照するといいでしょう。

https://wiki.openstreetmap.org/wiki/JA:Tag:highway%3Dresidential の、

上記をクリックすると、motorway,service,primary,secondary,tertiary,unclassified,residential 

の意味が分かります(多分)。

未分類

どなたか、ご教示頂きたく、お願い致します。

前提

Windows10でDockerを使って、PostgreSQL + PostGISの環境を使っています。

実現したいこと

PostGISで、曲線のジオメトリをそのまま使って、始点と距離を与えて、終点の座標を得たいです。
具体的には、イメージ説明に示すように、

(1)図中のジオメトリで与えられる地図上の曲線において、
(2)始点(A点)の座標(緯度経度)と距離を入力して、
(3)終点(B点)の座標(緯度経度)を取得する

を実現したいです。

検討した事項

geometry型がさっぱり分からん

にも記載しておりますが、曲線のジオメトリは、 ST_Astext()を使うことで、座標に展開できるので、これを使って地道に計算(足し算して端数は比率を乗算する)すれば、算出は可能だと思うのですが、非常に迂遠な計算で、計算負荷も大きくなると思います。

そこで、ジオメトリ(the geom)を直接使って、そのようなことを実現できる関数を
https://postgis.net/docs/manual-3.2/postgis-ja.html#reference
から、探してみたのですが、見付けられませんでした(見落している可能性大です)。

補足情報

大量のエージェントを地図上で動かすシミュレーションで、使うことを想定しており、可能な限りPostGISで提供されている関数とジオメトリをそのまま使って実現したいと考えております。

連絡先

(この質問に関するご報告のみ、ご利用頂きたくお願い致します)

何卒、よろしくお願い致します。

2022/04,江端さんの技術メモ

「OpenStreetMapから鉄道路線データを落とせない」と愚痴っていたら、社内の人から「OSMに鉄道データ入っていますよ」と言われて、愕然とした件

という訳で、今日は、OpenStreetMapX.jl をダウンロードして色々やっていたのですが、よく分からりませんでした。というか、何ができるのか、が今一つ肚に落ちてこないのです。

で、こちらの路線は諦めて、とにかく鉄道データが取れる手段を探しました。

OpenStreetMapのデータから鉄道だけを抽出してGeoJSONで出力する方法

を試すことにしました。
から、osm.pbfファイルを落してきました。

osmium を使う方法がでていたのですが、これが私のWindows10環境では実現できませんでした。(正確に言うと、私の環境には"cl.exe"というコマンドがないので、コンパイルができない。Visual Studio C++(?)を入れるとできるらしいのですが、これ以上、パソコンの環境を汚したくなったのです)。
で、色々試みたのですが(この間5~6時間)、上手くいかず、dockerでないかなにないかなーと探していたら、見付けました。
1つ目のWindowsのコマンドプロンプト(MSYS64では上手く動かない)かったので、
C:\Users\ebata>docker run -t -i stefda/osmium-tool /bin/bash
で、いきなりDockerのコンテナの中に入りました。

/bin , /usr/bin, /usr/local/bin のどこかで当るだろうと探りを入れていたら、

root@e87f198ccc07:/usr/bin# ls o*
objcopy objdump od odbcinst ogdi-config openssl osage osmium
root@e87f198ccc07:/usr/bin# osmium
Usage: osmium COMMAND [ARG...]

/usr/binで当たりました。

で、作業用のディレクトリを探していたら、/tmpがあったので、ここにファイルを持ち込んで作業することにしました

2つ目の、別のWindowsのコマンドプロンプトを上げて、今動かしているコンテナを調べました

C:\Users\ebata>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e87f198ccc07 stefda/osmium-tool "/bin/bash" 12 minutes ago Up 12 minutes wonderful_lumiere

で、ローカルからDockerコンテナの/tmpに直接コピーしました。

C:\Users\ebata>docker cp kanto-latest.osm.pbf wonderful_lumiere:/tmp

一つ目のコマンドプロンプトに戻って、ファイルが可能されているか確認しました。

root@e87f198ccc07:/# cd tmp
root@e87f198ccc07:/tmp# ls
kanto-latest.osm.pbf

ちゃんと入っていました。パスも通っているようですので、

root@e87f198ccc07:/tmp# which osmium
/usr/bin/osmium

そのまま、/tmpの中で作業しました

root@e87f198ccc07:/tmp# osmium tags-filter kanto-latest.osm.pbf w/railway -o kanto-railway-latest.osm.pbf
[======================================================================] 100%
root@e87f198ccc07:/tmp# ls
kanto-latest.osm.pbf kanto-railway-latest.osm.pbf
root@e87f198ccc07:/tmp# osmium export kanto-railway-latest.osm.pbf -o kanto-railway-latest.json
root@e87f198ccc07:/tmp# ls
kanto-latest.osm.pbf kanto-railway-latest.json kanto-railway-latest.osm.pbf

2つ目のコマンドプロンプトを立ち上げて、dockerコンテナから、ローカルに、完成したjsonファイルを送り出します。

C:\Users\ebata\docker-osmium-tool>docker cp wonderful_lumiere:/tmp/kanto-railway-latest.json .

ローカルの方に変換されたファイルが戻ってきました。
C:\Users\ebata>ls
 Dockerfile   README.md   kanto-latest.osm.pbf   kanto-railway-latest.json   work
さて、これを、ドラッグして、QGISに放り込んで出てきた図です。

見事に鉄道だけが抽出されています。

しかし、重要なのはそこではありません。

芳賀・宇都宮LRT が、すでに表示されている ―― これは、今の私にとって、とてつもないインパクトなのです。

さて、今回はLRTを中心とした宇都宮市をカバーする地域の交通機関を切り出します。

【食べログ作れる? 】 OpenStreetMap から Osmiumで飲食店の位置情報を取得してGeoJSONに出力してみたを参照して、

$ osmium extract --bbox 左上の経度,左上の緯度,右下の経度, 右下の緯度 -o 出力したいファイル名.pbf 元のファイル名.osm.pbf

から、

$ osmium extract --bbox 139.76675736787732, 36.659949299138, 140.1596765021647, 36.47004171587971 -o utunomiya-lrt.osm.pbf kanto-latest.osm.pbf

として切り出してみます。

root@80e1a2d0dc02:/tmp# osmium extract --bbox 139.76675736787732, 36.659949299138, 140.1596765021647, 36.47004171587971 -o utunomiya-lrt.osm.pbf kanto-latest.osm.pbf
Error parsing command line: too many positional options have been specified on the command line

あれ、コンマと空白がダメだったかな?

root@80e1a2d0dc02:/tmp# osmium extract --bbox 139.76675736787732,36.659949299138,140.1596765021647,36.47004171587971 -o
utunomiya-lrt.osm.pbf kanto-latest.osm.pbf
Need LEFT < RIGHT and BOTTOM < TOP in --box/-b option.

うむ、 では、36.659949299138 と 36.47004171587971 を入れかえて、再度挑戦

root@80e1a2d0dc02:/tmp# osmium extract --bbox 139.76675736787732,36.47004171587971,140.1596765021647,36.659949299138 -o utunomiya-lrt.osm.pbf kanto-latest.osm.pbf
[======================================================================] 100%

成功したっぽいです。

root@80e1a2d0dc02:/tmp# osmium tags-filter utunomiya-lrt.osm.pbf w/railway -o utunomiya-railway-latest.osm.pbf
[======================================================================] 100%

root@80e1a2d0dc02:/tmp# osmium export utunomiya-railway-latest.osm.pbf -o utunomiya-railway-latest.json

では、ここから、2つ目のコマンドプロンプトから、

C:\Users\ebata\docker-osmium-tool>docker cp serene_shirley:/tmp/utunomiya-railway-latest.json .
C:\Users\ebata\docker-osmium-tool>docker cp serene_shirley:/tmp/utunomiya-lrt.osm.pbf .

としました。

utunomiya-railway-latest.json の表示結果はこちらです。

データ量も、関東全域と比較すると、11%程度になりました。


ところで、osmファイルと、osm.pbfファイルの違いって何だろう?