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

そろそろ「雪」が来そうな気がしましので、本日、スノータイヤに交換をしました。

I changed my normal tires to snow tires today because I feel that snow is about to arrive.

すでに10回に近い経験を経たためか、30分程度で処理を終了できるようになりました。

Perhaps because I have already done the process close to 10 times, I am now able to finish the process in about 30 minutes.

しかし、

However,

―― 慣れてきたころに、事故が起こる

"Just when I am getting used to it, an accident happens"

ことは、なんども痛い目をして知ってきましたので、特に「腰」と「指」に注意して作業をしました。

I have learned this through many painful experiences. Therefore, I paid particular attention to my "waist" and "fingers.

『DIYのタイヤ交換で、5000円くらいの節約になっている』という気持ちで、これまでは盛り上っていたのですが ――

I've been getting excited with the feeling of 'I'm saving about $5,000 on a DIY tire change'

最近、作業が義務的になってきて、当初のような高揚感が落ちてきているような気がします。

Lately, I feel that the work has become obligatory and the elation that I felt in the beginning has dropped.

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

新しく購入したPCのオーディオ出力(イヤホンからの音)が不明瞭(例えるならば、歌手の声だけがフィルタリングされたようなされたような変な音)しか出力されません。

The audio output (from earphones) of my newly purchased PC is indistinct (i.e., only the singer's voice sounds filtered and distorted).

メーカーに問い合わせたところ、『ドライバの総入れ替え(全インストール)』を提案されました。

When I contacted the manufacturer, they suggested "total driver replacement (all installation)".

でも、

However,

―― それだけは嫌

"I'd like to avoid that"

です。

こういう大規模なドライバの入れ替えは、結構高い確率で、システムクラッシュするのです。

These large-scale driver replacements have a fairly high probability of causing system crashes.

こういうトラブルで、私は人生の相当な時間を費されてきました。

These problems have cost me a considerable amount of time in my life.

PC設定、Office、IED(VSCode)、Go言語、MindManagerなどを、全部を一からやりなおすのです。考えるだけでゾっとします。

I would have to start all over again with PC setup, Office, IED (VSCode), Go language, MindManager, etc. I shudder just thinking about it.

Youtubeが視聴できないくらいのことで、こんなリスクは取れません。

I can't take this kind of risk for something as trivial as not being able to watch Youtube.

-----

USBポートが余っているので、今回はこのデバイスを購入して問題を回避します。

I have an extra USB port, so I will purchase this device to avoid the problem.

こういう思考形態を、「保守」と言います。

This form of thinking is called "conservatism".

「日和(ひよ)る」とも言います。

Or, "opportunism".

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

「秒速5センチメートル」は、新海誠監督の名作です。

"5 Centimeters per Second" is a masterpiece by director Makoto Shinkai.

キャッチコピーは『桜の花びらが舞い落ちる速度』

The catchphrase is "The Speed of Cherry Petals Falling Down."

-----

しかし、シニアの私にとって、「秒速5センチメートル」とは、

But for me, as a senior, "5 Centimeters per Second" is

―― ぎっくり腰になった私が、トイレに向かう速度

"The speed at which I, having suffered an upset back, head for the restroom"

です。

# 今、検証シミュレーションをやってみたのですが、もっと低速みたいです(秒速1センチメートル前後)。

# I just ran a verification simulation and it seems to be much slower (around 1 centimeter per second

なお、この速度計算には、トイレに到着後、着衣を外して便座に着座するまでの時間は、入っていません(さらに速度は低下する)。

Note that this speed calculation does not include the time between arrival at the restroom and removal of clothing and seating on the toilet seat (which further reduces the speed).

-----

いずれ、あなたにも分かることになります ―― あの息もできなくなる激痛が。

Eventually, you will know -- that intense pain that makes you unable to breathe.

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

昨日の話の続きなります。

This is a continuation of yesterday's story.

最近の私は、論文の山と格闘中なのですが、正直かなり腹を立てています。

I am wrestling with a stack of papers these days, and to be honest, I am quite angry.

―― なんでお前ら、言葉だけで説明しようとするんだ

"Why do you guys try to explain with just words?"

と。

私、"他人の論文"を説明するのに、わざわざ自分でこんな図を作っています。

I went to the trouble of making this diagram myself to illustrate "someone else's paper".

『これって、そもそも、お前(執筆者)が作るものだろう』と思うのです。

I think, 'This is the figure you (the authors) would make in the first place.'

私には、「論文の理解を読者の力量にぶん投げて、読者に近づこうとする努力を怠っている」ように見えるんですよね。

To me, it looks like "the author is making no effort to approach the reader, leaving the reader's understanding of the paper out"

-----

(私のコラムをご覧頂いている方は、ご存知かと思いますが)、私、自分の執筆する文章には、非常識な程の多くの(紙面の50%超)図表や写真を張りまくっています。

If you have been reading my columns, you may know that I cover an insane amount of my writing (over 50% of the paper) with charts and photos.

今年、ほとんど口語調のコラムの形式で投稿した論文を執筆しました。

This year, I wrote a paper that I submitted in the form of a mostly spoken column.

『これでリジェクト(却下)されたら、それでも構わん』という気持ちで、寄稿したのですが、ありがたいことに、論文賞を貰いました。

I contributed my paper with the thought, "Even If rejected, I don't care," but thankfully, I received a paper award.

私的な見解ですが ―― 現在のアカデミズムに決定的に欠けているのは『思いやり』なんじゃないかなぁ、と思うのです。

In my opinion -- I think that what is definitely lacking in academia today is "compassion".

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

楕円内の一様乱数

などと苦労しているのですが、結局のところ、私は地図のある領域を指定して、任意の緯度・軽度情報を出す乱数を作りたかったのです。

川の中から人が歩き始める」とか「山の中で人が消える」とか、シミュレーションと言えども、ちょっと許されない設定だと思いまして。

で、上記の記事を読まれた師匠のSさんから「こんなのがあるよ」と教え貰いました。

https://aginfo.cgk.affrc.go.jp/docs/pgisman/2.3.0/ST_GeneratePoints.html

適当なdbに接続して、例題を試してみました。

yama_db=# SELECT ST_GeneratePoints(ST_Buffer(ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'), 10, 'endcap=round join=round'), 12);
st_generatepoints
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
01040000000C0000000101000000BBA9D0DF47496240F87F69424E0E5F400101000000B7F51F68D5646240F55A898F1F17504001010000003572FBDA8A5F5F400F87342089BE5E400101000000D4A38750931D5C40ED72799B370B5E4001010000006667943B23885B4066E8F671D97C5B400101000000EBA3152848526340221E78F6C3965D400101000000113BA23198BF6240C7234B9EF33D5840010100000069499F8062745540FF88E6BF407355400101000000A581F43AC300624042D083BD5A2262400101000000636CD355C19E62404AD3293D4D904B40010100000045F7B8041DAA4E405A849AF069A34F400101000000DE1370CF02E5564050D2988109CE5940
(1 row)

geom形式で出されても全然分からんので、st_asTextでラッピングしてみました。

yama_db=# SELECT st_asText(ST_GeneratePoints(ST_Buffer(ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'), 10, 'endcap=round join=round'), 12));
st_astext
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
MULTIPOINT(147.766265850576 102.733187047914,84.0318650671786 83.712367636874,149.077046025334 68.9777848138994,107.54047530747 106.78013766944,121.059921872846 120.108716631886,137.475992983887 141.067784163524,145.074876095804 96.5277972374404,92.7965422941866 103.656943557244,66.0805226475207 56.7924152255781,72.3801321221102 71.3671567226799,145.087956158666 41.5121740980702,151.631108302923 156.218459065337)

なるほど、乱数が出力されているようです。

'LINESTRING(50 50,150 150,150 50)'), 10 → 座標 (50,50)(150,150)(150,50)で繋がれた幅10の直線上に

'endcap=round join=round'), 12));  →  12個の座標乱数を作れ

という意味のようです。

 


さて、実際の地図で試してみました。

kitaya_db=# SELECT st_asText(ST_GeneratePoints(ST_GeomFromText('POLYGON((35.66463989558893 139.69827111644202,35.663009879798764 139.6983247606236,35.663436999453225 139.7011571734108,35.665398233838545 139.7012966482829,35.66463989558893 139.69827111644202))'),12));

これは、以下の地図の4点で取り囲まれた地区で、任意の12点を抽出しろというSQL文になっています。

POLYGON((35.66463989558893 139.69827111644202,35.663009879798764 139.6983247606236,35.663436999453225 139.7011571734108,35.665398233838545 139.7012966482829,35.66463989558893 139.69827111644202))

ポリゴン(POLYGON)は、始点と終点(上の赤字)を同じ座標として閉じなればならないようなので、注意して下さい。

このSQL文のアウトプットは、以下のようになりました。

st_astext
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
MULTIPOINT(35.6638134136244 139.699085401991,35.6638440750173 139.700762425247,35.6634366319309 139.699705025931,35.6644917235626 ,35.66424835050 139.69868073913379 139.70025902483, 35.664689711471 139.700525986493,35.6635000403398 139.700601350665,35.6637472356065 139.698748086462,35.6641512918098 139.699288949827,35.6643791061995 139.701118277182,35.6636240715869 139.699272976596,35.6645803781279 139.699116246391)

エクセルで座標描いて、当ててみました。

全て領域の中に入っているようです。

さて、今度は、プログラム(go言語)でのこの座標の取り出し方です。


package main

import (
	"database/sql"
	"fmt"
	"log"
	"regexp"

	// "os"
	_ "github.com/lib/pq"
)


func main() {

	db, err := sql.Open("postgres",
		"user=postgres password=password host=192.168.0.23 port=15432 dbname=kitaya_db sslmode=disable")
	if err != nil {
		log.Fatal("OpenError: ", err)
	}
	defer db.Close()

	//rows, err := db.Query("select id, age, type, departure_name, departure_number, departure_lat, departure_lng, arrival_name, arrival_number, arrival_lat, arrival_lng from user_list")

	rows, err := db.Query("SELECT st_asText(ST_GeneratePoints(ST_GeomFromText('POLYGON((35.66404878 139.6931452,35.66051393 139.6943828,35.65878732 139.6973512,35.658431 139.6997472,35.66067562 139.705346,35.66404467 139.706768,35.66790807 139.7049654,35.66945399 139.702109,35.66672151 139.7018011,35.66475716 139.6987517,35.66362838 139.6955941,35.66641828 139.6934209,35.66404878 139.6931452))'),12))")
	if err != nil {
		log.Fatal(err)
	}
	defer rows.Close()

	var msg string

	for rows.Next() {
		if err := rows.Scan(&msg); err != nil {
			fmt.Println(err)
		}

		// まずはMULTIPOINTをバラバラに分解する
		arr1 := regexp.MustCompile("[() ,]").Split(msg, -1) // '('か、')'か、' 'か、","で分割する → "[中身]" という構造でまぎらわしい

		for _, s := range arr1 {
			fmt.Printf("%s\n", s)
		}
	}
}

出力結果

> go run main3.go
MULTIPOINT
35.6601418389163
139.702654481044
35.661087233013
139.694572689447
35.6617615089132

Keyword: postgis postgres エリア 領域 範囲 指定 乱数 座標 囲む

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

英語に愛されないエンジニアの、英語プレゼンテーションのカンニングペーパーです。

This is a cheat sheet for an English presentation by an engineer who doesn't love English.

私、思うんですが ―― 日本人の多くが、英語を使って戦う時って、こんな感じじゃないかな、と思うんです。

I think -- this is a typical style when we Japanese fight using English.

つまり

That means,

―― 格好なんぞつけている場合か

"Don't be cool "

です。

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

昨夜、雪が降りましたが、私の街では大雪にはなりませんでした。

It snowed in my city last night, but not heavily.

私は知らなかったのですが、近くの裏山(15分くらいのところ)に大きなスキー場であることが分かり、そこに行くことになりました。

I didn't know that it was a big ski resort in the backwoods nearby (about 15 minutes away) , so I decided to going that.

スキーバスに乗ったのですが、そのバスは、傾斜30度もあるかというアイスバーンの坂道を登っていくので、私が驚いて、バスの運転手さんに、『大丈夫なんですか?』と尋ねたころ、

I took the ski bus, which was going up an icy slope with an incline of 30 degrees, and I was so surprised that I asked the bus driver, "Are you okay?"

『何、言っているのか分かりません』

"I don't know what you're talking about"

と、運転手のサンドウィッチマンの富沢さんが応えました。

Tomizawa-san, the driver of the car, of the manzai group of Sandwich Man, responded.

そして、バスが到着して、いよいよ、スキーゲレンデが見えてくる ―― と、思ったその瞬間、

And then the bus arrived, and finally, the ski slopes came into view -- at the moment,

『パパ、10分後に、よろしく~』という、嫁さんの呼び掛けで目を覚ましました。

I woke up to my wife's call, "10 minutes later, my darling".

-----

今日から、長女と2人で一泊二日の温泉旅行にいく嫁さんの為に、駅まで車を出すことになっていました。

I was supposed to drive to the station today for my wife, who was going on a two-day/one-night hot spring trip with my senior daughter.

車を運転しながら、

While driving the car,

江端:「せめて・・・、せめて、一目、ゲレンデを見たかった!」

Ebata: "At least... at least I wanted to catch a glimpse of the slopes!"

とグジグジと恨み言を言っていると、

When I was giggling and grumbling and resentful,

嫁さん:「帰って、もう一回寝れば?」

Wife: "Why don't you go home and sleep again?"

と言われました。

She said that.

私は、帰宅後、すぐにリモート会議に参加しなければなりませんでした。

I had to attend a remote meeting as soon as I got home.

-----

私、レポートや発表で、今も目が回るほど忙しいので、温泉旅行なんぞ論外です。

I am still dizzyingly busy with reports and presentations, so a trip to a hot spring is out of the question.

しかし、内心では「雪の温泉」を羨ましがっていたのかもしれません ―― 奇妙な夢を見てしまうほどに。

However, inwardly, I may have envied the "snowy hot springs" so much that I had strange dreams.

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

最近、副業としてプログラミングを履修している人が多いそうです。

Many people are taking programming as a side job these days.

で、その副業で収入を得ている人もいるそうです。

And some of them are earning income on the side.

とすれば、私の未来(老後)は、バラ色ではないかと思うのです。

If so, I think my future (retirement) will be rosy.

初学者と比較すれば、多分、学習時間は限りなくゼロに近いはずです。

Compared to a beginning student, the learning time should probably be as close to zero as possible.

なのに、

However,

―― なんで、こんなに不安なんだろう?

-- Why am I so worried?

-----

人間は、自分の持っている武器について、無頓着である、ということはあると思います。

I believe that people are sometimes indifferent about the weapons they have.

しかし、ことプログラミングに関しては、世間のプログラミングに対する理解が低いという可能性もあります。

However, when it comes to programming, it is possible that the public's understanding of programming is low.

実際、プログラムは、その評価がもっとも難しい無体財産の一つです。

In fact, the program is one of the most difficult intangible assets to value

-----

私、これまで、「プログラミングを見せて欲しい」という人に対して、プログラムを無制限に公開をしてきましたが、現時点で

I have been releasing unlimited number of programs to those who have asked me to show them, but

―― 江端のコードを利用して、別のプログラムを作った

"I used Ebata's code to create another program"

という人を、寡聞にして知りません。

I don't know of anyone to try it at all.

そして、私自身、他人のプログラムを、自分のプログラムに応用した事例は、数えるくらいしかありません。

And I myself can only count the number of instances in which I have applied other people's programs to my own.

何度もこの話はしていますが、

I've talked about this many times.

―― 人のプログラムを読むことは、他人の人体を切り開いて、脳味噌や内蔵を覗きこむような不快感がある

"Reading a person's program is as uncomfortable as cutting open another person's human body and peering into their brains and guts"

公開されたプログラムが、今一つ広がっていかない理由の一つには、この『気持ち悪さがある』と思っています。

I believe this 'weirdness' is one of the reasons why the programs that have been released to the public