BrainDump
  Home arrow BrainDump arrow Finding Entities with the MapPoint Web Ser...
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

Finding Entities with the MapPoint Web Service Find APIs
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-02-28

    Table of Contents:
  • Finding Entities with the MapPoint Web Service Find APIs
  • Finding entity by properties
  • Finding Polygons
  • Getting Entities from Latitude/Longitude

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    TestComplete™ automates software testing for a fraction of what the big guys charge. Easy functional and load testing for all Windows, .NET, Java and Web apps. Download a free trial now.

    Finding Entities with the MapPoint Web Service Find APIs
    (Page 1 of 4 )

    In this fourth part of a five-part series on the MapPoint Web Service Find APIs, you will learn how to find custom entity types, how to find entities by properties, and more. This article is excerpted from chapter six of the book Programming MapPoint in .NET, written by Chandu Thota (O'Reilly; ISBN: 0596009062). Copyright © 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

    Finding Custom Entity Types

    MapPoint Web Service has a certain set of methods that find entities using their identities and properties, but these methods can only be used with the custom data uploaded to the MapPoint servers. These methods are particularly useful for queries that depend on nonspatial attributes. For example, if you upload all your ATMs to MapPoint servers and you want to display all ATMs in the city of Chicago, or only the ATM that has the unique identity of 13324, these methods can be either simple non-spatial queries or spatial queries. In this section, let’s look at these find methods that can be used with your custom data.

    Find entity by identity

    You can use the FindServiceSoap.FindByID method to find entities using their entity IDs. Like any other find method, this method takes a specification object of type FindByIDSpecification and returns a FindResultsobject. TheFindByIDSpecificationobject takes up to 500 IDs as input parameters. Table 6-6 shows the fields exposed on theFindByIDSpecificationobject.

    Table 6-6. Fields exposed in the FindByIDSpecification object

    Field Description
    DataSourceName Data source name as a string
    EntityIDs Array of unique entity IDs; only points of interest with matching entity IDs are returned, while the rest are ignored

    Filter

    The filter (FindFilterobject) to apply to the results, which includes the specific entity type, properties, and values that the returned results must match

     Options

    The search options (FindOptionsobject), which may include the range of results and a flag to identify which objects are desired in the returned results

    The following code shows how to use theFindByIDmethod:

      //Create a Find Service proxy
      FindServiceSoap findService = new FindServiceSoap();
      //Assign credentials
      . . .

      //Define find by id specification
      FindByIDSpecification findbyidspec = new FindByIDSpecification();

      //Assign a data source name
      findbyidspec.DataSourceName = "MapPoint.FourthCoffeeSample";

      //Apply a filter for entity name
      findbyidspec.Filter = new FindFilter();
      findbyidspec.Filter.EntityTypeName = "FourthCoffeeShops";

      //Now assign the entity IDs to find
      int[] arrayID = {-21835, -21836};
      findbyidspec.EntityIDs = arrayID;

      //Call FindById method
      FindResults foundResults;
      foundResults = findService.FindByID(findbyidspec);

    The found entities are returned in the same order that the entity IDs are passed in, but you can override this sorting behavior using theFindFilter.SortProperties. Assuming that you want to sort the ATMs in the previousFindByIDmethod by their associated bank name (assuming that there is a property calledParentBankName), the method call looks as follows:

      //Create a Find Service proxy
      FindServiceSoap findService = new FindServiceSoap();
      //Assign credentials
      . . .

      //Define find by id specification
      FindByIDSpecification findbyidspec = new FindByIDSpecification();

      //Assign a data source name
      findbyidspec.DataSourceName = "MapPoint.FourthCoffeeSample";

      //Apply a filter for entity name
      findbyidspec.Filter = new FindFilter();
      findbyidspec.Filter.EntityTypeName = "FourthCoffeeShops";

      //Specify what properties to be used to sort the found results
      SortProperty[] sortproperties = new SortProperty[1];
      sortproperties[0] = new SortProperty();
      //Assign the property name to be sorted on
      sortproperties[0].PropertyName = "ParentBankName";
      //Specify the sort direction: Ascending or Descending
      sortproperties[0].Direction = SortDirection.Descending;

      //Assign sort specification to the find filter
      findbyidspec.Filter.SortProperties = sortproperties;

      //Now assign the entity ids to find
      int[] arrayID = {-21835, -21836};
      findbyidspec.EntityIDs = arrayID;

      //Call FindById method
      FindResults foundResults;
      foundResults = findService.FindByID(findbyidspec);

    As you can see, theSortPropertiesmethod is an array, so you can sort the resulting entities by more than one attribute if needed.

    It is important to remember that the points of interest entity identities are not persisted from one version of the MapPoint Web Service to another, so if you hardcode the point of interest entity IDs into your application, when you upgrade to a newer MapPoint Web Service, your application may break. To make it easy to distinguish between positive and negative IDs, all negative entity IDs (such as entity ID -21835 for a coffee shop) are not persisted across versions, while the positive IDs are (such as entity ID 244 for the United States).

    More BrainDump Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Programming MapPoint in .NET," published...
     

    Buy this book now. 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.

    BRAINDUMP ARTICLES

    - Multiple Service Contracts and Indigo
    - Cleaning Out Your Programs in XP
    - Handling Metadata with Indigo
    - Building Blocks for a WCF Service Web Site
    - Help! I Need Some Remote Assistance
    - Using Service Templates with Indigo
    - Windows XP Tips for Task Manager
    - Generating Clients and Services with Indigo
    - Vista SP1, A Review
    - Services and the WCF
    - VBScript: Final Date Functions
    - Creating Services with the WCF
    - The Resource View of the MFC
    - VBScript: More Fun with the Date Functions
    - Vista Price Cuts Dissected




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway