Hexagon Geospatial
MENU

Developers Knowledge Base

WebGIS enables powerful geospatial web applications and services that securely share your organization’s rich geospatial data, and provides tools to deeply examine spatial data and create value added products, on demand.
Showing results for 
Search instead for 
Do you mean 

Custom Search Dispatcher

by Technical Evangelist on ‎09-09-2015 04:04 AM - edited on ‎04-11-2017 03:45 AM by Technical Evangelist (1,191 Views)

Search Dispatchers

Search dispatchers are registered in Web.Config file under webclient section:

 

<searchDispatchers>
    <Dispatcher code="all" dispatcherType="Intergraph.WebSolutions.Core.WebClient.Platform.Search.AllMapServicesSearchDispatcher"/>
    <Dispatcher code="selective" dispatcherType="Intergraph.WebSolutions.Core.WebClient.Platform.Search.ServiceSelectiveSearchDispatcher"/>
    <Dispatcher code="parsing" dispatcherType="Intergraph.WebSolutions.Core.WebClient.Platform.Search.QueryParsingDispatcher"/>
</searchDispatchers>

 

Values set to \"code\" parameter can be then used in configuration of LiveSearch and GazetteerPanel controls (as \"entryPointCode\" property).


There are three predefined search dispatchers:

 

  • AllMapServicesSearchDispatcher - input is passed to all registered \"searchable\" map services
  • ServiceSelectiveSearchDispatcher - input is passed to those \"searchable\" map services, which ids are passed as a parameter
  • QueryParsingDispatcher - services that input will be passed to are chosen depending on the format of the input string

Writing Custom Search Dispatcher

Search Handler

Both LiveSearch and GazeteerPanel controls use the same search handler - SearchHandler.WebClient.ashx. Handler expects the following parameters:

 

  • ep (mandatory)
  • action (mandatory - \"search\")
  • start (optional - pagination)
  • limit (optional - pagination)

Only \"final\" processing of the results like pagination is handled directly by the handler. The actual search process is defined by a dispatcher object. Dispatchers can expect custom parameters (for example when they are called from a custom or \"hacked\" search control), which are passed from search handler without changes.


For example, predefined dispatchers expect this parameter

 

  • allMapServiceIds

which is used to determine if map services from client session match map services from server session and if the session is valid.

Implementing ISearchable interface

All dispatchers must implement the following interface:

 

namespace Intergraph.WebSolutions.Core.WebClient.Platform.Search
{
    public interface INameSearcher
    {
        string Id { get;}
        IEnumerable<SearchResult> SearchForName(string name, IDictionary<string, IEnumerable<string>> searchParameters);
        IEnumerable<SearchResult> SearchForName(string name, IDictionary<string, IEnumerable<string>> searchParameters, string srsId);
        IEnumerable<string> LocationTypes { get; }
        IList<string> SupportedSrs { get; }
    }
}


 

  • Id - an example implementation may look like that:

 

public string Id { get { return this.GetType().ToString(); } }

 

  • SearchForName - one method overload is for searching in given coordinate reference system while the other without that information (typical implementation will use \"Crs.Current.Id\")
  • name - string given as input, for example \"Conha Espina, 46, Madrid\"
  • searchParameters - for example it may contain additional \"locationType\" information (as for Nomenclator)
  • srsId - for example \"EPSG:4326\"

Implementing custom SearchForName may be a little easier with use of helper method, Intergraph.WebSolutions.Core.WebClient.Platform.Search.SearchDispatcherHelper.BasicSearch static method:

 

public static IEnumerable<SearchResult> BasicSearch(string name, IDictionary<string, IEnumerable<string>> searchParameters

 

which performs search on all map services passed as a collection in method parameter.


After implementing your custom dispatcher, please remember to:

 

  • register containing dll with assemblyLoader section in web.config
  • register dispatcher in searchDispatcher section providing an entry point code
  • set gazetteer or live search controls (or your own control) to use your custom dispatcher

 

Simple scenarios made simpler

To make this process easier, the custom dispatcher may inherit from SearchDispatcherBase. All that must be done in that scenario, is to implement a predicate for selecting \"searchers\" from all registered map services that are of type:

 

  • WFS-G
  • OpenLS
  • LUWS
  • Nomenclator

 

class ExampleSearchDispatcher : SearchDispatcherBase
    {
        public ExampleSearchDispatcher (IDictionary<string, IEnumerable<string>> searchParameters)
            : base(searchParameters)
        {
        }

        protected override bool IsSearcherAppropriate(INameSearcher searcher, IDictionary<string, IEnumerable<string>> searchParams)
        {
            //...
        }
    }

 

Comments
by DN
on ‎10-24-2016 08:43 AM

Does anyone have any examples? Sample Code?

Overview