Click or drag to resize

DataQueryBeginQueryPoi Method

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
Begins an asynchronous search for points of interest within a bounding box, starting from the center of the box and moving outwards.

Namespace:  Telogis.GeoBase
Assembly:  geobase.net (in geobase.net.dll) Version: 4.99.0.0
Syntax
public static IAsyncResult BeginQueryPoi(
	BoundingBox bbox,
	PoiType[] type,
	string nameSubstring,
	AsyncCallback resultsCallback,
	Object state
)

Parameters

bbox
Type: Telogis.GeoBaseBoundingBox
The BoundingBox within which to search.
type
Type: Telogis.GeoBasePoiType
An array of PoiTypes to restrict the search to. If this is null or empty all PoiTypes are returned.
nameSubstring
Type: SystemString
A substring to search for in POI names.
resultsCallback
Type: SystemAsyncCallback
The callback to call when more results become available. This may be called multiple times.
state
Type: SystemObject
The state of the asynchronous query.

Return Value

Type: IAsyncResult
An array of Poi objects.
Remarks

An asynchronous query is performed in a spiral fashion, starting from the center of the given bounding box.

Initially, a search area, with 3km x 3km dimensions, is centered on the bounding box's center. If the bounding box is smaller than the search area, then the search area is clipped down to size. If all sides are clipped, no more queries will be performed.

If not all sides are clipped, the search starts working in a spiral. After each iteration of the algorithm, it will have queried a square area (unless it hits the bounding box), so at the beginning of each iteration the following queries are planned:

Each box (A,B,C and D) is calculated, and fed into GeoBase for querying. These boxes are clipped to the bounding box if necessary. If a box is clipped entirely (to zero width or height) then the query needn't be performed.

Once all boxes are clipping to zero width or height, the query is complete.

The thickness of the spiral boxes is controlled by T.

Examples
C#
class Program
{
    //Poi list
    static List<Poi> async;

    //thread wait
    static ManualResetEvent mre;

    //Create new bounding box, and center on LatLon
    static BoundingBox box;
    static int count;

    static void Main(string[] args)
    {

        mre = new ManualResetEvent(false);

        //Callback
        AsyncCallback cb = new AsyncCallback(ar);

        //Dimensions
        box = new BoundingBox();
        box.Add(new LatLon(34, -118));
        box.Inflate(0.25);


        Console.WriteLine(DateTime.Now);
        count = 0;

        //Create list
        async = new List<Poi>();

        //start query - using boundary box and callback
        DataQuery.BeginQueryPoi(box, null, null, cb, null);

        //thread wait (until signaled)
        mre.WaitOne();
        Console.WriteLine(count);

        //Stop console closing automatically
        Console.ReadKey();
    }

    //Callback method
    static void ar(IAsyncResult cb)
    {

        bool comp;

        Poi[] res = DataQuery.EndQueryPoi(cb, out comp);

        if (res.Length > 0)
        {
            //update list
            count += res.Length;
            async.AddRange(res);
            Console.WriteLine("{0}:{1} - {2} - {3:0.0}", DateTime.Now, res.Length, res[0].Name, res[0].Location.DistanceTo(box.Center, DistanceUnit.KILOMETERS));
        }
        else
        {
            Console.WriteLine("{0}:{1}", DateTime.Now, res.Length);
        }

        if (cb.IsCompleted)
        {
            //set to signaled state
            mre.Set();
        }
    }
}
See Also