Proximity Searching via Apex

A new release of Geopointe will be out next week after all systems are on the Summer 11 release. With the update will come the ability to perform spatial/proximity/radial searches via Apex. Two new Apex methods are available for this:

  • radialSearchMapObject
  • radialSearchDataSet

These Apex methods enable Geopointe customers to utilize the proximity searching of Geopointe into advanced Apex logic. For information on all methods available to you, visit the Apex API page in the Help Center.

Let’s run an example.  The image below displays a query (via the Geopointe UI) of our Geopointe customers within 15 miles of Wrigley Field in Chicago. We want to accomplish this same query in Apex without ever needing the UI. Now we can and the geopointe.API class will help us with this.

Using radialSearchMapObject
This method allows you to perform a radial search against a Map Object (a Salesforce object enabled for mapping) and also allows the passing in of a custom filter. Here we are saying to search around the record with id a1430000001E32gAAC and to search the Account object with a filter of Type = ‘Customer’ for records within 15 miles.

[code lang=”java”] geopointe.API.radialSearchResult result = geopointe.API.radialSearchMapObject(
‘a1430000001E32gAAC’,
‘account’,
‘type=’Customer”,
15,
geopointe.API.units.MILES);

system.debug(result);
[/code]

Using radialSearchDataSet
The method below is accomplishing the same thing, but is using a pre-defined dataset that already has the filter for Customers built into it.

[code lang=”java”] geopointe.API.radialSearchResult result = geopointe.API.radialSearchDataSet(
‘a1430000001E32gAAC’,
‘12826856169860.9678661172894504’,
15,
geopointe.API.units.MILES);

system.debug(result);
[/code]

The radialSearchResult Class
Both methods result in a geopointe.API.radialSearchResult object, which is defined with the parameters below.

There are other methods available in the geopointe.API class, so check them out. More methods will become available to our customers as time goes on and more use cases emerge.

Related Posts