public class AddressSearch
extends com.supermap.data.InternalHandleDisposable
该类根据中文地址库数据创建地址索引,提供中文地址模糊匹配的方法。
中文地址模糊匹配的实现流程和注意事项:
public AddressMatchResults addressMatchResult() { //创建中文地址模糊匹配对象 AddressSearch addressSearch = new AddressSearch("D:/GeoCode/index"); //调用匹配方法 AddressMatchResults addressMatchResults = addressSearch.match("北京","超图大厦",10); //返回匹配结果 return addressMatchResults; }
构造器和说明 |
---|
AddressSearch()
地址匹配对象构建方法。
|
AddressSearch(String indexDirectory)
已过时。
此方法已废弃,请使用支持地址匹配参数设置类的新方法
AddressSearch.setSetting(AddressSearchSetting) 替换。 |
限定符和类型 | 方法和说明 |
---|---|
void |
dispose()
释放对象所占用的资源。
|
AddressMatchResults |
get(int resultCount,
int startPosition)
获取匹配结果的接口,和match方法结合使用。
|
PrjCoordSys |
getPrjCoordSys()
获取地址的投影信息。
|
AddressSearchSetting |
getSetting()
返回中文地址模糊匹配的参数设置对象。
|
static boolean |
isSupportReverse(String searchDirectory)
判断索引数据是否支持逆向匹配。
|
boolean |
isValidLowestGroupName(String value)
通过该方法可以判断
AddressSearchSetting 类设置的三级分组字段是否正确。 |
boolean |
isValidSecondaryGroupName(String value)
通过该方法可以判断
AddressSearchSetting 类设置的二级分组字段是否正确。 |
boolean |
isValidTopGroupName(String value)
通过该方法可以判断
AddressSearchSetting 类设置的一级分组字段是否正确。 |
int |
match(Geometry geometry,
double dDistance)
逆向地址匹配接口,和get方法结合使用。
|
AddressSearchResult |
match(Geometry geometry,
double dDistance,
AddressSearchSetting addressSearchSetting)
逆向地址匹配接口
该接口为多线程使用提供,只需加载一次索引文件。
|
int |
match(String searchAddress)
新的地址匹配接口,和get方法结合使用。
|
AddressSearchResult |
match(String searchAddress,
AddressSearchSetting addressSearchSetting)
地址匹配接口
该接口为多线程使用提供,只需加载一次索引文件。
|
AddressMatchResults |
match(String searchCity,
String searchAddress,
int resultCount)
已过时。
此方法已废弃,请使用支持地址匹配参数设置类的新方法
AddressSearch.match(String, AddressSearchSetting) 替换。 |
static void |
setIsDisposable(com.supermap.data.InternalHandleDisposable obj,
boolean disposable) |
void |
setSetting(AddressSearchSetting value)
设置中文地址模糊匹配的参数设置对象。
|
public AddressSearch()
@Deprecated public AddressSearch(String indexDirectory)
AddressSearch.setSetting(AddressSearchSetting)
替换。AddressLoad
类。indexDirectory
- 已经加载完的地址索引路径。public AddressSearchSetting getSetting()
AddressSearchSetting
类。public void setSetting(AddressSearchSetting value)
AddressSearchSetting
类。value
- 中文地址模糊匹配地址索引加载的参数设置对象。public void dispose()
@Deprecated public AddressMatchResults match(String searchCity, String searchAddress, int resultCount)
AddressSearch.match(String, AddressSearchSetting)
替换。searchCity
- 指定的要检索的地名地址所在的城市,该参数是进行AddressLoad
时加载的数据集中的City字段中的值。searchAddress
- 指定的要检索的地名地址。resultCount
- 指定一次返回的最优检索结果的数目。范围为1到10之间。public boolean isValidTopGroupName(String value)
AddressSearchSetting
类设置的一级分组字段是否正确。value
- 一级分组字段名称。public boolean isValidSecondaryGroupName(String value)
AddressSearchSetting
类设置的二级分组字段是否正确。value
- 二级分组字段名称。public boolean isValidLowestGroupName(String value)
AddressSearchSetting
类设置的三级分组字段是否正确。value
- 三级分组字段名称。public int match(String searchAddress)
searchAddress
- 指定的要检索的地名地址。注意事项:
AddressSearchSetting
;AddressLoad
类的新的 load(boolean) 接口生成的,不兼容老的废弃的load()接口;AddressSearchSetting
类设置分组字段名称,以实现更快和更准确的匹配。public AddressMatchResults addressMatchResultNew() { AddressSearchSetting searchSetting = new AddressSearchSetting(); searchSetting.setSearchDirectory("D:/GeoCode/index"); searchSetting.setMaxResultCount(100); searchSetting.setTopGroupName("四川"); searchSetting.setSecondaryGroupName("成都"); //searchSetting.setLowestGroupName(""); AddressSearch addressSearch = new AddressSearch(); addressSearch.setSetting(searchSetting); String query = "大学"; int matchCount = addressSearch.match(query); if (matchCount > 0) { //获取前十条匹配结果 AddressMatchResults addressMatchResults = addressSearch.get(10, 0); return addressMatchResults; } return null; }
public int match(Geometry geometry, double dDistance)
注意事项:
AddressSearchSetting
类;AddressLoad.load(boolean)
接口生成的,不兼容老的废弃的 AddressLoad.load()
接口;AddressLoadSetting.setLoadPoint
设置为 true),逆向地址匹配接口才能成功搜索。geometry
- 指定的点对象。dDistance
- 指定的搜索范围。public AddressMatchResults get(int resultCount, int startPosition)
resultCount
- 指定一次返回的最优检索结果的数目,最大不能超过match返回的匹配数目。startPosition
- 指定match获取结果的起始位置。AddressMatchResults
。public PrjCoordSys getPrjCoordSys()
public AddressSearchResult match(String searchAddress, AddressSearchSetting addressSearchSetting)
该接口为多线程使用提供,只需加载一次索引文件。
searchAddress
- 指定的要检索的地名地址。addressSearchSetting
- 中文地址模糊匹配参数设置对象。注意事项:
AddressSearchSetting
;AddressLoad
类的新的 load(boolean) 接口生成的,不兼容老的废弃的load()接口;AddressSearchSetting
类设置分组字段名称,以实现更快和更准确的匹配。public AddressMatchResults addressMatchResultNew() { AddressSearchSetting searchSetting = new AddressSearchSetting(); searchSetting.setSearchDirectory("D:/GeoCode/index"); AddressSearch addressSearch = new AddressSearch(); addressSearch.setSetting(searchSetting); AddressSearchSetting newsetting = new AddressSearchSetting(); newsetting.setMaxResultCount(100); newsetting.setTopGroupName("四川"); newsetting.setSecondaryGroupName("成都"); String query = "大学"; AddressSearchResult SearchResult = addressSearch.match(query,newsetting); if (SearchResult != null && SearchResult.getCount() > 0) { //获取前十条匹配结果 AddressMatchResults addressMatchResults = SearchResult.get(10, 0); return addressMatchResults; } return null; }
public AddressSearchResult match(Geometry geometry, double dDistance, AddressSearchSetting addressSearchSetting)
该接口为多线程使用提供,只需加载一次索引文件。
geometry
- 指定的点对象。dDistance
- 指定的搜索范围。addressSearchSetting
- 中文地址模糊匹配参数设置对象。注意事项:
AddressSearchSetting
;AddressLoad
类的新的 load(boolean) 接口生成的,不兼容老的废弃的load()接口;AddressSearchSetting
类设置分组字段名称,以实现更快和更准确的匹配。public AddressMatchResults addressMatchResultNew() { AddressSearchSetting searchSetting = new AddressSearchSetting(); searchSetting.setSearchDirectory("D:/GeoCode/index"); AddressSearch addressSearch = new AddressSearch(); addressSearch.setSetting(searchSetting); AddressSearchSetting newsetting = new AddressSearchSetting(); newsetting.setMaxResultCount(100); GeoPoint geopnt = new GeoPoint(new Point2D(1,1)); AddressSearchResult SearchResult = addressSearch.match(geopnt,0.1,newsetting); if (SearchResult != null && SearchResult.getCount() > 0) { //获取前十条匹配结果 AddressMatchResults addressMatchResults = SearchResult.get(10, 0); return addressMatchResults; } return null; }
public static boolean isSupportReverse(String searchDirectory)
searchDirectory
- [in] 索引数据目录public static void setIsDisposable(com.supermap.data.InternalHandleDisposable obj, boolean disposable)
Copyright © 2021–2024 SuperMap. All rights reserved.