MapPoint Web Service Find APIs - Data Sources and Entity Types
(Page 4 of 4 )
Because entities in MapPoint Web Service are real things, they are contained in corresponding data sources for any given geographic extent. For example, if you consider the North American map data source MapPoint.NA, entities within the United States, Canada, Mexico, and Puerto Rico are contained in this data source. The only way to get to these entities is by knowing which entity types are supported by a particular data source. To find out which entity types are supported by a given data source, use theCommonServiceSoapmethod to get a list of the entity types supported by different data sources.
Getting all supported entity types within a data source
You can get a list of entity types supported by a specific data source using the CommonServiceSoap.GetEntityTypes method, which takes the data source name as an input argument and returns an array ofEntityTypeobjects. The following code snippet shows how to get all entity types defined in theMapPoint.NAdata source:
//Define an instance of CommonServiceSoap class
CommonServiceSoap commonService = new CommonServiceSoap();
//Assign credentials
. . .
//Define a local entitytypes array
EntityType[] entityTypes;
//Datasource in question
string datasource = "MapPoint.NA";
//Get all entity types using the GetEntityTypes method
entityTypes = commonService.GetEntityTypes(datasource);
//Now loop through each entity display the name, parent
foreach(EntityType et in entityTypes)
{
Console.WriteLine(et.Name);
Console.WriteLine(et.Definition);
Console.WriteLine(et.ParentName);
}
Along the same lines, you can also get all entity type definitions for all data sources in MapPoint Web Service environment:
//Create an instance of common service soap
CommonServiceSoap commonService = new CommonServiceSoap();
//Assign credentials
. . .
DataSource[] dataSources;
dataSources = commonService.GetDataSourceInfo(null);
foreach (DataSource ds in dataSources)
{
String datasource = ds.Name;
//Now get entity type info for this data source
//Define a local entitytypes array
EntityType[] entityTypes;
//Datasource in question
//Get all entity types using the GetEntityTypes method
entityTypes = commonService.GetEntityTypes(datasource);
//Now loop through each entity display the name, parent
foreach(EntityType et in entityTypes)
{
Console.WriteLine(et.Name);
Console.WriteLine(et.Definition);
Console.WriteLine(et.ParentName);
}
}
I use theCommonServiceSoap.GetDataSourceInfomethod to get a list of data sources and then theCommonServiceSoap.GetEntityTypesmethod to get a list of entity types defined in each data source.
Once you know the names of the entity types, you can use the Find APIs, which we will see in detail later in the chapter, to customize the find queries to find only particular entity types.
Please check back next week for the continuation of this article.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
|
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.
|
|