Example: Using MPRouteReader to Create a Route

Top  Previous  Next


This example shows you how to use MPRouteReader to create a route from a Microsoft Excel list of waypoints. Waypoints are imported as pushpins and they are sorted using a sequence defined in the Excel worksheet. The example is based in the New York area and requires Microsoft MapPoint North America. You will need the 2006 version if you wish to read the intermediate MapPoint file.


The example uses the reader_data.xls Excel spreadsheet in the RouteWriter_samples.zip file available from https://www.mapping-tools.com/routewriter/download.php. The spreadsheet looks like this:




The first row consists of column headers. Ideally these should match column headers recognized by MapPoint. Each location has a name and two fields (Longitude, Latitude) that give the location's position. Although coordinates such as these are the most accurate, you can also use street addresses if you wish. MPRouteReader will also require a data field that tells it how to organize the pushpins in the route. You could use the Name field, but it is usual to add a new field that explicitly gives the required sequence order. Here it is called "Sequence".


Next, start MapPoint and use the Data Import Wizard to import the reader_data.xls file as a pushpin set. Refer to the MapPoint documentation if you are unsure how to use the Data Import Wizard. Make sure the Sequence field is read as "Other Data". The imported data will look like this:




This example marks the data with blue flag pushpins for visibility. A copy of the imported data suitable for Microsoft MapPoint 2006 North America is included in the examples as reader_data.ptm.


Next start MPRouteReader by selecting MPRouteReader... on the MapPoint Tools menu. This will look like this:




Make sure the imported pushpin set is selected (reader_data). The Waypoint Order list lists the available data fields. We wish to sort the resulting waypoints according to their Sequence numbers, so select the Sequence field. Check the Calculate final route check box to cause MPRouteReader to also calculate the final route after inserting the waypoints.


Press Create Route. MPRouteReader then copies the pushpins from the selected pushpin set into a new route. These pushpins are ordered according to their Sequence values. MapPoint then calculates the final route before MPRouteReader finishes. The final route looks like this:




Notice that the waypoints are ordered according to their Sequence values in the original Excel file.


Further details on specific aspects of MPRouteReader operation can be found on the Running MPRouteReader pages.