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

MapPoint 2013

Programming MapPoint in .NET

MapPoint Book

  Spatial Community
SVG Tutorials
MapPoint

Map Visitors

  ARTICLES  


Extracting the Mappoint 2002 Points of Interest

Extract all 801,171 POIs from the North American version of Mappoint into a database, for subsequent searches.

Introduction

While reviewing the threads on the Microsoft.Public.Mappoint newsgroup I noticed that there was some interest in gaining access to the Mappoint Points of Interest (POIs). My curiosity led me into investigating the possibility of using the Mappoint object model to extract the POIs from Mappoint and load them into a database. What I found is that with a little code and some patience it was possible to extract 801,171 POIs from the North American version of Mappoint. This article explains how this can be done. Before getting started, the reader must be fore warned that the use of the extracted data is subject to Mappoint licensing agreements.

Assumptions

This article assumes that the reader is familiar with data access using the Microsoft Data Access Components (MDAC) and using the Mappoint 2002 Object Model within the Visual Basic development environment.

The following items will be required to build and execute the application described in this article:

Application Overview

The application creates a database and uses the Mappoint 2002 object model to extract the POIs. For each POI extracted it calculates the POI's Lat/Long and adds a record to the database with the following data:

  • Name
  • Latitude
  • Longitude
  • Category (Cinemas, Shopping, etc.)
  • Full Street Address
  • Street
  • City
  • Region
  • Country
  • Postal Code
(Note: For a large number of POIs, the address is not provided. When not available, the POI is added to the database with only the Name, Lat/Long and Category included in the record.) The application includes a single form that includes a Mappoint ActiveX control, 4 textbox controls and a single command button using the default names (i.e., MappointControl1, Text1, Text2, Text3, Text4 and Command1). The following Project References will need to be made for the VB application:
  • Microsoft Mappoint Control 9.0
  • Microsoft Mappoint 9.0 Object Library (North America)
  • Microsoft ActiveX Data Object Library
  • Microsoft ADO Ext for DDL and Security
Initialization

Code executed from the form's load event is used to initialize the application. The initialization includes configuring Mappoint and creating the database.


As seen in the code above, once the Mappoint control is initialized, all the Place categories are made visible to allow for the maximum number of POIs to be extracted. This is necessary since the FindNearby method will only select the POIs from the categories that are visible.

In order for the extraction to work as planned, it is required that the distance Units used by Mappoint be set to "miles".

The database is created as "poi.mdb" in the same directory as the application from which the subroutine is executed. Once created, the database contains a single table named "tblPOI" and has columns that store the data as identified in the previous paragraph.

The following subroutine is called from the form's load event to create the database.


Notice that the Primary Key in the table consists of the POI Name, Latitude and Longitude. Due to the nature of the extraction algorithm, some POIs will be processed more than once. So, by defining the Primary Key using these fields, no POIs will get added to the table more than once. This will become clearer when the extraction algorithm is explained in the following paragraphs.

Also, Indices were placed on the Category, City and Postal Code fields for faster searching and sorting once the database has been created.

Extracting the POIs

Once the form has loaded, the extraction code can be started by clicking the command button to execute the code in the command's OnClick event.


The main task behind the POI extraction is performed using the FindNearby method of a Location object to populate a FindResults object. The FindNearby method receives a range as an input. In this application, the range is specified as 50 miles. Therefore, the FindResults object is populated with a collection of Location objects, one for each POI within 50 miles of the location object for which the FindNearby method is executed.

It should be apparent that the Location object for which the FindNearby Method will be executed will need to be moved across the North American continent in such a way as to not allow any POIs to be missed. This is done using two loops, a longitudinal (east to west) loop nested inside a latitudinal (south to north) loop. As seen in the code, the latitudes ranging from 15 to 75 degrees north and the longitudes ranging from 20 to 180 degrees west are covered. Each loop increment represents a single degree in either direction. Using a 50- mile radius with the FindNearby method will provide enough overlap as the Location object is moved to prevent any POIs from being missed. This is where it is important that the table where the records are being stored has a Primary Key set to prevent any POIs from being added more than once.

Looking at the extraction process from the top down, after establishing a connection with the database the latitudinal and longitudinal looping process begins. At each increment within the longitudinal loop, the Location object is repositioned at the location specified by the loop variables (e.g., the first position is lat/long 15.0/-20.0, the second position is 15.0/-21.0, etc., until 75.0/-120.0 is reached). Each time the Location object is repositioned, the FindNearby method is used to populate the FindResults Collection. A loop is then performed to process each POI, which is represented by a Location object in the FindResults collection. Within the loop, the Location object is used as an input to the CalPos function to obtain the POI's Lat/Long and a record is added to the database by executing an INSERT SQL statement.

As the extraction is being performed, the text boxes placed on the form will be updated as follows:

  • Text1 = Current latitude position
  • Text2 = Current longitude position
  • Text3 = Count of POIs processed at current location
  • Text4 = Total number of POIs at current location
You will notice as the extraction process is being performed the map is re-centered on the location being processed and a circle is displayed defining the area used by the FindNearby method to extract POIs.

The time needed for the application to execute will vary based on the system resources of the machine on which it is being executed. When executed on my Dell Inspiron 7500, it took a little over 30 hours to perform the entire extraction, approximately 26,700 POIs/hr. An alternative method would be to modify the code to do the extraction in segments and then append the records together into a single database.

Interesting Findings

Many POIs do not have a street address. In the case of no address, only the Name, Lat/Long and Category are included in the record for the POI.

The POIs extracted from Canada with an address indicate the country as being "US".

McDonalds has 10057 locations listed.

The postal code with the most POIs is 10021 with 676 which as you might expect exists for an area of Manhattan.

The POI category count breakdown is as follows:

CategoryCounts
Airports - Major 208
Airports - Minor 5650
Aquariums 13
ATMs and Banks 45361
Auto Services 65958
Bus Stations 319
Campgrounds 10819
Casinos 125
Cinemas 5111
Convention Centers 1279
Exit Services 36804
Galleries 19003
Gas Stations 26022
Hospitals 8026
Hotels and Motels 57331
Landmarks 12687
Libraries 12748
Marinas 1736
Museums 6184
Nightclubs and Taverns 47050
Park and Rides 604
Police Stations 3309
Post Offices 16093
Rental Car Agencies 4161
Rest Areas 1527
Restaurants - Asian 3445
Restaurants - BBQ 6552
Restaurants - Chinese 26676
Restaurants - Delis 21713
Restaurants - French 1838
Restaurants - Greek 2161
Restaurants - Indian 1788
Restaurants - Italian 16942
Restaurants - Japanese 5463
Restaurants - Mexican 23183
Restaurants - Other 196057
Restaurants - Pizza 32729
Restaurants - Seafood 9302
Restaurants - Steak 6926
Restaurants - Thai 2473
Schools 47492
Shopping 2295
Stadiums and Arenas 585
Subway Stations 1601
Theaters 2958
Train Stations 721
Zoos 143
Summary

As often is the case in software development and learning new applications, my curiosity got the best of me. Once I knew how to obtain the Lat/Long given a Location Object (thanks to Gilles Kohl's article), it was just a matter of familiarizing myself a little more with the Mappoint Object Model to come up with a way to extract the POIs. I now have a nicely populated database that I can use to try out many of the other Mappoint data related capabilities as well as to test Mappoint applications I will be responsible for developing.

Discuss this story in the forum.

Author: John Washenberger
Email: jwash(AT)seadak.com
URL: http://www.seadak.com
John is a Software Development Consultant for SeaDak Solutions, Inc. located on Bainbridge Island, WA which specializes in developing Microsoft integrated office and database solutions.



Google
 
MP2Kmag Internet


 Recent Discussion
 Resources
Browse GIS books and periodicals
Find a MapPoint Partner or Consultant
Real Estate Columbia Custom Home


Want Your Site To Appear Here?

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