从MapX到MapXtreme2004[12]-SearchNearest!

 

“/xy”应用程序中的服务器错误。

searchInfo.SearchResultProcessor must be null.

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.ArgumentException: searchInfo.SearchResultProcessor must be null.

源错误:

行 956:
行 957:				Feature ftr2=MapInfo.Engine.Session.Current.Catalog.SearchForFeature("公交车站",si);
行 958:				
行 959:			

源文件: d:\xy\xy.aspx.cs    行: 957 

         当想用searchnearest时,总是报这个错误。而先前用searchwhere是好好的,于是折腾si,不断试验各种构造函数,还自定义了个SearchResultProcessor类,都不行,直到在帮助中看到这个:

Catalog.SearchForFeature Method (String, SearchInfo)

Searches the given table and returns the first Feature from the results.

public Feature SearchForFeature(
   string tableAlias,
   SearchInfo searchInfo
);

Parameters

tableAlias
The alias of the table to search.
searchInfo
Search definition.

Return Value

Returns a Feature.

Remarks

The SearchInfo must not have a SearchResultProcessor specified, because no post-processing of search results can take place.

      
 于是,增加一个
            si.SearchResultProcessor=null;
        便ok了,郁闷…………

结论:
        1、searchnearest的si构造有两个类都可以,MapInfo.Data.SearchInfoFactory.SearchNearest和MapInfo.Mapping.SearchInfoFactory.SearchNearest,似乎可以通用
        2、The default columns are MI_Geometry, MI_Syle, MI_Key. An Analysis column of MI_Geometry is added.如果不指定的话,查出来的结果就只有3列,所以需要加上si.QueryDefinition.Columns = null;
        3、A  ClosestSearchResultProcessor is created with the Search point.会自动生成一个SearchResultProcess对象。
        4、This SearchInfo can't be passed to SearchForFeature or SearchReader because they do not work with SearchResultProcessors.最关键的,原来根本不能用在SearchForFeature中。因为这种搜索方式不能有SearchResultProcessors。如果强制删掉SearchResultProcessors,虽然不报错,但也查找不到东西。
        5、只好用search
    IResultSetFeatureCollection ftrs=MapInfo.Engine.Session.Current.Catalog.Search("公交车站",si);
    foreach(Feature f in ftrs){  }

       6、无需(si.SearchResultProcessor as ClosestSearchResultProcessor).Options = ClosestSearchOptions.StopAtFirstMatch;因为这种查询会自动只查一条。

posted @ 2005-10-31 22:42  jetz  阅读(969)  评论(0编辑  收藏  举报