spacer1
spacer2 1_1 1_2
2_1
 Subscribe
 The MP2K Update!
 
 
 
 Magazine
Front Cover
What's New
Articles
Toolbar
News
Sample Data
Gallery
Advertise
About
 Features
MapPoint 2009
Press Releases
MapPoint Forums
Companies
Link to MP2Kmag
Wish List
MapPoint Trial
Authors
 Sponsors
 Order

MapPoint 2009

Programming MapPoint in .NET

MapPoint Book

  Spatial Community
ViaVirtualEarth
SVG Tutorials
MapPoint

Map Visitors

 Direct Media

IT support
Connect.co.uk provides top-notch IT Support for small and medium-sized enterprises.

cartridge ink
Get cartridge ink from top brands such as Epson, HP and many more. Check out our great prices. Ring our rapid order freephone!

Cheap flights to Italy
Italy is overflowing with things to do, things to see and things to eat. Why not book cheap flights to Italy online right now?

Cheap Holidays in Greece
Book cheap holidays in Greece and relax on the beach. Book online with On The Beach to book a brilliant holiday. High value holidays for low costs!

Bulgarian Property...
Here is the easiest Bulgarian property company to work with.

Flights to India
Don't miss out on the great value flights to India available online at dealchecker.co.uk. India is home to the descendants of one of the world's oldest civilisations, the Indus Valley civilisation.

Cyprus
Before visiting Cyprus, make sure you are well informed to make the most of your holiday. Online at ulookubook.com you check out our useful travel guides. Find out all about the Cyprus nightlife, shopping, eating and customs.

  ARTICLES  


Merging Multiple Routes

In this article, Chip Pearson demonstrates a method to merge several MapPoint files in to a single "Master" route programmatically with VBA.

I had the situation in which I wanted to merge the routes from each of several MapPoint files in to a single "master" route. I had taken an 8 day driving trip through New Mexico and Colorado, and had each day's route in a separate file. I wanted to create a single Map that described my entire trip.

So, being a VBA junkie, I wrote some VBA code to automate the process. The VBA consists of two modules. The first, a standard code module called modRouteMerge contains the code that does the actual work. The second, a class module called CWayPointX, defines the "holding" object in which we store information about each way point.

As the various maps are read, each waypoint's information is stored in an instance of CWayPointX, and each instance of CWayPointX is stored in a collection. The individual map routes are read by a procedure called GetRoutes. Then, a new blank map is created, and a route is created by looping the collection object, pulling information from each CWayPointX object stored in the collection. This is done by the procedure called CreateNewMapRoute.

The CWayPointX class contains a procedure called CalcPos, written by Gilles Kohl, which I got from this web site, in the article "A More Compact Method For Obtaining Lat/Long" (18-July-2001). This procedure calculates the latitude and longitude from a Location object.

The CWayPointX class preserves only the Name, latitude, and longitude of the original WayPoint object. Other properties (e.g., Overnights) are not preserved. However, the source code provides detailed instructions about how one can modify the class to preserve any WayPoint property.

The code was developed the code under Excel 2002, but it does not use any Excel-specific features, and therefore should work under any "host" application that supports VBA (e.g., Excel, Word or PowerPoint). Any VBA-enabled host application can run the code. The user will have to set a reference to the MapPoint 2002 (version 9) object library. I have not tested this code under any version of MapPoint prior to 2002, but doubt it will work.

The code is very completely commented, and can easily be customized by anyone with a basic understanding of VBA.

To use the code, simply import the two modules in to any application that supports VBA (e.g., Excel or Word), change the file names in the GetRoutes procedure to the files you want to merge, and execute GetRoutes. The builds the collection of WayPoints. Then, execute CreateNewRouteMap to build a new map with the "merged" route. The original files are not modified in any way.

The code is explicitly granted to the Public Domain.

Discuss this story in the forum.

Author: Chip Pearson
Email: chip(AT)cpearson.com
URL: http://www.cpearson.com
Chip Pearson is an independent software developer, specializing in applications written on the Microsoft Excel platform. He has been awarded the Most Valuable Professional (MVP) award from Microsoft for each of the last 4 years. Prior to working in the Excel world, Chip was a consultant to Tandem Computers in Cupertino, CA. He has a degree in mathematics from the University Of Kansas, and currently lives in Kansas City with his cat, Sadie.



Google
 
MP2Kmag Internet


 Recent Discussion
-How to hide Direction panel after call ActiveRoute.Calculate()?
-Internet Explorer 8 Beta 2 Includes Virtual Earth
-Virtual Earth for the Environment
-u-blox GPS Technology to Power Microsoft MapPoint 2009 USB Stick
-Move pins to dataset
-MapPoint 2009 - Zooming Right Mouse Button
-Virtual Earth 6.0 Auto-Upgrade Postponed
-Set up project is not running
-Hello
-Disappointed by Mappoint 2009
-Updating Address Data
-Virtual Earth Applications on Facebook
-Licensing Question (Images used in Print context)
-I Want My MapPoint Icons Back!
-Virtual Earth UltraCam ortho-imagery can now be licensed for offline use!
-See county names through graphics
-Microsoft Virtual Earth & Photosynth: Coming Together
-Purchase Standalone Microsoft Virtual Earth Photography
-Mappoint Control as a Navigator
-Streets & Trips 2009 Free Trial Download Now Available
-MapPoint 2009 Trial Now Available for Free Download
-Heat Maps
-Virtual Earth API: Displaying Birdseye Maps With and Without Labels
-SK8R Nation on Push
-Any fundamental change of MapPoint programming model?
 Resources
Browse GIS books and periodicals
Best Car Contract Hire Lease Save
Find a MapPoint Partner or Consultant
Real Estate Thornbrook Subdivision


Want Your Site To Appear Here?

   © 1999-2008 MP2K. Questions and comments to: website@mp2kmag.com
  Microsoft and MapPoint 2002/2004/2006 are either trademarks or registered trademarks of Microsoft.

• Replacement Cordless Phone Batteries from DSMiller
Improve your career with a computer degree LocalEDU.com
• Tim Cohn's Marketing Strategy Consultancy
• Buy Toner, Ink Cartridges & Drums at Marquee Office Solutions
• Looking for Dry Erase Boards? See Dry Erase Boards • The Search Starts Here Used Cars
• 5339 - We Know Bikes: Road Bikes / Triathlon Bikes / Mountain Bikes / BMX Bikes
• Buy Your Car Used Cars, Car Lease and Contract Hire