Finding Locations with the MapPoint Web Service Find APIs - Finding Points of Interest Around a Location
(Page 3 of 4 )
To find points of interest around a given location, use the FindServiceSoap.FindNearby method. The FindNearby method works only with data sources that have the CanFindNearby capability. As a general rule of thumb, only the point of interest data sources supplied by data vendors such as NavTeq and Acxiom have this capabil ity; data sources such as MapPoint.NA and MapPoint.EU do not support the FindNearby method.
Like any other find service method, the FindNearby method also takes a specification of type FindNearbySpecification class. The FindNearbySpecification object takes information such as the data source name, input location around which you want to find points of interest (as a latitude/longitude), distance to be covered around the original location to find points of interest, and entity types you want to find. Table 6-4 gives an idea of the fields presented in the FindNearbySpecification object.
Table 6-4. Fields in a FindNearbySpecification object
| Field | Description |
| DataSourceName | Data source name as a string. |
| Distance | The distance from the LatLong property. |
| Filter | The filter ( FindFilter object) to apply to the results. In other words, it is the specific entity type, properties, and values that the returned results must match. |
| LatLong | The latitude and longitude coordinate ( LatLong object) of the point around which the search is made. |
| Options | The search options ( FindOptions object), which include the range of results and a flag to identify which objects are desired in the returned results. |
To find all ATMs around the address 1 Microsoft Way, Redmond, WA, get the latitude and longitude information using the FindServiceSoap.FindAddress method, and call FindServiceSoap.FindNearby with one of the point of interest data sources (in this case, I chose to use NavTech.NA ) and the entity type name for ATM, SIC3578 :
//Create find service soap instanc e
FindServiceSoap findService = new FindServiceSoap();
//Assign credentials
. . .
//Define findnearby specification
FindNearbySpecification findNearbySpec = new FindNearbySpecification();
//Assign a data source
findNearbySpec.DataSourceName = "NavTech.NA";
//Since you are looking for ATMs, assign ATMs entity type
findNearbySpec.Filter = new FindFilter();
//Assign entity type for ATMs
findNearbySpec.Filter.EntityTypeName = "SIC3578";
//Set the distance in miles
findNearbySpec.Distance = 1;
//Assign the location around which you want to find ATMs
findNearbySpec.LatLong = new LatLong();
findNearbySpec.LatLong.Latitude = 47.6;
findNearbySpec.LatLong.Longitude =
-122.33;
//Call findnearby method
FindResults foundResults;
foundResults = findService.FindNearby(findNearbySpec);
//Process the results
foreach(FindResult fr in foundResults.Results)
{
. . .
}
The previous code finds ATMs around the specified address within one mile using the NavTech.NA data source; of course you could have also used other points of inter est data sources from Acxiom .
Next, say that you are working for a banking company and building an ATM locator application; obviously you would display your company’s ATMs around any specified address. It is possible to display your ATMs with the FindNearby method, but since none of the MapPoint data sources or vendor data sources (NavTech, Acxiom, and so on) know about your bank’s ATMs specifically, you need to provide a data source for MapPoint Web Service to use with the FindNearby method. That’s when the customer data sources come into the picture.
If you do not want to upload your data to MapPoint servers due to security reasons, you can implement your own FindNearby functionality using SQL Server—see Appendix C for more details.
Customer data sources—displaying your data
When you sign up for MapPoint Web Service, you are assigned space on MapPoint servers to upload your business data (such as points of interest and icons) to use with the FindNearby method. Using this space, you can create a maximum of 25 data sources on the MapPoint Web Service servers. For example, if your company has banks and ATMs, you would create two data sources with one assigned to each entity type. So, with multiple data sources, you can use different data source files for different types of data. Having said that, there are certain requirements for creating your own data sources:
- The combined size of all your data sources cannot exceed 2 gigabytes.
- Each data file that you upload (that contains a number of location records) cannot exceed 100 megabytes.
- Each data source and the entities it contains must have an entity type, which is a user-defined alphanumeric string, and an entity id, which is an integer.
- The total number of searchable non-Boolean cells (or entity properties) per data source cannot exceed 8.75 million.
Every entity (or location record) has three required properties (EntityID, latitude, and longitude) and six additional properties created by the MapPoint Geocoder sevice, including MatchCode, MatchedAddress, MatchedMethod, EditedLocationUTC, EditedPropertyUTC, and InputModified. All of these properties are treated as searchable non-Boolean cells, so the number of entities contained in a single data source cannot exceed 972,222 (8.75 million cells divided by 9 non-Boolean, searchable properties per row). The number of Boolean cells per entity in a data source cannot exceed 200.
There are additional requirements applicable for entity property types in MapPoint Web Service, such as number of characters per field and type of characters per field.
For more information on the customer data formatting requirements, see the “Requirements for Custom Location Data” section from the MapPoint Web Service Customer Services site help documentation.
There are two options for uploading and downloading your entities to and from the customer services site: you can either use the Customer Services site web UI, or programmatically upload and download using the Customer Data Service Web Service, which is discussed in detail in Appendix A. Once you upload your custom data, you can use the FindServiceSoap.FindNearby method to use it against your own data.
Next: Finding Points of Interest Along a Route >>
More BrainDump Articles
More By O'Reilly Media
|
This article is excerpted from chapter six of the book Programming MapPoint in .NET, written by Chandu Thota (O'Reilly; ISBN: 0596009062). Check it out today at your favorite bookstore. Buy this book now.
|
|