BrainDump
  Home arrow BrainDump arrow Page 4 - 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
     
     
    Iron Speed
     
    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 - Optimizing Find Call Performance
    (Page 4 of 5 )

    One of the advantages of working with web services is that you can invoke methods over the wire using XML, but due to the remote nature of this method and XML’s inherent behavior to bloat the packet size, it may pose performance and end user experience issues. For example, say you are building a mapping application for a handheld device that depends on GPRS for connectivity; usually the users of these connected handheld devices pay the network service provider for the data plans (the number of bytes downloaded over the air using the GPRS connections).

    To find a place, your MapPoint Web Service application sends a request SOAP XML message and receives the response SOAP XML message from the Web Service. Because the XML bloats the size of the request and response packet, this could cost your application users a lot of money. Not only could having large request and response messages slow down your application for network transfer, but it also may result in poor end user experience. There are multiple ways to optimize your MapPoint Web Service applications for SOAP XML size and response speed; let’s look at them in detail.

    Optimizing the SOAP Response Size

    Always write your applications to receive only the information you need and filter out all unnecessary noise. There are three elements you can limit to do this:

    Result-set size

    If you are looking for a place and are certain of its name, request only one find result using the FindRange object:

    //Create a FindServiceSoap object. FindServiceSoap findservicesoap = new FindServiceSoap();
    //Assign credentials go here.
    . . .
    //Create a FindSpecification object. FindSpecification findspecification = new FindSpecification();
    //Assign a valid data source name. findspecification.DataSourceName = "MapPoint.NA";
    //Specify a place to find. findspecification.InputPlace = "Redmond, WA";
    //Create a FindOptions object.
    findspecification.Options = new FindOptions();
    //Create a Range object. findspecification.Options.Range = new FindRange();
    //Assign the Range StartIndex and the result count to be returned. findspecification.Options.Range.StartIndex = 0; findspecification.Options.Range.Count = 1;
    //Invoke the Find method.
    FindResults findresults =
              findservicesoap.Find(findspecification);

    Result information

    Usually, all find methods returnFindResultobjects with location, entity, and best map view information, leaving it up to you to pick and choose what
    information you need and don’t need. If you are looking only for latitude/longitude information for one particular place, get only that information by filtering all other information using theFindResultMaskenumeration:

      //Create a FindServiceSoap object.
      FindServiceSoap findservicesoap = new FindServiceSoap();
      //Assign credentials go here.
      . . .
      //Create a FindSpecification object.
      FindSpecification findspecification = new FindSpecification();
      //Assign a valid data source name.
      findspecification.DataSourceName = "MapPoint.NA";
      //Specify a place to find.
      findspecification.InputPlace = "Redmond, WA";
      //Set ResultMask to retrieve only map view information.
      findspecification.Options.ResultMask = FindResultMask.BestMapViewFlag;
      //Invoke the Find method.
      FindResults findresults =
                findservicesoap.Find(findspecification);

    Limit entity information

    Even though this is only applicable to point of interest methods, such asFindNearby,FindById,FindByProperty, andFindNearRoute, it is always a good practice to request entity attributes using theFindFilterobject. This object has a property,PropertyNamesof type string array, that allows you to define which attributes you want to see on returned entities. If an entity (such as a coffee shop) has 200 properties and you plan to use only 2 properties (say, Name and PhoneNumber), you can specify that in yourFindNearbyrequest using theFindFilter.PropertyNamesso that your response SOAP XML contains only 2 properties instead of all 200. The only caveat to this approach is that your definition for property names must also include the names used in filter expression in theFindFilterExpression.Expressionobject. The following code snippet shows the usage of theFindFilter.PropertyNamesproperty:

      //Declare a find nearby specification object
      //and assign all required information
      FindNearbySpecification findNearbySpec = new FindNearbySpecification();
      findNearbySpec.DataSourceName = "MapPoint.FourthCoffeeSample";
      findNearbySpec.Distance = 1;
      findNearbySpec.LatLong = new LatLong();
      findNearbySpec.LatLong.Latitude = 47.6;
      findNearbySpec.LatLong.Longitude =
    -122.33;
      findNearbySpec.Filter = new FindFilter();
      findNearbySpec.Filter.EntityTypeName = "FourthCoffeeShops";
     
    //Minimize the properties on returned entities by
     
    //specifying the property names field
      //Define the properties you plan to use
      //in your application
      string[] returnProperties = new string[2];
      returnProperties[0] = "Name";
      returnProperties[1] = "Phone";
      //Assign it to find nearby specification
      findNearbySpec.Filter.PropertyNames = returnProperties;

      FindResults foundResults;
      foundResults = findService.FindNearby(findNearbySpec);

    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

    - 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