addressGeocoding

説明

住所文字列をジオコーディングした結果を返す。

文法

object geonlp.addressGeocoding (string address [, object options])

object geonlp.addressGeocoding (string[] addresses [, object options])

リクエストパラメータ

address
  • 住所文字列
addresses
  • 住所文字列の配列
options
  • 結果の詳細度を指定するためのオプション( geocoding オプション)
  • オプションの詳細は parse オプション を参照

リクエストの例

{
  "method": "geonlp.addressGeocoding",
  "params": ["千代田区一ツ橋2-1-2", {"geocoding":full}],
  "id": "9"
}

レスポンス

住所文字列をジオコーディングして得られた住所の情報。

リクエストが配列の場合、それぞれをジオコーディングした住所情報の配列。

レスポンスの例

{
  "error":null,
  "id":9,
  "result":{
    "geometry":{
      "coordinates":[
        139.758606,
        35.691406
      ],
      "type":"Point"
    },
    "properties":{
      "address":[
        {
          "geonlp_id":"ALRYpP",
          "geoword":{
            "address":"新宿区西新宿2-8-1",
            "body":"東京",
            "body_kana":"トウキョウ",
            "code":{
              "jisx0401":"13",
              "lasdec":"130001"
            },
            "dictionary_id":28,
            "entry_id":"13",
            "fullname":"東京都",
            "geonlp_id":"ALRYpP",
            "latitude":"35.6895",
            "longitude":"139.69164",
            "ne_class":"都道府県",
            "phone":"03-5321-1111",
            "suffix":[
              "都",
              ""
            ],
            "suffix_kana":[
              "ト",
              ""
            ]
          },
          "latitude":35.693932,
          "level":1,
          "longitude":139.753540,
          "name":"東京都"
        },
        {
          "geonlp_id":"51sMnl",
          "geoword":{
            "address":"千代田区九段南1−2−1",
            "body":"千代田",
            "body_kana":"チヨダ",
            "code":{
              "jisx0402":"13101",
              "lasdec":"131016"
            },
            "dictionary_id":29,
            "entry_id":"13101",
            "fullname":"千代田区",
            "geonlp_id":"51sMnl",
            "hypernym":[
              "東京都"
            ],
            "latitude":"35.69393",
            "longitude":"139.75354",
            "ne_class":"市区町村/特別区",
            "suffix":[
              "区",
              ""
            ],
            "suffix_kana":[
              "ク",
              ""
            ],
            "tel":"03-3264-2111"
          },
          "latitude":35.693932,
          "level":3,
          "longitude":139.753540,
          "name":"千代田区"
        },
        {
          "geonlp_id":"8G80mm",
          "geoword":{
            "body":"一ツ橋",
            "code":{
              "isj":"131010001999"
            },
            "dictionary_id":30,
            "entry_id":"131010001999",
            "geonlp_id":"8G80mm",
            "hypernym":[
              "千代田区"
            ],
            "latitude":"35.691634",
            "longitude":"139.756685",
            "ne_class":"居住地名/大字",
            "note":"原表記「一ツ橋一丁目」より生成",
            "prefix":[
              
            ],
            "suffix":[
              
            ]
          },
          "latitude":35.691635,
          "level":5,
          "longitude":139.756683,
          "name":"一ツ橋"
        },
        {
          "latitude":35.692947,
          "level":6,
          "longitude":139.757324,
          "name":"二丁目"
        },
        {
          "latitude":35.691406,
          "level":7,
          "longitude":139.758606,
          "name":"1番"
        }
      ],
      "code":{
        "isj":"131010001999",
        "jisx0401":"13",
        "jisx0402":"13101",
        "lasdec":"131016"
      },
      "name":"東京都千代田区一ツ橋二丁目1番",
      "standard_form":"東京都千代田区一ツ橋二丁目1番"
    },
    "type":"Feature"
  }
}

PHP サンプルコード

jsonrpc_client.php

ダウンロード

<?php

$apikey = ""; // <-- input your API key

function jsonrpc_exec($json_request) {
  global $apikey;
  if ($apikey == '') throw new Exception("Please submit the API key from the GeoNLP site (https://geonlp.ex.nii.ac.jp)");

  $endpoint = "https://dias.ex.nii.ac.jp/geonlp/api/1/geo-tagging";
  $header  = array("Content-Type: application/json",
                   "X-GeoNLP-Authorization: {$apikey}",
                   "Content-Length: ".strlen($json_request));
  $options = array('http' => array('method' => 'POST', 'header' => implode("\r\n", $header), 'content' => $json_request));
  $content = file_get_contents($endpoint, false, stream_context_create($options));
  $result = var_export(json_decode($content, true), true);
  return $result;
}

addressGeocoding.php

ダウンロード

<?php
require_once('jsonrpc_client.php');

$request = array(
  'method'=>'geonlp.addressGeocoding',
  'params'=>array("千代田区一ツ橋2-1-2",
    array("geocoding"=>"full")),
  'id'=>9);

$result = jsonrpc_exec(json_encode($request));
print_r($result);

実行結果

$ php addressGeocoding.php
Array
(
    [error] => 
    [id] => 9
    [result] => Array
        (
            [geometry] => Array
                (
                    [coordinates] => Array
                        (
                            [0] => 139.758606
                            [1] => 35.691406
                        )

                    [type] => Point
                )

            [properties] => Array
                (
                    [address] => Array
                        (
                            [0] => Array
                                (
                                    [geonlp_id] => ALRYpP
                                    [geoword] => Array
                                        (
                                            [address] => 新宿区西新宿2-8-1
                                            [body] => 東京
                                            [body_kana] => トウキョウ
                                            [code] => Array
                                                (
                                                    [jisx0401] => 13
                                                    [lasdec] => 130001
                                                )

                                            [dictionary_id] => 28
                                            [entry_id] => 13
                                            [fullname] => 東京都
                                            [geonlp_id] => ALRYpP
                                            [latitude] => 35.6895
                                            [longitude] => 139.69164
                                            [ne_class] => 都道府県
                                            [phone] => 03-5321-1111
                                            [suffix] => Array
                                                (
                                                    [0] => 都
                                                    [1] => 
                                                )

                                            [suffix_kana] => Array
                                                (
                                                    [0] => ト
                                                    [1] => 
                                                )

                                        )

                                    [latitude] => 35.693932
                                    [level] => 1
                                    [longitude] => 139.75354
                                    [name] => 東京都
                                )

                            [1] => Array
                                (
                                    [geonlp_id] => 51sMnl
                                    [geoword] => Array
                                        (
                                            [address] => 千代田区九段南1−2−1
                                            [body] => 千代田
                                            [body_kana] => チヨダ
                                            [code] => Array
                                                (
                                                    [jisx0402] => 13101
                                                    [lasdec] => 131016
                                                )

                                            [dictionary_id] => 29
                                            [entry_id] => 13101
                                            [fullname] => 千代田区
                                            [geonlp_id] => 51sMnl
                                            [hypernym] => Array
                                                (
                                                    [0] => 東京都
                                                )

                                            [latitude] => 35.69393
                                            [longitude] => 139.75354
                                            [ne_class] => 市区町村/特別区
                                            [suffix] => Array
                                                (
                                                    [0] => 区
                                                    [1] => 
                                                )

                                            [suffix_kana] => Array
                                                (
                                                    [0] => ク
                                                    [1] => 
                                                )

                                            [tel] => 03-3264-2111
                                        )

                                    [latitude] => 35.693932
                                    [level] => 3
                                    [longitude] => 139.75354
                                    [name] => 千代田区
                                )

                            [2] => Array
                                (
                                    [geonlp_id] => 8G80mm
                                    [geoword] => Array
                                        (
                                            [body] => 一ツ橋
                                            [code] => Array
                                                (
                                                    [isj] => 131010001999
                                                )

                                            [dictionary_id] => 30
                                            [entry_id] => 131010001999
                                            [geonlp_id] => 8G80mm
                                            [hypernym] => Array
                                                (
                                                    [0] => 千代田区
                                                )

                                            [latitude] => 35.691634
                                            [longitude] => 139.756685
                                            [ne_class] => 居住地名/大字
                                            [note] => 原表記「一ツ橋一丁目」より生成
                                            [prefix] => Array
                                                (
                                                )

                                            [suffix] => Array
                                                (
                                                )

                                        )

                                    [latitude] => 35.691635
                                    [level] => 5
                                    [longitude] => 139.756683
                                    [name] => 一ツ橋
                                )

                            [3] => Array
                                (
                                    [latitude] => 35.692947
                                    [level] => 6
                                    [longitude] => 139.757324
                                    [name] => 二丁目
                                )

                            [4] => Array
                                (
                                    [latitude] => 35.691406
                                    [level] => 7
                                    [longitude] => 139.758606
                                    [name] => 1番
                                )

                        )

                    [code] => Array
                        (
                            [isj] => 131010001999
                            [jisx0401] => 13
                            [jisx0402] => 13101
                            [lasdec] => 131016
                        )

                    [name] => 東京都千代田区一ツ橋二丁目1番
                    [standard_form] => 東京都千代田区一ツ橋二丁目1番
                )

            [type] => Feature
        )

)