AddressNode クラス

住所要素ノードを表すクラスです。

ノードは名称(「東京都」や「新宿区」など)や経緯度などの 属性情報と、親ノードや子ノード集合へのリンクを持ちます。

class jageocoder.node.AddressNode(id: Optional[int] = None, name: Optional[str] = None, name_index: Optional[str] = None, x: Optional[float] = None, y: Optional[float] = None, level: Optional[int] = None, priority: Optional[int] = None, note: Optional[str] = None, parent_id: Optional[int] = None, sibling_id: Optional[int] = None)

The address node stored in 'address_node' table.

パラメータ:
  • id (int) -- The key identifier that is automatically sequentially numbered.

  • name (str) -- The name of the address element, such as '東京都' or '新宿区'

  • x (float) -- X-coordinate value. (Longitude)

  • y (float) -- Y-coordinate value. (Latitude)

  • level (int) -- The level of the address element. The meaning of each value is as follows.

  • priority (int) -- Priority assigned to each source of data. Smaller value indicates higher priority.

  • note (string) -- Note or comment.

  • parent_id (int) -- The id of the parent node.

  • sibling_id (int) -- The id of the next sibling node.

name_index

The standardized string for indexing created from its name.

Type:

str

__init__(id: Optional[int] = None, name: Optional[str] = None, name_index: Optional[str] = None, x: Optional[float] = None, y: Optional[float] = None, level: Optional[int] = None, priority: Optional[int] = None, note: Optional[str] = None, parent_id: Optional[int] = None, sibling_id: Optional[int] = None) None

The initializer of the node.

In addition to the initialization of the record, the name_index is also created.

as_dict()

Return the dict notation of the node.

as_geojson()

Return the geojson notation of the node.

property dataset

Get dataset record.

classmethod from_record(record) AddressNode

East: 153°59'12″ West: 122°55'57″ South: 20°25'31″ North: 45°33'26″

get_aza_code() str

Returns the 'AZA-code' concatinated with the city-code and the aza-id containing this node.

get_aza_id() str

Returns the AZA-id defined by JDA address-base-registry containing this node.

get_aza_names(tree: AddressTree) list

Returns representation of Aza node containing this node.

パラメータ:

tree (AddressTree) -- The tree containing this node.

戻り値:

A list containing notations from the prefecture level to the Aza level in the following format:

[AddressLevel, Kanji, Kana, English, code]

戻り値の型:

list

get_child(target_name: str) AddressNode

Get a child node with the specified name.

パラメータ:

target_name (str) -- The name (or standardized name) of the target node.

戻り値:

  • Returns the relevand node if it is found,

  • or None if it is not.

get_children() List[AddressNode]

Get all children of the node.

戻り値の型:

List[AddressNode]

get_city_jiscode() str

Returns the jisx0402 code of the city that contains this node.

get_city_local_authority_code() str

Returns the 地方公共団体コード of the city that contains this node.

get_city_name() str

Returns the name of city that contains this node.

get_fullname(delimiter: Optional[str] = None)

Returns a complete address notation starting with the name of the prefecture.

パラメータ:

delimiter (str, optional) -- Specifies the delimiter character for the address element; If None is specified, returns a list of elements.

Returns the URL for GSI Map with parameters. ex. https://maps.google.com/maps?q=24.197611,120.780512&z=18

Returns the URL for GSI Map with parameters. ex. https://maps.gsi.go.jp/#13/35.713556/139.750385/

get_nodes_by_level()

The function returns an array of this node and its upper nodes. The Nth node of the array contains the node corresponding to address level N. If there is no element corresponding to level N, None is stored.

サンプル

>>> import jageocoder
>>> jageocoder.init()
>>> node = jageocoder.searchNode('多摩市落合1-15')[0][0]
>>> [str(x) for x in node.get_node_array_by_level()]
['None', '[11460206:東京都(139.69164,35.6895)1(jisx0401:13)]', 'None', '[12063501:多摩市(139.446366,35.636959)3(jisx0402:13224)]', 'None',
                        '[12065382:落合(139.427097,35.624877)5(None)]', '[12065383:一丁目(139.427097,35.624877)6(None)]', '[12065389:15番地(139.428969,35.625779)7(None)]']
get_omissible_index(tree: AddressTree, index: str, processed_nodes: List[AddressNode]) str

Obtains an optional leading substring from the search string index.

パラメータ:
  • tree (AddressTree) -- The tree containing this node.

  • index (str) -- Target string.

  • processed_nodes (List of AddressNode) -- List of nodes that have already been processed by TRIE search results.

戻り値:

The optional leading substring. If not omissible, an empty string is returned.

戻り値の型:

str

メモ

  • Retrieve the lower address elements of this node that have start_count_type is 1 from the aza_master.

  • If the name of the element is contained in the index, the substring before the name is returned.

get_parent() Optional[AddressNode]

Get the parent node.

戻り値:

The parent.

戻り値の型:

AddressNode

メモ

  • Returns None if the current node is directly under the root node.

get_parent_list()

Returns a complete node list starting with the prefecture.

get_postcode() str

Returns the 7digit postcode of the oaza that contains this node.

get_pref_jiscode() str

Returns the jisx0401 code of the prefecture that contains this node.

get_pref_local_authority_code() str

Returns the 地方公共団体コード of the prefecture that contains this node.

get_pref_name() str

Returns the name of prefecture that contains this node.

is_inside(area: str) int

Check if the node is inside the area specified by parent's names or jiscodes.

パラメータ:

area (str) -- Specify the area by name or jiscode.

戻り値:

It returns 1 if the node is inside the region, 0 if it is not inside, and -1 if it cannot be determined by this node.

戻り値の型:

int

メモ

If a city code is specified and the node is at the prefecture level, it will return 0 if the first two digits of the code do not match, otherwise it will return -1.

retrieve_upper_node(target_levels: List[int])

Retrieves the node at the specified level from the this node or one of its upper nodes.

save_recursive(session)

Add the node to the database recursively.

パラメータ:

session (sqlalchemy.orm.Session) -- The database session for executing SQL queries.

search_child_with_criteria(pattern: str, min_candidate: Optional[str] = None, gt_candidate: Optional[str] = None, max_level: Optional[int] = None, require_coordinates: bool = False)

Search for children nodes that satisfy the specified conditions.

パラメータ:
  • pattern (str) -- The regular expression that the child node's name must match.

  • min_candidate (str, optional) -- The smallest string that satisfies the condition as the name of a child node.

  • gt_candidate (str, optional) -- The smallest string that exceeds the upper limit that satisfies the condition as the name of a child node.

  • max_level (int, optional) -- Maximum level of child nodes; unlimited if None.

  • require_coordinates (bool [False]) -- If set to True, the child node must have valid coordinates.

search_recursive(tree: AddressTree, index: str, processed_nodes: Optional[List[int]] = None) List[Result]

Search nodes recursively that match the specified address notation.

パラメータ:
  • tree (AddressTree) -- The tree containing this node.

  • index (str) -- The standardized address notation.

  • processed_nodes (List of the AddressNode's id, optional) -- List of node's id that have already been processed by TRIE search results.

戻り値:

List of relevant AddressNode.

戻り値の型:

List[AddressNode]

set_attributes(**kwargs)

Set attributes of this node by kwargs values. 'name' can't be modified.