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  


Delphi Address Verifier

Yildiray Elmaci shares a MapPoint solution developed in Delphi to verify addresses including filling in missing information and returning the lat/lon

I have been working with MapPoint 2002 for only a short time, but already love it because it is easy to use and very compatible with Delphi, my favorite rapid application development (RAD) tool.

I obtained the european edition of MapPoint and installed it. I needed a complete environment for our geo-based requirements. I was not so hopeful because all the other tools that I tried had limitations.

After installation, I switched to Delphi 6. I opened the Project menu and selected "Import Type Library" option.

Which bring up this screen:

I selected "Microsoft Mappoint Control 9.0 (Version 1.0)". Then I pressed Install to add the components to Delphi component palette.

Then I could get the MapPoint components in the Activex tab of the component palette of Delphi 6.

There will be 3 components. From left to right: MappointUtilities, Application, Map.

Now I am ready to use MapPoint in my applications.

I must develop a address verifier for a Transport management software package. This article will focus on the the address verifying and address to lat/lon conversion routine.

First I added a Application object of MapPoint 2002 from Activex Component palette to my form and named it as "Mapp".

In the create event of the main form, I will make some initializations. Here is the the procedure:

In this procedure, I have set some variables. This variables will be used in the locations to lat/lon conversions. The variables are defined like this:

Now I will list the arc function that will be also required for locations to lat/lon conversions.

Here are the above-mentioned locations to lat/lon conversion functions.
These two functions will have location object as parameters and will return both LAT and LON locations as double.

As the last requirement, I will give you my split function. This is not related to the subject. This will split the given string using given delimiter and return the item in the given index.

Now the final part. The address verifier function. First, I will list the function. Then I will give remarks.

This is a function that I have been using to verify the given address. For instance, if the address that is passed in does not have a postal code, then this will return verified address filled with postal code. This is the same with street, city or region.

The given address parameter must be a comma delimited address. It is formatted like this:

[street],[postalcode],[city1],[city2],[region],country

The return format will be (if a good address is found):

street,postalcode,city1,city2,region,Lat,Lon

The Country is a must, the others are not. The function will return the first found address filling the empty items. In the returned string, the lat/lon positions will be added at the end.

The country code must be the number. This number can be found in the MapPoint help file.

04: r is defined as resultset for FindAddressResults method.
06: item is defined to use as found address item storing.
12 .. 17: Doing splitting activity to split the given address string to separate address items to use in the FindAddressResult function.
19: The key line. Calling FindAddressResults method of active Map object (mapp) to retrieve found addresses.
23: If one or more address are found then the return string will be created again as comma seperated. Otherwise null will be returned.
27: Return string is being created, using concanate of different address items.
33,34:I am also adding the lat/lon location of the found address to the end of the result string.

For example, if i give to this function this:
Lindelaan,,Zwijndrecht,,ZUID-HOLLAND,176
Note: 176 is the country code of the Nederlands.
I get the result as:
Lindelaan,3331,Zwijndrecht,,ZUID-HOLLAND,176

Or when i give this:
Lindelaan,3331,,,,176
I get again ; Lindelaan,3331,Zwijndrecht,,ZUID-HOLLAND,176 as result.

I hope you find this article useful.

Enjoy.

Discuss this story in the forum.

Author: Yildiray Elmaci
Email: yildiray(AT)turk.net
I am working for a Dutch company in the Netherlands as a senior software developer. I love MapPoint 2002 because it solved our almost all geo-based problems. I also have information about MapInfo and ESRI objects. I generally use Delphi as RAD tool. I love music, reading, walking, being with my family.



Google
 
MP2Kmag Internet


 Recent Discussion
 Resources
Browse GIS books and periodicals
Find a MapPoint Partner or Consultant
Real Estate Columbia MO Homes for Sale


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.