从MapX到MapXtreme2004[12]-SearchNearest!

博客围绕“/xy”应用程序的服务器错误展开,指出searchInfo.SearchResultProcessor须为null。介绍了Catalog.SearchForFeature方法的参数、返回值等,给出解决错误的办法,如设置si.SearchResultProcessor=null等,还总结了搜索构造、列设置等相关要点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

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

searchInfo.SearchResultProcessor must be null.

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

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

源错误:

行 956:
行 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;因为这种查询会自动只查一条。

转载于:https://www.cnblogs.com/jetz/archive/2005/10/31/265859.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值