public class AddressLoad extends Object
该类主要负责对中文地址库数据创建地址索引。以配合中文地址模糊匹配类AddressSearch
进行地址的模糊查询。
中文地址模糊匹配地址索引加载流程和注意事项:
AddressLoad
类的 setSetting()
方法设置,包括使用的地址词典、数据集、字段、索引目录等;AddressLoad
类的 load()
方法加载设置,才会使所做的设置生效,在加载的过程中,系统将对参与分析的数据集中指定的参与匹配的字段中的内容建立索引,同时对其进行分词,即将这些字段中存储的内容切分成有意义的词,这一过程是基于用户传入的地址词典进行的;public void AddressLoadExample() { DatasourceConnectionInfo connectionInfo_udb = new DatasourceConnectionInfo(); connectionInfo_udb.setEngineType(EngineType.UDB); connectionInfo_udb.setServer("D:/GeoCode/china.udb"); Workspace workspace = new Workspace(); Datasource datasource = workspace.getDatasources().open(connectionInfo_udb); //参数设置 AddressLoadSetting addressLoadSetting = new AddressLoadSetting(); Datasets datasets = datasource.getDatasets(); for(int j = 0; j < datasets.getCount();j++){ Dataset dataset = datasets.get(j); addressLoadSetting.addDataset((DatasetVector)dataset); } addressLoadSetting.addIndexField("ADDRESS"); addressLoadSetting.addIndexField("NAME"); try { addressLoadSetting.setDictionaryFile("D:/GeoCode/mydic.dct"); } catch (FileNotFoundException e) { e.printStackTrace(); } addressLoadSetting.setLoadDirectory("D:/GeoCode/index"); //设置参数类加载 AddressLoad addressLoad = new AddressLoad(); addressLoad.setSetting(addressLoadSetting); addressLoad.load(false); }
构造器和说明 |
---|
AddressLoad()
默认构造函数,构造一个新的AddressLoad对象
|
限定符和类型 | 方法和说明 |
---|---|
void |
addSteppedListener(SteppedListener l)
添加一个进度条事件(
SteppedEvent )的监听器。 |
AddressLoadSetting |
getSetting()
返回中文地址模糊匹配地址索引加载的参数设置对象。
|
boolean |
load()
已过时。
此方法已废弃,请使用支持追加地址索引的新方法
AddressLoad.load(boolean) 替换。 |
boolean |
load(boolean isAppend)
新的中文地址模糊匹配地址索引加载方法,支持在原有索引上追加数据。
|
void |
removeSteppedListener(SteppedListener l)
移除一个进度条事件(
SteppedEvent )的监听器。 |
void |
setSetting(AddressLoadSetting value)
设置中文地址模糊匹配地址索引加载的参数设置对象。
|
public AddressLoadSetting getSetting()
AddressLoadSetting
类。public void setSetting(AddressLoadSetting value)
AddressLoadSetting
类。value
- 中文地址模糊匹配地址索引加载的参数设置对象。@Deprecated public boolean load()
AddressLoad.load(boolean)
替换。public boolean load(boolean isAppend)
isAppend
- 当前加载是否是追加新的数据。注意事项:
AddressLoad
类的 setSetting(AddressLoadSetting value)
方法设置地址词典、数据集、字段、索引目录等参数,另外还可设置分组字段;public void AddressLoadExampleNew() { DatasourceConnectionInfo connectionInfo_udb = new DatasourceConnectionInfo(); connectionInfo_udb.setEngineType(EngineType.UDB); connectionInfo_udb.setServer("D:/GeoCode/china.udb"); Workspace workspace = new Workspace(); Datasource datasource = workspace.getDatasources().open(connectionInfo_udb); //参数设置 AddressLoadSetting addressLoadSetting = new AddressLoadSetting(); Datasets datasets = datasource.getDatasets(); for(int j = 0; j < datasets.getCount();j++){ Dataset dataset = datasets.get(j); addressLoadSetting.addDataset((DatasetVector)dataset); } addressLoadSetting.addIndexField("ADDRESS"); addressLoadSetting.addIndexField("NAME"); addressLoadSetting.addSaveField("EN_NAME"); addressLoadSetting.setTopGroupField("province"); addressLoadSetting.setSecondaryGroupField("city"); addressLoadSetting.setLowestGroupField("county"); try { addressLoadSetting.setDictionaryFile("D:/GeoCode/mydic.dct"); } catch (FileNotFoundException e) { e.printStackTrace(); } addressLoadSetting.setLoadDirectory("D:/GeoCode/index"); //设置参数类加载 AddressLoad addressLoad = new AddressLoad(); addressLoad.setSetting(addressLoadSetting); addressLoad.load(false); //追加数据到已有索引 AddressLoadSetting addressAppendSetting = new AddressLoadSetting(); //追加的新数据 Dataset datasetNew = datasets.get("new"); addressAppendSetting.addDataset((DatasetVector)datasetNew); //addressAppendSetting.add.. //与已加载的数据要有相同的分组字段 addressAppendSetting.setTopGroupField("province"); addressAppendSetting.setSecondaryGroupField("city"); addressAppendSetting.setLowestGroupField("county"); addressLoad.setSetting(addressAppendSetting); addressLoad.load(true); }
public void addSteppedListener(SteppedListener l)
SteppedEvent
)的监听器。l
- 一个用于接收进度条事件的监听器。public void removeSteppedListener(SteppedListener l)
SteppedEvent
)的监听器。l
- 一个用于接收进度条事件的监听器。Copyright © 2021–2024 SuperMap. All rights reserved.