- Forked from digital-go-jp/abr-geocoder
- Appended server code and dockerized
npm install
npm run build
node build/cli/cli.js download --dataDir path/to/abrg-data # takes about 500s
ABRG_DATADIR=path/to/abrg-data node build/server/index.js # listen on 8787
curl http://localhost:8787/geocode?q=東京都千代田区紀尾井町1-3
{
"result": {
"input": "東京都千代田区紀尾井町1-3",
"output": "東京都千代田区紀尾井町1-3",
"match_level": 8,
"lat": 35.679107172,
"lon": 139.736394597,
"other": "",
"prefecture": "東京都",
"city": "千代田区",
"town": "紀尾井町",
"town_id": "0056000",
"lg_code": "131016",
"block": "1",
"block_id": "001",
"addr1": "3",
"addr1_id": "003",
"addr2": "",
"addr2_id": ""
}
}or you can use Container Image
docker build . -t abrg-server # takes about 500s
docker run -p 8787:8787 abrg-serverAddress Base Registry Geocoder by Japan Digital Agency
- Assigns a town ID.
- Normalizes address strings.
- Outputs latitude and longitude pair with matched level.
This command requires node.js version 18 or above.
npm install @digital-go-jp/abr-geocoder
$ abrg download # Download data from the address base registry and create a database.
$ echo "東京都千代田区紀尾井町1-3 東京ガーデンテラス紀尾井町 19階、20階" | abrg -
Obtains the latest data from server.
$ abrg download
Downloads the public data from the address base registry "全アドレスデータ" into the $HOME/.abr-geocoder directory,
then creates a local database using SQLite.
To update the local database, runs abrg download.
Checks the new update data.
$ abrg update-check
Returns 0 if new data is available in CKAN or if no local database exists. In that case, runs download command.
Returns 1 if the local database is the latest.
Geocodes from the <inputFile>.
You can also specify - for stdin.
$ abrg <inputFile> [<outputFile>] [options]
-
<inputFile>-
case: Specifies a query file path: Geocodes from the
<inputFile>. The input file must have Japanese address each line.For example:
abrg ./sample.txt東京都千代田区紀尾井町1-3 東京都千代田区永田町1-10-1 ... 東京都千代田区永田町一丁目7番1号
-
case: Specifies
-: You can also pass the input query throughpipecommand.-denotesstdin.echo "東京都千代田区紀尾井町1-3 東京ガーデンテラス紀尾井町 19階、20階" | abrg -
-
-
<outputFile>Specifies the file path to save the output. If you ommit, the command prints out to stdout.For example:
abrg ./sample.txt ./output.json echo "東京都千代田区紀尾井町1-3" | abrg - ./output.json cat ./sample.txt | abrg - | jq -
-f,--formatSpecifies output format. Default is
json.format description csv Output results in comma-separated csv format. json Output results in json format. ndjson Output results in NDJSON. geojson Output results in GeoJSON format. ndgeojson Output results in NDGeoJSON format. -
--fuzzy- Specifies the character to be used as a wildcard. Default is `?``.
For example:
echo "東京都町?市森野2-2-22" | abrg - --fuzzy "?" -
-h,--helpDisplays this command usage.
[
{
"query": {
"input": "東京都千代田区紀尾井町1-3"
},
"result": {
"prefecture": "東京都",
"match_level": 8,
"city": "千代田区",
"town": "紀尾井町",
"town_id": "0056000",
"lg_code": "131016",
"other": "",
"lat": 35.679107172,
"lon": 139.736394597,
"block": "1",
"block_id": "001",
"addr1": "3",
"addr1_id": "003",
"addr2": "",
"addr2_id": ""
}
}
]
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
139.736394597,
35.679107172
]
},
"properties": {
"query": {
"input": "東京都千代田区紀尾井町1-3"
},
"result": {
"match_level": 8,
"prefecture": "東京都",
"city": "千代田区",
"town": "紀尾井町",
"town_id": "0056000",
"lg_code": "131016",
"other": "",
"block": "1",
"block_id": "001",
"addr1": "3",
"addr1_id": "003",
"addr2": "",
"addr2_id": ""
}
}
}
]
}
The level property denotes the address maching level.
| level | description |
|---|---|
| 0 | Could not detect at all. |
| 1 | Could detect only prefecture level. |
| 2 | Could detect prefecture and city levels. |
| 3 | Could detect prefecture, city, and a town ID. |
| 7 | Could detect prefecture, city, a town ID, and street name level. |
| 8 | Could detect prefecture, city, a town ID, street name, and extra information, such as suite number. |