Skip to content

Commit

Permalink
fix: 未初始化RegionEntity()的children属性 (#183)
Browse files Browse the repository at this point in the history
* fix: 未初始化RegionEntity()的children属性

本次修复问题 #182 对于一个空的dat字典文件,GeocodingX.addRegionEntry时,没有初始化RegionEntity()的children属性,导致下级的行政区划未能成功添加。

* feat: 增加自定义地址文件说明

修改README.md的1.3节自定义地址文件设置

---------

Co-authored-by: 何翀彬 <hecb@sucsoft.com>
  • Loading branch information
blvyoucan and 何翀彬 committed Jun 9, 2023
1 parent d07dc03 commit 1947d07
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Expand Up @@ -102,8 +102,14 @@ Address(
## 1.3 自定义地址文件设置

```kotlin
// 文件生成方式见下文
// 加载自定义地址文件
val geocoding = GeocodingX("region_2021.dat")

// 添加自定义区县"临平区"
geocoding.addRegionEntry(330113000000, 330100000000, "临平区", RegionType.District, "", true)

// 保存自定义字典文件
geocoding.save("xxx.dat")
```

## 1.4 自定义地址设置
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/bitlap/geocoding/GeocodingX.kt
Expand Up @@ -102,6 +102,8 @@ open class GeocodingX(val ctx: Context) {
region.name = name
region.alias = alias
region.type = type
// 暂时在这里初始化下级行政区划列表
region.children = arrayListOf()
// 1. Add to cache (id -> Region)
ctx.persister.addRegionEntity(region)
// 2. Build term index
Expand Down

0 comments on commit 1947d07

Please sign in to comment.