未分類

------

"pq: sorry, too many clients already" は、コネクション数とかで出てくる訳ではないらしい。

(実際に、1コネクションでも、このエラーは発生した)。

sql.Query() のアクセス頻度が高くなると発生するみたいなので、コーディングでクエリを少なくする工夫が必要となる。

for i := 0; i < 1200; i++ {
		subWG.Add(1)
		go person(db, i, &subWG)
		time.Sleep(5 * time.Second) // 1秒待つ
	}

上記のプログラムでSleepを長くすると、発生しなくなることがある。

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

(まとめ)地図DBの作り方

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

ところが、問題は、

/usr/share/osm2pgrouting/mapconfig_for_bicycles.xml(自転車)

/usr/share/osm2pgrouting/mapconfig_for_cars.xml(自動車)

/usr/share/osm2pgrouting/mapconfig_for_pedestrian.xml(歩行者)

の3つしか、準備されておらず、鉄道のテンプレートがありませんでした

本当に鉄道を使ったDBはつくれないのかな? と思い、ちょっと試してみました。

こちらに、mapconfig_for_cars.xml があるので、それを見てみました。

私の場合、芳賀・宇都宮LRT と、一般の道路を交えたダイクストラを実現することが目的でしたが、まずは、(道路のことは忘れて)芳賀・宇都宮LRTの情報だけを取り出すことに注力しました。

で、こんなの(mapconfig_for_train.xml)を作ってみました。

ちなみに、"tram"とは路上電車のことで、要するにLRTのことです。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <tag_name name="railway" id="1">
    <tag_value name="tram"              id="101" priority="1.0" maxspeed="40" />
  </tag_name> 
</configuration>

id="1"> とか、 id="101" priority="1.0" maxspeed="40" /> は、適当に付けました(多分、この辺は適当で良いと思います)。

で、これで何が出てくるかを見ていたのですが、

<tag_name name="railway" id="1">
<tag_value name="tram" id="101" priority="1.0" maxspeed="40" />
</tag_name>
</configuration>

この結果、分かったことは、osmデータの中にある、<tag k="railway" v="tram"/> が含まれている、<way>のタグが取り出されることでした。

<way id="678320671" version="2" timestamp="2021-08-04T10:06:56Z" changeset="0">
		<nd ref="6351482006"/>
		<nd ref="5948014189"/>
		<nd ref="5558816378"/>
		<nd ref="5948014109"/>
		<tag k="bridge" v="yes"/>
		<tag k="railway" v="tram"/>
		<tag k="electrified" v="contact_line"/>
		<tag k="frequency" v="0"/>
		<tag k="gauge" v="1067"/>
		<tag k="maxspeed" v="40"/>
		<tag k="name" v="(仮称)宇都宮ライトレール"/>
		<tag k="railway" v="construction"/>
		<tag k="voltage" v="750"/>
	</way>

 

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

osm.pbfファイルを、osmファイルに変換する方法

で作った、utunomiya-railway-latest.osm を使って、テスト用のDB (test_db)を作っておいて、

osm2pgrouting -f utunomiya-railway-latest.osm -c mapconfig_for_train.xml -d test_db -U postgres

をやってみました(実は、芳賀・宇都宮LRTの情報は、工事中の情報が入っていて、utunomiya-railway-latest.osmには、<tag k="construction" v="tram"/>と記載されていましたので、これを、強制的に<tag k="railway" v="tram"/>に置換しました)。

test_dbをQGISで表示したら、こんな感じで出てきました。

出発点のid = 1 と、

終着点のid = 6 を使って、

ダイクストラ計算を実施してみました。

root@a2b2f7061d88:/tmp# psql -U postgres
psql (12.5 (Debian 12.5-1.pgdg100+1))
Type "help" for help.

postgres=# \c test_db
You are now connected to database "test_db" as user "postgres".
test_db=# SELECT seq, node, edge, cost, agg_cost FROM pgr_dijkstra('SELECT gid as id, source, target,length_m as cost FROM ways',1, 6, false);
 seq | node | edge |        cost        |      agg_cost
-----+------+------+--------------------+--------------------
   1 |    1 |  112 |  968.5677557470831 |                  0
   2 |  105 |    1 |  401.6831070639031 |  968.5677557470831
   3 |    2 |   40 | 1932.1157045557927 | 1370.2508628109863
   4 |   36 |   43 |  91.90138904387848 | 3302.3665673667792
   5 |   39 |   65 | 111.55679510881248 |  3394.267956410658
   6 |   63 |   67 | 159.06195161851494 | 3505.8247515194703
   7 |   65 |   10 | 45.988089536965845 |  3664.886703137985
   8 |    9 |   74 |  25.50249632394143 |  3710.874792674951
   9 |   71 |    8 |  83.08385331794597 | 3736.3772889988927
  10 |    7 |   12 | 27.274859434129702 | 3819.4611423168385
  11 |   10 |   36 |  55.83052462128617 |  3846.736001750968
  12 |   32 |   37 |  48.05528375189372 | 3902.5665263722544
  13 |   33 |    2 |    700.36313814633 |  3950.621810124148
  14 |    3 |   69 | 13.830090594515813 |  4650.984948270478
  15 |   67 |   57 |  269.7483878007764 |  4664.815038864994
  16 |   55 |   13 | 243.90865759717457 |   4934.56342666577
  17 |   11 |   14 |  592.4332460936212 |  5178.472084262944
  18 |   12 |   30 | 197.95743212114834 |  5770.905330356565
  19 |   26 |   44 | 230.11474397115853 |  5968.862762477714
  20 |   40 |   32 |  32.15748444428291 |  6198.977506448872
  21 |   28 |   34 | 128.30514459608628 |  6231.134990893155
  22 |   30 |   46 | 292.51977773825814 |  6359.440135489242
  23 |   42 |   47 |  42.00097102860326 |    6651.9599132275
  24 |   43 |   51 |  317.7487966492082 |  6693.960884256103
  25 |   48 |    3 | 24.366299209335182 |  7011.709680905311
  26 |    4 |    6 |  35.05578311994414 |  7036.075980114646
  27 |   46 |   62 |  269.6784973606185 |   7071.13176323459
  28 |   60 |   71 |  261.6741520558861 |  7340.810260595208
  29 |   69 |   20 | 1312.5430898908662 |  7602.484412651094
  30 |   18 |   72 |  86.31512692490578 |  8915.027502541961
  31 |   70 |    4 |  962.8503750491366 |  9001.342629466868
  32 |    5 |   60 | 131.65329169122384 |  9964.193004516004
  33 |   58 |   59 |  129.1237292961209 | 10095.846296207228
  34 |   57 |   53 |  93.77398873447196 |  10224.97002550335
  35 |   50 |   55 |  200.4322777934951 | 10318.744014237822
  36 |   52 |    7 |  4122.794957245806 | 10519.176292031318
  37 |    6 |   -1 |                  0 | 14641.971249277123
(37 rows)

芳賀・宇都宮LRTの全長は、15kmと聞いていましので、ほぼドンピシャ(14641.971249277123メートル)が算出されていることが分かります。

ただ、現在のnodeの位置は、駅の場所に対応していないので、鉄道情報のosmファイルを手動で作り直す必要はあります(nodeとgeomの変更等)が、その前に、とりあえず今のままの方式で、道路ー鉄道混在のダイクストラができるか、試してみます。

(2時間経過)

こんなのを作って試してみました。

mapconfig_for_cars_tram.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <tag_name name="highway" id="1">
    <tag_value name="motorway"          id="101" priority="1.0" maxspeed="130" />
    <tag_value name="motorway_link"     id="102" priority="1.0" maxspeed="130" />
    <tag_value name="motorway_junction" id="103" priority="1.0" maxspeed="130" />
    <tag_value name="trunk"             id="104" priority="1.05" maxspeed="110" />
    <tag_value name="trunk_link"        id="105" priority="1.05" maxspeed="110" />    
    <tag_value name="primary"           id="106" priority="1.15" maxspeed="90" />
    <tag_value name="primary_link"      id="107" priority="1.15" maxspeed="90" />    
    <tag_value name="secondary"         id="108" priority="1.5" maxspeed="90" />
    <tag_value name="secondary_link"    id="109" priority="1.5" maxspeed="90"/>  
    <tag_value name="tertiary"          id="110" priority="1.75" maxspeed="90" />
    <tag_value name="tertiary_link"     id="111" priority="1.75" maxspeed="90" />  
    <tag_value name="residential"       id="112" priority="2.5" maxspeed="50" />
    <tag_value name="living_street"     id="113" priority="3" maxspeed="20" />
    <tag_value name="service"           id="114" priority="2.5" maxspeed="50" />
    <tag_value name="unclassified"      id="117" priority="3" maxspeed="90"/>
    <tag_value name="road"              id="100" priority="5" maxspeed="50" />
  </tag_name> 
  <tag_name name="railway" id="1">
    <tag_value name="tram"              id="101" priority="1.0" maxspeed="40" />
  </tag_name> 
</configuration>

osm2pgrouting -f utsunomiya.osm -c mapconfig_for_cars_tram.xml -d test_db2 -U postgres

(<tag k="construction" v="tram"/>の<tag k="railway" v="tram"/>の強制置換を忘れずに)

QGISで表示してみたところ、ちゃんとLRTの架橋ができていました。

ただノード接続ができているか不明なので、これから調べてみます(経路が繋がっていないと、ダイクストラ計算はできないはずなので)。駅を手動で作るしかないかな・・・

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

私の勤務している会社は、eラーニング(*)も使って、社員教育を行っています ―― ってまあ、今時、どこでもそうでしょうが。

In my company, e-Learning systems(*) is working for education of employees, well nowadays, many companies use the system.

(*)パソコンやタブレット、スマートフォンを使ってインターネットを利用して学ぶ学習形態のこと

(*)Education system using PCs tables and smartphones vis the Internet.

で、先日、新しいカリキュラムが提示さてていました。

The other day, a new education package has come to my mail box.

簡単に纏めれば、「介護」と「子育て」 ―― 我が国のみならず、世界の社会課題 ―― に対する、会社としての取り組みに関する内容でした。

The contents are, company's measures and policies about in short "caring" for "parents" and "children", which are not only domestic but also international social problems.

『両親は、今年、いなくなり、子供は一人は成人、もう一人は大学生。もう私には関係のない話だな』

"My parents had been gone, and my senior daughter has been business person and my junior daughters is a college student. Anyway I don't have think about the problems".

と思っていたのですが、数秒後に自分に怒鳴っていました。

But after a few seconds, I screamed alone.

―― アホか! 私は!!

"How stupid I am!"

―― これから「介護」「子育て」を迎える世代、あるいは現在進行形の世代を、サポートする主体が、この私だろう!

"It is me to support the generations of present and future, who have to fight against "caring" for "parents" and "children"

―― 世間がどうなろうが知ったことではいが、社内の人間や、娘たちは、ドンピシャのターゲットだろうが!!

"I don't care of the world, however I have to support my co-workers and my daughter as supported persons"

-----

2大社会課題から逃がれた、と一瞬でも思ってしまった自分に、思いっきりつっこんでまいました。

I blamed me that I thought, even for a moment, that I had escaped from the two major social issues.

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

pgRoutingのデータベース構成ファイル
/usr/share/osm2pgrouting/mapconfig_for_cars.xml(自動車)
で作った、DBのレコードの意味が混乱してきたので、ちょっと整理

utsu_db=# select * from ways limit 1;
gid | osm_id | tag_id | length | length_m | name | source | target | source_osm | target_osm | cost | reverse_cost | cost_s | reverse_cost_s | rule | one_way | oneway | x1 | y1 | x2 | y2 | maxspeed_forward | maxspeed_backward | priority | the_geom
30797 | 547468496 | 112 | 0.002103460902954004 | 194.17417410447345| | 23363 | 7527 | 5289963314 | 1937141869 | 0.002103460902954004 | 0.002103460902954004 | 13.980540535522088 | 13.980540535522088 | | 0 | UNKNOWN|139.9512784 | 36.5577371 | 139.9532349 | 36.5573415 | 50 | 50 | 2.5 | 0102000020E610000004000000852C66DF707E61400822E6ED6347424033EE17FD727E61403F41182E61474240AD2C76A0737E6140B41D537765474240FD1C7AE6807E61400F9A5DF756474240

sourceとtargetの違いが分からかなったけど、wayの両端の番号、ということで良さそう。

で、今度はnodeの方だけど

utsu_db=# select * from ways_vertices_pgr limit 1;
id | osm_id | eout | lon | lat | cnt | chk | ein | the_geom
----+-----------+------+--------------+-------------+-----+-----+-----+----------------------------------------------------
4 | 264184195 | | 139.95960820 | 36.60870170 | | | | 0101000020E6100000267F411CB57E61408242F3EFE94D4240

が、nodeの情報が書かれているものらしい。

で、ここが重要。

ways_vertices_pgr の"id"  は、waysの"source" または"targetに対応しています。

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

業務連絡が、転送メールで送られてきます。

Sometimes, business orders come to us by forwarded mail.

普通に、サブジェクトの記載をコピペして、

Many people are support to copy and paste the message of mail subject, like

「今期、明細書執筆予定者への注意点を展開します」

"Please remained to people who plan to write patent application at this quarter"

とだけ記載して転載されてくるメールが多いです。

and they just forward the mail to us.

―― で、これらのメールは、ほとんどの人間にスルーされる、と

"As a result, these mails will be ignored by most readers"

-----

分かります。面倒くさいですからね。

I can understand it, because they are troublesome.

しかも、管理部門のメールは、『悪意でもあるのか』と思えるほど、文面が分かりにくです。

In addition, the mails from management departments are difficult to understand, as if they are malice.

「何をして欲しいのか、さっぱり分からん」という内容です。

The contents are "I don't know at all what on earth do they expect?"

まあ、管理部門の立場としては、そういう文面にならざるを得ないのも分かります。

Well, I might understand that they have to make the contents like that.

恣意的な内容を記載すると、業務内容を誤解されて、後でつっこまれる恐れがあるからです(面倒ごとになる)。

If they try to write the contents on their subjection, it might make the readers trouble.

-----

私も、面倒なので、基本的にはコピペ&スルーをしますが、例外があります。

I also copy, paste and forward the mail to avoid the troublesome, however I have an exception.

『これは、後で、自分に面倒が振りかかってくるな』と直感したものに関してだけは、丁寧に解説をします。

If I feel that "if I do that, another trouble comes to me", I will explain it by my words carefully.

概要を、江端の文言で解説し、該当者をby nameで指定し、締切の日時を強調して記載します。

I am going to write outline of the mail and explain it by my words and indicate the person by name, and emphasize the deadline.

こんな感じです。

As follows

====== メール文面例(ここから) ======

====== Example of the mail (From here) ======

知財部が激怒しています。

The IT department is furious.

『何度説明しても、書式を間違えて提出している』とのことです。

The reason is "we submit the patent application with wrong formats, even they have already had to explain it to us again and again".

本件に関しては、AさんとBさんが、この対象者のようです。

About this mail, I am afraid that Mr.A and Ms.B are objects.

「今月末までに修正を出せ」と言われています。

We have been ordered to re-submit the modification version.

ご希望があれば、私(江端)の方で、ざっくりレビューします

If you hope. I (ebata) will check it roughly.

レビューを希望しない人のことは知りません。その場合は「自力」で知財部と闘って下さい

I don't care people who don't want it. If so, fight the IT department on your own.

江端

Ebata

====== メール文面例(ここまで) ======

====== Example of the mail (To here) ======

まあ、こういう風に書いておけば、ほぼ100%の対応を得られます。

I know that I can get almost 100% responses, if I write the above.

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

例年、4月の上旬は、入社したての新人が、窓口業務でOJT(On the Job Training)に出てきます。

Usually, in early April, new employees who have just joined the company appear for on-the-job training (OJT) in window operations.

当然、新人ですので、その業務がもたつきますし、4月は各種手続で、多くの人が窓口に集まってきて 混雑します。

Naturally, since they are newcomers, their work will be slow, and in April, many people will gather at the counter for various procedures, making it crowded.

しかし、これは、「社会システムの立ち上げ期間」として、我が国の国民が、暖かい目で見守る必要のある期間である、とも言えましょう。

However, it can also be said that this is a "start-up period for the social system," a period that the people of Japan need to watch with warm eyes.

-----

本日、朝一番に、速達書留を出しに郵便局にでかけたのですが、窓口の方が、いわゆるシニアのおじさんでした。

Today, first thing in the morning, I went to the post office to send out an express registered mail. The person at the counter was a so-called senior uncle.

多分、そのおじさんは、新人で、若手の局員が横について、業務手続をサポートしていました。

The uncle was probably a newcomer, with a younger bureau staff member by his side to assist him with business procedures.

おじさんは、かなり戸惑っていたようですが、無理もありません。

He seemed to be confused, however, it could not be help.

書留郵便は、スキャナで封筒を読みとる方式に変わっていましたし(私が楽になりました)、カードで支払いできましたし、郵送物追跡用の番号が記載された紙片が発行されました。

About the express registered mail, the method to read a destination address changed to scan the envelopment( I don't have to write the address), I could use the credit cared, and get a receipt including the tracking number.

利用者にとっては、とても便利になっていますが、運用者(窓口のおじさん)にとっては、様々なデバイスを使わなければならないので、大変そうでした。

For me, as a users, these are very useful, however, the operator ( the uncle at the counter ) seemed to be hard to use various devices.

-----

そのおじさんは、未来の私です。

The uncle is me of the future.

皆さん、シニア(高齢者)を大切にしましょう。

Let's all take care of our seniors (elderly).

彼らは(私)は、社会的弱者という位置付けを終え、今や、必須の労働力として期待される存在です。

They (I) have already finished the role of "weaker of society", and now they are expected as essential labors

さらには、年金受給年齢を引き上げることで、国庫に寄与する重要な存在です。

In addition, they will be contributors to save national budget by rising the age of qualifying conditions.

-----

「おじいさん、おばあさんを大切にしましょう」というスローガンは、今や、その後ろに「貴重な労働力として」というフレーズが付与する時代です。

Now, the slogan of "Take care of elder people" is not completed. The phrase of "as important labors" will be added after the slogan.

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

今回のコラムでは、自分の無知の未経験を晒してコラムを書いています。

In this column, I am writing a column exposing my ignorance and inexperience.

以前、詐欺に遭った時のことを、書いたこともありました。

I once wrote about a time when I was scammed.

―― 「自分(江端)の無知や無能や無力をさらして書いている」と、これほど念入りに言っているのに、それでも『傷口に塩ふってくる人』は、一定数いるなぁ

"Even though I have been very careful to say, "I am writing to expose my (Ebata's) ignorance, incompetence, and inability," there are still a certain number of people who "sprinkle salt on the wound"

と、しみじみと実感しております。

I am deeply aware of this.

-----

まあ、『池に落ちた犬を叩く』というのは、誰にとっても(私も)、『相当、楽しい』です。

Well, 'beating the dog that fell in the pond' is 'quite fun' for everyone (even me).

なにしろ、犬(私)は、現在進行形で、池に落ちて溺れていますので、反撃することもできません。

After all, the dog (me) is currently drowning in the pond, so I can't fight back.

加えて、私の場合、『これまで、叩かれるだけのことをやってきた』という自覚もあります。

In addition, I am also aware that, in my case, 'I have reasons to be beaten'.

そして、これらの批判コメンをすることが ―― たとえ『池に落ちた犬を叩く』のであったとしても ―― 担保されている社会は、やはり『良い』のだと思います。

I believe that a society that guarantees the ability to make these critical comments is a good one -- even if it is "beating the dog that fell into the pond".

-----

ただ、覚えておいて欲しいのは、「私"が"叩いた人」のことは、数分間で忘れますが、

Just remember, I forget about the "person I "have beaten" in a few minutes. however,

「私"を"叩いた人」のことは、10年単位でも忘れません ―― というか忘れることができません。

I will not -- or rather, cannot -- forget the person who "beat" me, even if it takes me 10 years to do so.

『一生忘れないんじゃないかな』と思えるほど、自分でも信じられないほどの鮮明な記憶を保持し続けます。

I'll continue to retain vivid memories, and I think I'll remember it for the rest of my life.

-----

私、研究所の先輩から『愛の永久機関』の称号を頂いておりますが ――

I have received the title of "Permanent Institution of Love" from my seniors at the laboratory.

むしろ、『憎悪の高速増殖炉』の方が、相応わしいんじゃないかな、と、思っています。

Rather, I think "Fast Breeder Reactor of Hatred" would be more appropriate for me.

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

やったことがないプログラミングは、ワクワクします。

Programming that I have never done before excites me.

私、ゲーム(ここでは、コンピュータゲームのこと)を真剣にやったことがないのですが、たぶん、同じ方向だと思います。

I've never played games (I mean it's computer games) seriously , but probably in the same direction.

「思い通りにプログラムが動く = ラスボスを倒す」

I think that "I make a program that I want to execute" is equal to "I defeat the last boss."

だと思うのです。

違いがあるとすれば ――

If there is a difference,

プログラミングは、第三者にノウハウを継承できる、という点は大きいと思います。

I think programming is a great way to pass on know-how to third parties.

比して、ラスボスを倒すノウハウは、知財として保護もされないし、そもそも第三者に移転できません。

In contrast, the know-how to defeat the last boss is not protected as intellectual property, nor can it be transferred to a third party.

-----

江端家は、一般的な庶民の家庭だと思いますが、

The Ebata family is a typical family of ordinary people, I think. However we had never used the following phrase of

『ゲームばかりやっていないで、勉強しなさい』

"Don't play games all the time, study!"

というフレーズだけは登場しない家庭でした。

そもそも、我が家には、ゲームの文化が根付いていません。

To begin with, the culture of gaming has not taken root in my family.

私が最後に聞いたゲームの単語は「ニンテンドウDS」と「Wii」なるものでした。

The last game words I heard were "Nintendo-DS" and "Wii".

娘たちはハイティーンの時代を"No Game"で過してきたのかと思うと、それはそれで凄いことだな、と思います。

It is amazing to think that my daughters have spent their high teenage years playing "No Game".

それはさておき

Return to the topic.

------

逆に考えれば、ゲームの才能は、第三者に移転できないが故に、強い差別化が実現できます。

Conversely, gaming talent cannot be transferred to a third party, and therefore strong differentiation can be achieved.

プロのゲームプレーヤーなどはその一例です。

Professional game players are one example.

ゲームは、ちゃんと体系化して、マニュアル化して、カリキュラムを組めば、学校教育の対象に成るかもしれません。

Games could be the subject of school education if they are properly systematized, manualized, and curricularized.

これは、現在のプログラミング教育やSTEM教育ともタッグを組みやすいです。

This can easily tag-team with current programming and STEM education.

また、年齢、性別、体格等によって影響を受けにくいという点から、Eスポーツは、高齢者の健康作りに資する可能性が高いです。

In addition, e-sports have a high potential to contribute to the health of the elderly in that they are less likely to be affected by age, gender, or physical size.

また、実際に、「孤独」や「孤立化」に対する、ソリューションの一つであるとも言えます。

It is also, in fact, one of the solutions to "loneliness" and "isolation".

教育による負の効果としては、「ゲーム嫌い」という、新しいパラダイムを作り出せるようになるかもしれません。

One negative effect of education may be the creation of a new paradigm, that of "game aversion".

我が国で顕著な、「英語嫌い」「数学嫌い」と同じように、ゲームを嫌う傾向が構築されることで、「ゲーム依存症」などの問題の解決策となる可能性があります。

Just like the "English haters" and "math haters" that are prominent in our country, the building of a tendency to dislike games could be a solution to problems such as "game addiction".

------

まあ、実際のところ、現在のプログラミング教育の導入によって、「プログラミング嫌い」も発生する可能性も高いです。

Well, in fact, the current introduction of programming education is also likely to generate "programming aversion".

正直に言えば、『絶対に発生する』と、私は思っています。

I can honestly say, 'It will definitely occur,' I believe.

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

私が知らないだけなのかもしれませんが(知っている人は教えて欲しいでです)、OpenStreetMapの鉄道のデータは、nodeとwayに変換できません ―― というか、変換する方法を、私には知りません(散々探したんだけど、見つからない)。

#でも、絶対にあると思うんだよなぁ。だって、鉄道と車を融合させる研究、腐るほどあるもん。これらの研究が全部、商用のGISシミュレータ使っているとは思えないんだけどな。

ちなみに私は、PostgreSQL + PostGISを使って、GISのシミュレータを作っています。

で、鉄道を路線の上で走らせたいのですが、鉄道の情報は、進行方向の順番通りには表示してくれません。

ですので、一路線を作る為には、geomをLINESTRINGで、座標単位にバラバラにする必要がありますが、問題は、geomが順番通りに表示れない、ということです。

なので、QGISとかを使って、始点・終点を探して、SQLの結果から、順番を探す、という面倒なことをやらざるを得ません。

QGIS弄っていたら、LINESTRINGの座標を得られる方法をたまたま見つけてしまったので、私の為に記録しておきます。

まず、前提はこの内容です。

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

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

まず地物表示のボタンを押します。

次に、LRTの路線の最初の部分をクリックします。

次に、(派生した属性)を右クリックして、「地物をコピー」を選択します。

で、これをエディタなどに、コピペすると

wkt_geom tags
LineString (139.89970149999999194 36.55948450000000349, 139.89955630000000042 36.55885789999999957, 139.8995482999999922 36.55877879999999891, 139.89956340000000523 36.55872629999999646, 139.8996118000000024 36.55866100000000074, 139.89968200000001275 36.55861320000000347, 139.8997737999999913 36.55858750000000157, 139.89987840000000574 36.55857249999999681, 139.90136459999999374 36.55845939999999672, 139.90222030000001041 36.55839509999999848, 139.90252409999999372 36.55837619999999788, 139.90541809999999145 36.55817369999999755, 139.90668009999998844 36.55808119999999661, 139.90870390000000612 36.55791560000000118, 139.90887219999999047 36.55789959999999894, 139.90931180000001177 36.55786609999999826)

てな感じで、geomに含まれる座標がでてきます。

これを、出発地から到着地まで、間断なく続ければ、路線の連続の座標が得られる、という訳です(そこそこ面倒ですが、selectのダンプから探すよりはマシです)。

まあ、それぞれのgeomの先頭と終端は、重複する座標となるので、これを消すなどの処理は必要ですが、取り敢えず、これで鉄道の連続する座標は得られます。

この後、これらの座標をDBに放り込むなり、プログラムにベタ書きするなり、煮るなり焼くなり、色々できると思います。

とりあえず、(emacs使い倒して)csvファイルにしました。

ここからpostgreSQLにインポートするのは ―― 多分、なんかの手段があるだろう、と思う。

ここにありました。

[付録B] 地図の上に100人ほど配置してみる(メモ)

私はPostgreSQLをdockerコンテナの中に作っているので、"docker cp"でコンテナ内にcsvファイルを送り込む必要がありました。

utsu_rail_db=# CREATE TABLE "lrt"(
utsu_rail_db(# seq integer,
utsu_rail_db(# x1 float,
utsu_rail_db(# y1 float,
utsu_rail_db(# distance_m float
utsu_rail_db(# );
CREATE TABLE
utsu_rail_db=# \dt
              List of relations
 Schema |      Name       | Type  |  Owner
--------+-----------------+-------+----------
 public | lrt             | table | postgres
 public | spatial_ref_sys | table | postgres
 public | utunomiya       | table | postgres
(3 rows)
utsu_rail_db=# \copy lrt from '/tmp/lrt.csv' with csv
COPY 286
utsu_rail_db=# select * from lrt;
 seq |     x1      |     y1      | distance_m
-----+-------------+-------------+-------------
   1 | 139.8997015 |  36.5594845 |           0
   2 | 139.8995563 |  36.5588579 | 55.68730112
   3 | 139.8995483 |  36.5587788 | 6.785051714
   4 | 139.8995634 |  36.5587263 | 4.769494948
   5 | 139.8996118 |   36.558661 | 7.734168448
   6 |  139.899682 |  36.5586132 | 8.800865673
   7 | 139.8997738 |  36.5585875 | 10.43856664
   8 | 139.8998784 |  36.5585725 | 11.70055883
285 | 140.0145241 | 36.572845 | 28.22469677
286 | 140.0117433 | 36.57920089 | 623.5656217
(286 rows)
以上

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

ロシア外務省が、日本人の入国禁止者63人を発表しました。

The Russian Ministry of Foreign Affairs announced that 63 Japanese nationals are banned from entering Japan.

私は入っていないようでした ―― 当然ですが。

I didn't seem to be in it -- naturally.

-----

以前、ワクチン接種証明の提示に応じないお客に対して、出入禁止(いわゆる、出禁)ができるか、について調べました。

I have previously done my own research on whether a customer who refuses to show proof of vaccination can be banned from the premises.

さて、これから「マスクをしない方は、入店を御遠慮下さい」が、「ワクチン接種を終えていない方は、入店を御遠慮下さい」に変化していくに際して、『これは、"差別"なのか?』という純粋な疑問です。

今回、再度、調べてみました。

This time, I looked into it again.

上の日記でも書いていますが、この出入禁止の法的根拠は、民法第521条「契約の自由」です。

The Russian Ministry of Foreign Affairs announced that 63 Japanese nationals are banned from entering Japan.

この521条は、現行法と抵触しない限りにおいて、自由に設定できるものであり、その範囲はかなり広いようです。

This Section 521 is open-ended, as long as it does not conflict with current law, and its scope appears to be quite broad.

"ドレスコード"や"一見さん"はもとより、個人を指定し、名指しで出禁を指定することもできるようです。

It is possible to specify a "dress code", a "first-time customer", or even to designate individuals to be banned from facilities by name.

これを無視すると、刑法(×民法)第130条に規定する建造物侵入罪・不退去罪で、警察に通報・強制退去の対象となります。

If you ignore this, you will be subject to a police report and forced eviction for the crime of trespassing and eviction from a building, as stipulated in Article 130 of the Penal Code (x Civil Code).

もちろん、名指しで出禁を指定された人は、『「契約の自由」の濫用』として、訴訟に持ち込むこともできますが、私が、ざっと調べた限り、裁判になっても、原告が敗訴しているようです(例 平成29年1月12日静岡地方裁判所沼津支部判決)。

Of course, those who have been designated as banned by name can bring a lawsuit for 'abuse of "freedom of contract"', but as far as I can tell, the plaintiffs have lost their cases in court (example: January 12, 2009 Shizuoka District Court, Numazu Branch decision).

もちろん、現行法と抵触するような出禁は、当然に無効となりますが、まあ、そういうケースは、そもそも裁判にならないのでしょう。

Of course, any entry/exit ban that conflicts with current law would obviously be invalid, but, well, such a case would probably never go to court in the first place, I think.

-----

『ロシア外務省に対して、入国禁止の不服申立(即時抗告)をする』というアクションを試してみる人、いませんか?

Is there anyone who would like to try the action of 'file an appeal (immediate appeal) against the entry ban to the Russian Ministry of Foreign Affairs'?

ロシアが採用している行政法の法体系を、全然知りませんが、ロシアの司法による『判断理由』を読んでみたいな、と思いました ―― 理由の記載なし、というケースも含めて。

I don't know the legal system of administrative law that Russia has adopted, at all, but I would like to read the 'reasons for the decision' by the Russian judiciary -- including the case of "no reasons stated".