com.supermap.analyst.addressmatching

类 AddressLoad



  • public class AddressLoad
    extends Object
    新的地址加载和匹配相分离的中文地址模糊匹配地址索引加载类。

    该类主要负责对中文地址库数据创建地址索引。以配合中文地址模糊匹配类AddressSearch进行地址的模糊查询。

    中文地址模糊匹配地址索引加载流程和注意事项:

    1. 中文地址模糊匹配地址索引加载的相关设置,主要通过 AddressLoad 类的 setSetting() 方法设置,包括使用的地址词典、数据集、字段、索引目录等;
    2. 加载中文地址模糊匹配的相关设置,在完成中文地址模糊匹配的设置之后,要使用 AddressLoad 类的 load() 方法加载设置,才会使所做的设置生效,在加载的过程中,系统将对参与分析的数据集中指定的参与匹配的字段中的内容建立索引,同时对其进行分词,即将这些字段中存储的内容切分成有意义的词,这一过程是基于用户传入的地址词典进行的;
    3. 中文地址数据库数据要求除包含指定的多个地址字段外,还需包含有省市区的信息,以此实现精确匹配和快速匹配;
    4. 中文地址数据库数据库所有数据集统一设置字段,可以设置一个或多个。
    示范代码:
    以下代码示范如何对中文地址库数据创建地址索引。
       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

        public AddressLoad()
        默认构造函数,构造一个新的AddressLoad对象
    • 方法详细资料

      • getSetting

        public AddressLoadSetting getSetting()
        返回中文地址模糊匹配地址索引加载的参数设置对象。有关详情,请参见 AddressLoadSetting 类。
        返回:
        中文地址模糊匹配地址索引加载的参数设置对象。
      • setSetting

        public void setSetting(AddressLoadSetting value)
        设置中文地址模糊匹配地址索引加载的参数设置对象。通过该方法可以设置地址匹配所使用的地址词典、参与地址匹配的数据集、参与匹配的字段以及加载结过索引的地址,有关详情,请参见 AddressLoadSetting 类。
        参数:
        value - 中文地址模糊匹配地址索引加载的参数设置对象。
      • load

        @Deprecated
        public boolean load()
        已过时。 此方法已废弃,请使用支持追加地址索引的新方法 AddressLoad.load(boolean) 替换。
        进行中文地址模糊匹配地址索引加载。
        返回:
        如果载入成功,返回值为 true,否则为 false。
      • load

        public boolean load(boolean isAppend)
        新的中文地址模糊匹配地址索引加载方法,支持在原有索引上追加数据。
        参数:
        isAppend - 当前加载是否是追加新的数据。
        返回:
        如果载入成功,返回值为 true,否则为 false。

        注意事项:

        1. 该加载接口不兼容老的load()接口,故不可混用;
        2. 该加载接口调用之前,也要通过 AddressLoad 类的 setSetting(AddressLoadSetting value) 方法设置地址词典、数据集、字段、索引目录等参数,另外还可设置分组字段;
        3. 该加载接口不要求数据必须包含有省市区的信息,但由AddressLoadSetting指定的不同级别分组字段必须存在;
        4. 该加载接口指定isAppend为true时,即追加新的数据时要求新的属性表结构与已加载数据的属性表结构相同。
        示范代码:
        以下代码示范如何通过该加载接口对中文地址库数据创建地址索引。
           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);
                 }
         
      • addSteppedListener

        public void addSteppedListener(SteppedListener l)
        添加一个进度条事件(SteppedEvent)的监听器。
        参数:
        l - 一个用于接收进度条事件的监听器。
      • removeSteppedListener

        public void removeSteppedListener(SteppedListener l)
        移除一个进度条事件(SteppedEvent)的监听器。
        参数:
        l - 一个用于接收进度条事件的监听器。

Copyright © 2021–2024 SuperMap. All rights reserved.