BrainDump
  Home arrow BrainDump arrow Page 5 - Parsing Addresses and More with the MapPoi...
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

Parsing Addresses and More 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-03-06

    Table of Contents:
  • Parsing Addresses and More with the MapPoint Web Service Find APIs
  • AJAX-Enabling Your Web Applications
  • Implementing MapPoint Lookup AJAX Application
  • Optimizing Find Call Performance
  • Applying Proper Metadata for Faster Searches

  • 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
     
     
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Parsing Addresses and More with the MapPoint Web Service Find APIs - Applying Proper Metadata for Faster Searches
    (Page 5 of 5 )

    Whenever possible, try to apply proper metadata for your find queries, including applying proper entity type information and adding search contexts. For example, if you are searching for Redmond, WA in the United States, you can improve your application’s performance by adding the entity type information of PopulatedPlace (using the entity type name for cities means that you are looking only for a city) and a context of 244 (the entity ID of the United States narrows your search to the United States) during your find call:

      //Create a find specifications object
      FindSepcification findspecification = new FindSepcification();

      //Assign the EntityTypeNames value
      findspecification.EntityTypeNames = new string[] {"PopulatedPlace"};

      //Assign search context findspecification.Options = new FindOptions();
      //Add context for United States
      findspecification.Options.SearchContext = 244;

    Use Asynchronous Programming Patterns

    Since any web service call involves a network round-trip, using asynchronous programming improves the user’s experience dramatically. With MapPoint Web Service Find Service, you can use asynchronous programming paradigms provided by Microsoft .NET Framework. If you are building a web or Windows application using MapPoint Web Service, you can use the MapPoint Web Service asynchronous methods to perform tasks such as Find or FindAddress; however, in order to use asynchronous methods, you use the Begin and End pair methods instead of the actual method itself. For example, to call the Find method in asynchronous patterns, use the BeginFind and EndFindmethods, which internally use theSoapHttpClientProtocolobject’sBeginInvokeandEndInvokemethods.

    When you are building an enterprise-level application using MaPoint Web Service, obviously performance is not the only thing you need to keep in mind; you also need to think about supporting multiple languages and cultures, so globalizing your applications to support local languages is an essential part of your application. In the next section, let's see how to leverage some of the MapPoint Web Service features to build global applications.

    Globalizing Find

    MapPoint Web Service currently supports 10 different languages, meaning that when you use the Find Service with a desired (and supported) language, the Find results are returned in that language. It is important to note that in the case of the Find service, only city names and other entity information are localized to display in that specific language.

    Table 6-10 shows the list of languages currently supported in MapPoint Web Service:

    Table 6-10. Languages supported in MapPoint Web Service

    Language Language Code Lcid
    Dutch nl 19
    English en 9
    English-United States en-us 1033
    French fr 12
    German de 7
    Italian it 16
    Portuguese pt 22
    Spanish es 10
    Swedish sv 29

    The data sourcesMapPoint.MoonandMapPoint.Worldsupport all of these languages as well as Japanese (language code ja and LCID 1041).

    To send your desired language information to the MapPoint Web Service during your Find Service calls, MapPoint Web Service provides SOAP Headers. With Find Service, these settings use theFindServiceSoap.UserInfoFindHeaderValuefield. TheUserInfoFindHeaderValueis of typeUserInfoFindHeader, and it and provides fields to set values for the location search context (theUserInfoFindHeader.Contextfield), user preferred culture (theUserInfoFindHeader.Culturefield), and default distance unit as eithermilesorkilometers(theUserInfoFindHeader.DefaultDistanceUnit field). To use Find Service with a search context for Canada (whose country entity ID is 39) with a preferred language of French (name fr), you would have to provide the user information header to theFindServiceSoap:

      //Create a find service soap object
      FindServiceSoap findService = new FindServiceSoap();
      //Create a user header
      UserInfoFindHeader userInfoFindHeader = new UserInfoFindHeader();
      //Set the country context to Canada
      userInfoFindHeader.Context = new CountryRegionContext();
      userInfoFindHeader.Context.EntityID = 39;

      //Set the language preference
      userInfoRenderHeader.Culture = new CultureInfo();
      userInfoRenderHeader.Culture.Name = "fr";

      //Then assign the header to the find service proxy
      findService.UserInfoFindHeaderValue = userInfoFindHeader;

    The entity ID and language name are assigned to the find header before making any find calls. To set the desired culture information, you could also use theLcidID for French instead of using the language name. One thing to remember while using the user information header to obtain localized information from Find Service is that the addresses returned by theFindServiceSoap.FindAddressmethod are never localized.

    Where Are We?

    Find Service is one of the core components of the MapPoint Web Service, providing many features such as finding places, addresses, and points of interest around a given location. Find Service also provides a way to convert any latitude/longitude information to an entity that contains the geographic information about that given point; it also provides necessary tools to parse addresses to see whether a given string is a place or an address so that you can call the appropriate method to find information.

    Since Find Service methods are web service methods, it is important to think about performance optimization and asynchronous programming patters where applicable. Finally, Find Service also provides a way to get information in a specific localized language (among the 10 supported languages).

    In the next chapter, we’ll look at MapPoint Web Service Route and Render Service components. 


    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 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

    - Handling Multiple Contracts with Indigo
    - Cleaning Out Your Data in XP
    - 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

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




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