com.supermap.analyst.addressmatching
类 AddressSearch

java.lang.Object
  继承者 com.supermap.analyst.addressmatching.AddressSearch

public class AddressSearch
extends java.lang.Object

新的地址加载和匹配相分离的中文地址模糊匹配类。

该类根据中文地址库数据创建地址索引,提供中文地址模糊匹配的方法。

中文地址模糊匹配的实现流程和注意事项:

  1. 指定中文地址库数据创建的地址索引的目录,创建一个中文地址匹配对象;
  2. 调用match对象,指定要搜索的地址所在城市,必须是中文地址数据库中市级字段中的值,再指定要搜索的中文地址和返回个数;
  3. 系统对待匹配的关键字进行分词,然后去匹配指定数据集中指定字段中的内容,通过一定的运算,返回匹配的结果。

示例:
以下代码示范如何进行中文地址模糊匹配。
         public AddressMatchResults addressMatchResult() 
         {
                //创建中文地址模糊匹配对象
                AddressSearch addressSearch = new AddressSearch("D:/GeoCode/index");
                //调用匹配方法
                AddressMatchResults addressMatchResults = addressSearch.match("北京","超图大厦",10);
                //返回匹配结果
                return addressMatchResults;     
         }
 

构造方法摘要
AddressSearch()
          地址匹配对象构建方法。
AddressSearch(java.lang.String indexDirectory)
          已过时。  
 
方法摘要
 void dispose()
          释放对象所占用的资源。
 AddressMatchResults get(int resultCount, int startPosition)
          获取匹配结果的接口,和match方法结合使用。
 AddressSearchSetting getSetting()
          返回中文地址模糊匹配的参数设置对象。
static boolean isSupportReverse(java.lang.String searchDirectory)
          判断索引数据是否支持逆向匹配。
 boolean isValidLowestGroupName(java.lang.String value)
          通过该方法可以判断 AddressSearchSetting 类设置的三级分组字段是否正确。
 boolean isValidSecondaryGroupName(java.lang.String value)
          通过该方法可以判断 AddressSearchSetting 类设置的二级分组字段是否正确。
 boolean isValidTopGroupName(java.lang.String value)
          通过该方法可以判断 AddressSearchSetting 类设置的一级分组字段是否正确。
 int match(Geometry geometry, double dDistance)
          逆向地址匹配接口,和get方法结合使用。
 AddressSearchResult match(Geometry geometry, double dDistance, AddressSearchSetting addressSearchSetting)
          逆向地址匹配接口 该接口为多线程使用提供,只需加载一次索引文件。
 int match(java.lang.String searchAddress)
          新的地址匹配接口,和get方法结合使用。
 AddressSearchResult match(java.lang.String searchAddress, AddressSearchSetting addressSearchSetting)
          地址匹配接口 该接口为多线程使用提供,只需加载一次索引文件。
 AddressMatchResults match(java.lang.String searchCity, java.lang.String searchAddress, int resultCount)
          已过时。  
 void setSetting(AddressSearchSetting value)
          设置中文地址模糊匹配的参数设置对象。
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

AddressSearch

public AddressSearch(java.lang.String indexDirectory)
已过时。 

新的地址加载和匹配相分离的地址匹配对象构建方法,需要指定已经加载的地址索引路径。有关新的加载地址索引的更多信息,请参见 AddressLoad 类。

参数:
indexDirectory - 已经加载完的地址索引路径。

AddressSearch

public AddressSearch()
地址匹配对象构建方法。

方法详细信息

dispose

public void dispose()
释放对象所占用的资源。调用该方法之后,此对象不再可用。


match

public AddressMatchResults match(java.lang.String searchCity,
                                 java.lang.String searchAddress,
                                 int resultCount)
已过时。 

新的地址加载和匹配相分离的地址匹配方法。

参数:
searchCity - 指定的要检索的地名地址所在的城市,该参数应该是进行AddressLoad时加载的数据集中的City字段中的值。
searchAddress - 指定的要检索的地名地址。
resultCount - 指定一次返回的最优检索结果的数目。范围为1到10之间。
返回:
中文地址模糊匹配结果集合对象。

getSetting

public AddressSearchSetting getSetting()
返回中文地址模糊匹配的参数设置对象。有关详情,请参见 AddressSearchSetting 类。

返回:
中文地址模糊匹配的参数设置对象。

setSetting

public void setSetting(AddressSearchSetting value)
设置中文地址模糊匹配的参数设置对象。通过该方法可以设置地址匹配所使用的搜索路径,搜索结果数目,搜索组别等信息,有关详情,请参见 AddressSearchSetting 类。

参数:
value - 中文地址模糊匹配地址索引加载的参数设置对象。

isValidTopGroupName

public boolean isValidTopGroupName(java.lang.String value)
通过该方法可以判断 AddressSearchSetting 类设置的一级分组字段是否正确。

参数:
value - 一级分组字段名称。

isValidSecondaryGroupName

public boolean isValidSecondaryGroupName(java.lang.String value)
通过该方法可以判断 AddressSearchSetting 类设置的二级分组字段是否正确。

参数:
value - 二级分组字段名称。

isValidLowestGroupName

public boolean isValidLowestGroupName(java.lang.String value)
通过该方法可以判断 AddressSearchSetting 类设置的三级分组字段是否正确。

参数:
value - 三级分组字段名称。

match

public int match(java.lang.String searchAddress)
新的地址匹配接口,和get方法结合使用。

参数:
searchAddress - 指定的要检索的地名地址。
返回:
结果匹配的数目。

注意事项:

  1. 使用接口前,需要先通过AddressSearchSetting对象设置相关参数,详情参见 AddressSearchSetting
  2. 该接口使用的地址索引数据只能是 AddressLoad 类的新的 load(boolean) 接口生成的,不兼容老的废弃的load()接口;
  3. 使用接口前,如果加载数据时使用了分组字段,建议通过 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;    
                 }
 

get

public AddressMatchResults get(int resultCount,
                               int startPosition)
获取匹配结果的接口,和match方法结合使用。

参数:
resultCount - 指定一次返回的最优检索结果的数目,最大不能超过match返回的匹配数目。
startPosition - 指定match获取结果的起始位置。
返回:
中文地址模糊匹配结果集合对象, 详情参见 AddressMatchResults

match

public int match(Geometry geometry,
                 double dDistance)
逆向地址匹配接口,和get方法结合使用。

注意事项:

  1. 使用接口前,需要先通过AddressSearchSetting对象设置相关参数,详情参见 AddressSearchSetting 类;
  2. 该接口使用的地址索引数据只能是 AddressLoad 类的新的 AddressLoad.load(boolean) 接口生成的,不兼容老的废弃的 AddressLoad.load()接口;
  3. 创建索引数据时,需要设置生成逆向地址匹配索引数据(即AddressLoadSetting.setLoadPoint 设置为 true),逆向地址匹配接口才能成功搜索。

参数:
geometry - 指定的点对象。
dDistance - 指定的搜索范围。
返回:
结果匹配的数目。

match

public AddressSearchResult match(java.lang.String searchAddress,
                                 AddressSearchSetting addressSearchSetting)
地址匹配接口

该接口为多线程使用提供,只需加载一次索引文件。

参数:
searchAddress - 指定的要检索的地名地址。
addressSearchSetting - 中文地址模糊匹配参数设置对象。
返回:
中文地址模糊匹配结果集合。

注意事项:

  1. 使用接口前,需要先通过AddressSearchSetting对象设置相关参数,详情参见 AddressSearchSetting
  2. 该接口使用的地址索引数据只能是 AddressLoad 类的新的 load(boolean) 接口生成的,不兼容老的废弃的load()接口;
  3. 使用接口前,如果加载数据时使用了分组字段,建议通过 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;    
                 }
 

match

public AddressSearchResult match(Geometry geometry,
                                 double dDistance,
                                 AddressSearchSetting addressSearchSetting)
逆向地址匹配接口

该接口为多线程使用提供,只需加载一次索引文件。

参数:
geometry - 指定的点对象。
dDistance - 指定的搜索范围。
addressSearchSetting - 中文地址模糊匹配参数设置对象。
返回:
中文地址模糊匹配结果集合。

注意事项:

  1. 使用接口前,需要先通过AddressSearchSetting对象设置相关参数,详情参见 AddressSearchSetting
  2. 该接口使用的地址索引数据只能是 AddressLoad 类的新的 load(boolean) 接口生成的,不兼容老的废弃的load()接口;
  3. 使用接口前,如果加载数据时使用了分组字段,建议通过 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;    
                 }
 

isSupportReverse

public static boolean isSupportReverse(java.lang.String searchDirectory)
判断索引数据是否支持逆向匹配。

参数:
searchDirectory - [in] 索引数据目录
返回:
支持返回TRUE ,不支持返回FALSE