AddressNode クラス
住所要素ノードを表すクラスです。
ノードは名称(「東京都」や「新宿区」など)や経緯度などの 属性情報と、親ノードや子ノード集合へのリンクを持ちます。
- class jageocoder.node.AddressNode(*args, **kwargs)
The address-node structure stored in 'node' table.
- priority
Priority assigned to each source of data. Smaller value indicates higher priority.
- Type:
- note
Note or comment.
- Type:
string
- children
The child nodes.
- Type:
list of AddressNode
- dataset
- Type:
source dataset where the node come from.
- __init__(*args, **kwargs)
The initializer of the node.
In addition to the initialization of the record, the name_index is also created.
- add_child(child)
Add a node as a child of this node.
- パラメータ:
child (AddressNode) -- The node that will be a child node.
- add_to_parent(parent)
Add this node as a child of an other node.
- パラメータ:
parent (AddressNode) -- The node that will be the parent.
- as_dict()
Return the dict notation of the node.
- as_geojson()
Return the geojson notation of the node.
- get_aza_code() str
Returns the 'AZA-code' concatinated with the city-code and the aza-id containing this node.
- get_aza_names() list
Returns representation of Aza node containing this node.
- 戻り値:
A list containing notations from the prefecture level to the Aza level in the following format:
[AddressLevel, Kanji, Kana, English, code]
- 戻り値の型:
- get_child(target_name: str)
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_fullname()
Returns a complete address notation starting with the name of the prefecture.
- get_googlemap_link() str
Returns the URL for GSI Map with parameters. ex. https://maps.google.com/maps?q=24.197611,120.780512&z=18
- get_gsimap_link() str
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(index: str, tree: AddressTree, processed_nodes: List['AddressNode']) str
Obtains an optional leading substring from the search string index.
- パラメータ:
index (str) -- Target string.
tree (AddressTree) -- Current working tree object.
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.
- 戻り値の型:
メモ
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_list()
Returns a complete node list starting with the prefecture.
- get_pref_local_authority_code() str
Returns the 地方公共団体コード of the 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.
- 戻り値の型:
メモ
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_recursive(index: str, tree: AddressTree, processed_nodes: Optional[List['AddressNode']] = None) List[Result]
Search nodes recursively that match the specified address notation.
- パラメータ:
index (str) -- The standardized address notation.
processed_nodes (List of AddressNode, optional) -- List of nodes that have already been processed by TRIE search results
- 戻り値の型:
A list of relevant AddressNode.
- set_attributes(**kwargs)
Set attributes of this node by kwargs values. 'name' can't be modified.