Problems with Dutch ZIP codes (bug?) (Delphi code provided)

schuchhardp
11-12-2002, 03:47 AM
Hi,

I think I've seen some other posts about this subject, but I will also give this a try:

I try to obtain the ZIP codes for a given set of Locations. I use ObjectsFromPoint to get a list of streets and then try to get the postalCode for one of those streets. This works for locations that are on streets in countries such as France, Germany and Spain. It doesn't work for the Netherlands: the value for streetAddress.postalCode there is always an empty string.

My questions are:
a) Is the way I try to obtain the postalCode the best one and do any alternatives exist?
b) Does anyone know the reason why the Netherlands are different from other European countries? Is this a bug, or does Microsoft just not provide this functionality for this country?

Thanks for any help you can give me with this,
Pascal

I have provided a sample of Delphi code:

function getPostalData(latitude: Extended; longitude: Extended): String;
var
StreetResults: FindResults;
address: StreetAddress;
myLoc: Location;
i: Integer;
j: OLEVariant;
size: Integer;
temp: IDispatch;
begin
result:='';

myLoc:=myMap.GetLocation(latitude, longitude, 1);

myLoc.GoTo_;
StreetResults:= MyMap.ObjectsFromPoint(MyMap.LocationToX(myLoc), MyMap.LocationToY(myLoc));
size:=StreetResults.count;

//we loop through the resultset and look at all streets
//result:='s='+intToStr(size);
for i:=1 to size do begin
j:=i;
temp:=StreetResults.Get_Item(j);
if(temp.queryInterface(Location, myLoc)=0) then //its a location Object
begin
address:=myLoc.StreetAddress;
if (address<>nil) then begin
if(length(address.postalCode)>0) then
result:=result+ '_'+ address.postalCode
else
result:=result+'_length was 0';
end;
end;
//else result:=result+'_X';
end;
end;

Anonymous
11-27-2002, 05:05 PM
Hi,

This solution works. The several fields you can retrieve are a bit strange. For the netherlands only the numeral part is given back by Mappoint.

success!
Jan Vieveen.



procedure Tformmain.Button5Click(Sender: TObject);
var mpMap: _Map;
x1,y1: real;
objloc1,objloc2: Location;
objres : findresults;
j,k : integer;
i : OleVariant;
temp: IDispatch;
address:StreetAddress;
wstr: widestring;

begin
mpApplication.Visible:=TRUE;
mpMap:=mpAPplication.ActiveMap;

x1:=52.154;
y1:=5.0;
objloc1:=mpMap.GetLocation(x1,y1,1);
objloc1.GoTo_();
objres:=objloc1.FindNearby(10);
j:=objres.Count;
if j>1 then
begin
i:=1;
temp:=objres.item[i];
if (temp.queryInterface(Location, objloc2)=0) then //its a location Object
begin
address:=objloc2.StreetAddress;
address:=objloc2.Get_StreetAddress(); // works as well
wstr:=address.City;
wstr:=address.Get_City();
wstr:=address.Get_Street();
wstr:=address.Get_PostalCode();
wstr:=address.Get_OtherCity();
wstr:=address.Value;
end;
end;

end;

schuchhardp
11-28-2002, 03:37 AM
Sorry Jan, but I can't get it to werk. My results are just empty. Maybe you have a different version of MP? I use 2002.

It's also easy to check this problem by just clicking on the map. When selecting a street in Amsterdam, you are usually provided a streetname and housenumber. Streets in Berlin, Antwerp and Paris will also provide the postal code.

I wonder if this is a bug and if it will be fixed in the next version of MP.

Pascal

 
Web mp2kmag.com
mapforums.com