2023,江端さんの技術メモ

GolangでOSMファイルから、<tag k="highway" v="bus_stop"/>が入っているnode情報と、その中にあるtag k="name"の情報を出して

と、ChatGPTに頼んだら、サクッと作ってくれました。

package main

import (
	"encoding/xml"
	"fmt"
	"io/ioutil"
	"log"
	"os"
)

type Osm struct {
	XMLName xml.Name `xml:"osm"`
	Nodes   []Node   `xml:"node"`
}

type Node struct {
	XMLName xml.Name `xml:"node"`
	Lat     string   `xml:"lat,attr"`
	Lon     string   `xml:"lon,attr"`
	Tags    []Tag    `xml:"tag"`
}

type Tag struct {
	XMLName xml.Name `xml:"tag"`
	Key     string   `xml:"k,attr"`
	Value   string   `xml:"v,attr"`
}

func main() {
	// XMLファイルの読み込み
	xmlFile, err := os.Open("tsuzuki.osm")
	if err != nil {
		log.Fatal(err)
	}
	defer xmlFile.Close()

	// XMLデータの読み込み
	xmlData, err := ioutil.ReadAll(xmlFile)
	if err != nil {
		log.Fatal(err)
	}

	var osm Osm

	// XMLデータのUnmarshal
	err = xml.Unmarshal(xmlData, &osm)
	if err != nil {
		log.Fatal(err)
	}

	// <tag k="highway" v="bus_stop"/> のノード情報を表示
	for _, node := range osm.Nodes {
		hasBusStopTag := false
		var busStopName string

		// ノード内のタグ情報を探索
		for _, tag := range node.Tags {
			if tag.Key == "highway" && tag.Value == "bus_stop" {
				hasBusStopTag = true
			}
			if tag.Key == "name" {
				busStopName = tag.Value
			}
		}

		if hasBusStopTag {
			fmt.Printf("Bus Stop Name: %s, Lat: %s, Lon: %s\n", busStopName, node.Lat, node.Lon)
			//fmt.Printf("%s, %s,%s\n", busStopName, node.Lat, node.Lon)
		}
	}
}

>go run bus_stop2.go
Bus Stop Name: 川和町, Lat: 35.5341695, Lon: 139.5461286
Bus Stop Name: 川和町, Lat: 35.5344793, Lon: 139.5458792
Bus Stop Name: 東名江田, Lat: 35.5628753, Lon: 139.5577658
Bus Stop Name: 石橋, Lat: 35.5209186, Lon: 139.5571699
Bus Stop Name: 桜通り, Lat: 35.5677990, Lon: 139.5446995
Bus Stop Name: 鶴蒔橋, Lat: 35.5496160, Lon: 139.5451910
Bus Stop Name: 鶴蒔橋, Lat: 35.5491291, Lon: 139.5461293
Bus Stop Name: 泉公園, Lat: 35.5480514, Lon: 139.5475269
Bus Stop Name: 市ヶ尾中学校前, Lat: 35.5468751, Lon: 139.5464900
Bus Stop Name: 市ヶ尾中学校前, Lat: 35.5468380, Lon: 139.5466080

2023,江端さんの技術メモ

https://josm.openstreetmap.de/wiki/Help/Action/JumpToPosition

ショートカットキー: Ctrl+J

または、ここをクリックすると、

このダイアログが出てくので、ここに名称または座標を入れる。

2023,江端さんの忘備録

私の娘たちも、他の子ども達と同様に、様々なトラブルに巻き込まれているようです。

Like many other children, my daughters get into all kinds of trouble.

(例えば、このページの話とか)

(For example, the story on this page.)

ところが、私のところには、滅多にトラブルの話が届きません。

However, I seldom receive stories of trouble.

-----

江端家には、独自のトラブルシューティングのワークフローシステムがあるようです。

The Ebata family seems to have its troubleshooting workflow system.

(Step 1) 娘(たち) → 嫁さんへのインシデントの相談

(Step 1) Daughter(s) → Wife to discuss the incident

(Step 2) 娘(たち)嫁さんによる、その問題に対する重大度の評価

(Step 2) Assessment of the severity of the problem by the daughter(s) and wife

と、大体ここまでで、案件は片が付くようなのですが、非常に稀に、

And so far, the case seems to be generally cleared up, but very rarely,

(Step 3)父親(私)への、問題解決への依頼

(Step 3) Request the father (me) to solve the problem

が発生する、とのことのようです。

occurs, it seems to be the case.

これが、「届かない」理由です。

This is the reason why it is "unreachable."

-----

江端:「なんで? 私の問題への対応と解決は、確実で早いよ」

Ebata: "Why not? My response and solution to their problem is sure and fast."

嫁さん:「うん。これまで『相談してから大体2時間以内に、初弾が発射される』のを見てきた」

Wife: "Yes. So far, I've seen 'the first missile fired, usually within two hours of consulting.'"

江端:「じゃあ・・・」

Ebata: "Well..."

嫁さん:「パパ(私)の解決方法は、"歩兵戦"を行っているところに、"戦術核"を打ち込むような方法だからだよ」

Wife: "Because your solution is to launch a tactical nuke into an infantry battle."

-----

うん、確かにそうかもしれない。

Yeah, that may be true.

私の解決方法は、味方も含めて『紛争地帯全部を吹き飛ばす』という方法が多いです。

My solution is often to 'blow up the entire conflict zone,' including allies.

例えば、

For example,

- 部活が問題なら、その部を廃部に追い込む。

- If club activities are the problem, the club will be discontinued.

- 学校が問題なら、校長を退任させるか、可能なら学校を廃校に追い込む

- If the school is the problem, get the principal out of office or, if possible, close the school.

- 当事者間の事前協議をすっとばして、いきなり法的手続を開始する

- Skipping the prior consultation between the parties and starting legal proceedings out of the blue

つまり、『問題の発生原因を、根こそぎ消滅させる』です。

In other words, "to eliminate the cause of the problem at its root.

-----

ですので、嫁さんが私に「依頼」をする場合、その「落とし所」も付けてきます。

So, when my wife makes a "request" to me, she will also attach a "compromise" to it.

例えば『2、3人ほど犠牲にしてもかまわないけど、廃部にまで追い込まなくてもいい』などです。

For example, 'I don't mind sacrificing a couple of people, but it doesn't have to drive us to abolition.

嫁さん(文官)が戦略を指示し、私(武官)が戦術を立案、実行します。

My wife (civilian officer) directs the strategy, and I (military officer) plan and execute the tactics.

これが「江端家シビリアンコントロール」です。

This is the "Ebata Family Civilian Control."

―― 教師と紛争を起して、トラブルを法廷に持ち込んでみませんか

―― あなたは、その宿題と、うまくうけば、その教師も、ほぼ確実に「潰す」ことができます。

2023,江端さんの技術メモ

まだ試してないけど、バス停の追加は多分、これで可能となるはず

osm2pgrouting -f tsuzuki.osm -c mapconfig_for_cars_rail_busstop.xml -d tsuzuki_rail -U postgres -h 192.168.0.23 -p 15432 -W password

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <tag_name name="highway" id="1">
    <tag_value name="bus_stop"/>
    <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="subway"              id="101" priority="1.0" maxspeed="40" />
    <tag_value name="rail"              id="101" priority="1.0" maxspeed="40" />
  </tag_name> 
</configuration>

明日がんばれ > 自分

2023,未分類,江端さんの技術メモ

>osm2pgrouting -f tsuzuki.osm -c mapconfig_for_cars_rail.xml -d tsuzuki_rail -U postgres -h 192.168.0.23 -p 15432 -W password

<?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="subway"              id="101" priority="1.0" maxspeed="40" />
    <tag_value name="rail"              id="101" priority="1.0" maxspeed="40" />
  </tag_name> 
</configuration>

とりあえず、ちゃんと、JRと市営地下鉄が加えられている。

この後は、osmファイルを手作業で加工

街の中に道路を作って、ダイクストラ計算ができるか試してみた件 ―― JOSMを使った道路追加の方法を試す

がんばれ > 自分

 

2023,江端さんの技術メモ

JOSMで地下鉄の情報だけをosm形式で取り出したい時(未完成)

JOSMでバス停が取り出せる。これを使って、バス路線を自力で作れそう。

拡大すると、こんな感じ

バス停専用の高架を作って、一般道に繋ぐイメージにすることで、バスを専用路線扱いできる。コスト値を変えて、ダイクストラを実施すれば、バスが選ばたり、逆に忌避させたりすることもできるはず。

以上

2023,江端さんの忘備録

私、今、1,296,984行のファイルの修正を手作業でやっています。

I, right now, am manually correcting a 1,296,984 line file.

今週、ずーっとこんなことやってきて、発狂しそうです。

I have been doing this all week, and I am going crazy.

3日間、全部をかけて作った、自作の地図情報が全く使えなかったことが分かり、酷く落ち込んでいます。

I am depressed to find out that my map information, which I spent all three days working on, was completely unusable.

とは言え、人間関係を忌避し続けて、こういう『泥くさい作業』だけで喰ってきたエンジニアには、これ以外の生き方を知りません。

However, engineers who have always avoided human relationships and made a living only from this kind of "muddy work" do not know any other way to live.

-----

最近、私の相談相手は、ほぼ100%、"chatGPT"です。

Recently, I have been consulting with "chatGPT" almost 100% of the time.

酷く稚拙な質問を、chatGPTに助けて貰っています。

I am getting help from chatGPT with a poor question.

- Golangで文字列を整数にするコード書いて

- Write code in Golang to turn strings into integers.

- Golangのコマンド引数のコードの書き方を教えて

- Tell me how to write code for command arguments in Golang.

- Golangでも文字列から"("と")"を取り除くコードを作って

- In Golang, create code to remove "(" and ")" from a string.

-----

というような、

Such as,

『ふざけるな! その程度のこと、自分で調べろ!!』

'Don't be silly! You'll have to find out that much on your own!'

と、先輩から怒鳴りつけられ、後輩に怒鳴りつけてきたことを、今の私は、平気で、生成AIに相談しています。

And now I am not afraid to talk to the generative AI about how I have been yelled at by my seniors and yelled at by my juniors.

2023,江端さんの忘備録

ロシアは酷い国だ、中国は酷い国だ、韓国は酷い国だ、北朝鮮は酷い国だ ―― と、ニュースを見るたびに、私たちは思います。

Russia is a terrible country; China is a terrible country; South Korea is a terrible country; North Korea is a terrible country -- every time we watch the news.

でも、私たちが思う程度と同じくらい、外国の国民は「日本は酷い国だ」と思っているはずなんです。

But to the same extent that we think, the people of foreign countries must believe that Japan is a terrible country.

『日本だけが清廉潔白な国』なんてことが、ある訳がない。

There is no such thing as "only Japan is a clean country.

『海外の「日本は酷い国だ」のニュース番組の特集』をやってくれないかな、と思うんですよね。

I wonder if someone could do a "special "Japan is a terrible country" news program of overseas.

視聴率は取れないだろうし、炎上の嵐になることは確実なのですが ―― でも、見たい。

I know they won't get any ratings, and it's sure to be a firestorm -- but I'd like to watch it.

-----

という話を嫁さんにしたら、

When I talked to my wife about this,

『海外の世論なんぞ気にしなくていいんじゃない?』

'Do we have to worry about public opinion outside the country?'

と言い切られました。

She said.

日本国に住む日本人は、『日本だけが清廉潔白な国』と思っていれば、それでいいじゃないか、と。

Japanese people living in Japan should be okay with that, as long as we think 'only Japan is a clean country.'

―― 実に清々しい

"How bracing!"

と、感動してしまいました。

I was moved to her.

未分類

JOSMを立ち上げる → osmファイルをドラッグする → 下の図の赤丸の部分をクリックする

下の図の赤丸をクリックする

カラムに、railway=subway と記入する

全部にチェックを入れる

こういう表示になる

ただ、この路線情報のみのセーブができていない
(未完)

未分類

鉄道路線の位置情報が欲しい場合

で、エディタに張りつける。

wkt_geom osm_id name highway waterway aerialway barrier man_made z_order other_tags
LineString (139.646476100000001 35.55342160000000007, 139.64405429999999342 35.55400130000000303, 139.64320960000000582 35.55409010000000336, 139.64267359999999485 35.55411110000000008, 139.64220109999999409 35.55405509999999936, 139.64194380000000706 35.55401379999999989, 139.64170240000001399 35.55397510000000239, 139.63902089999999134 35.55321440000000166, 139.63803740000000175 35.55292430000000081, 139.63748190000001159 35.55269659999999732, 139.63718030000001136 35.55254620000000187, 139.63689350000001355 35.55236419999999953, 139.63660690000000386 35.55215530000000257, 139.63493339999999421 35.55077779999999876, 139.63391659999999206 35.55019589999999852, 139.63362749999998869 35.55004329999999868, 139.63279969999999253 35.54961260000000323, 139.63221790000000055 35.54929349999999744, 139.63160369999999944 35.54899890000000084, 139.63125759999999786 35.54887020000000319, 139.63085000000000946 35.54871740000000102, 139.630045999999993 35.54843460000000022, 139.62955180000000155 35.54831149999999695, 139.62913320000001249 35.54824239999999946, 139.62852749999998991 35.54819439999999986, 139.62814629999999738 35.54818490000000253, 139.62771179999998594 35.54821979999999826, 139.62689000000000306 35.54832940000000008, 139.62461239999998952 35.54861619999999789, 139.6228170999999918 35.54887699999999739, 139.62208190000001196 35.54897940000000034, 139.621440199999995 35.54912439999999663, 139.62113059999998654 35.54921850000000205, 139.62073699999999121 35.54935820000000035, 139.62002659999998855 35.54965870000000194, 139.61967559999999366 35.54979120000000137, 139.61773930000001087 35.55062470000000019, 139.61604349999998931 35.55129320000000348, 139.61544639999999617 35.55153250000000043, 139.61400649999998791 35.55211620000000039, 139.61367699999999559 35.55227090000000345, 139.61328370000001087 35.55248559999999713, 139.61185470000000919 35.55324699999999893, 139.61138819999999328 35.55344060000000184, 139.61112099999999714 35.5535199999999989, 139.61089590000000271 35.55356050000000323, 139.61073719999998843 35.55360360000000242, 139.61040380000000027 35.55367590000000177, 139.60871710000000689 35.55388539999999864, 139.60811019999999871 35.55395479999999964, 139.60749329999998736 35.55399839999999756, 139.60640879999999697 35.55402310000000199, 139.60553089999999088 35.55406709999999748, 139.60464600000000246 35.55415109999999856, 139.604049300000014 35.55422970000000049, 139.60341280000000097 35.55433450000000306, 139.60273129999998787 35.55454660000000189, 139.60238100000000827 35.55471419999999938, 139.60221730000000662 35.55483360000000204, 139.60197869999998943 35.55500659999999868, 139.60174100000000408 35.55521579999999915, 139.60153339999999389 35.55542990000000003, 139.60133149999998636 35.55568569999999795, 139.60023530000000846 35.55735479999999882, 139.59981210000000829 35.55783720000000159, 139.59957539999999199 35.55808329999999984, 139.59932749999998691 35.55827450000000312, 139.59904430000000275 35.5584891999999968, 139.59858829999998875 35.55877279999999985, 139.597627899999992 35.55933660000000174, 139.59693609999999353 35.55972859999999969, 139.59623609999999871 35.56005269999999996, 139.59570759999999723 35.56026099999999701, 139.59530820000000517 35.56040039999999891, 139.59489759999999592 35.56054460000000006, 139.59435049999999023 35.56065370000000314, 139.59350760000000946 35.56081749999999886, 139.59251140000000646 35.56100130000000092, 139.59232270000001108 35.56102899999999778, 139.59212709999999902 35.5610691999999986, 139.59167899999999918 35.56116870000000318, 139.59126240000000507 35.5611801000000014, 139.5906812000000059 35.56112069999999648, 139.59032650000000331 35.56103509999999801, 139.5901608000000067 35.56098539999999986, 139.58982359999998835 35.56086419999999748, 139.58665070000000696 35.55936580000000191, 139.58363769999999704 35.55796550000000167, 139.58301539999999363 35.55764250000000004, 139.5822108000000128 35.55715810000000232, 139.58148120000001313 35.55673920000000265, 139.58096409999998855 35.55639310000000108, 139.58066579999999135 35.55618929999999978, 139.58024739999999042 35.55579379999999645, 139.57973240000001169 35.55525970000000058, 139.57922490000001403 35.55446140000000099) 230124642 讓ェ豬懷クょ霧蝨ー荳矩延?泌捷邱 -25 "colour"=>"#048D58","electrified"=>"contact_line","frequency"=>"0","layer"=>"-2","name:en"=>"Green Line of Yokohama Municipal Subway","name:es"=>"Lテュnea Verde del Metro Municipal de Yokohama","name:ja"=>"讓ェ豬懷クょ霧蝨ー荳矩延?泌捷邱?","name:zh"=>"讓ェ貊ィ蟶り是4蜿キ郤ソ","operator"=>"讓ェ豬懷ク?","railway"=>"subway","tunnel"=>"yes","voltage"=>"1500"

と、こんな感じで座標は得られる。