GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
data returned by postcode lookup does not match state-suburb  XML
Forum Index -> Administrative Divisions
Author Message
veemltd



Joined: 01/10/2014 03:14:18
Messages: 8
Offline

Hi all/Marc,
I am having some teething issues but highly impressed by the sheer volume of data and speed at which it is retrieved at our end.
I have two ways of populating the state-suburb comboboxes:
a) User chooses a country and I use the following functions:
function getplaces(gid, src) {
whichCombo = src;
$.getScript("http://api.geonames.org/childrenJSON?geonameId=" + gid + "&username=veemltd" + "&style=full&callback=newGetList");
}

function newGetList(jData) {
var counts = jData.geonames == null ? 0 : jData.geonames.length < jData.totalResultsCount ? jData.geonames.length : jData.totalResultsCount;
whichCombo.ClearItems();
whichCombo.SetEnabled(counts > 0);
if (counts > 0)
whichCombo.AddItem('Select');
else
whichCombo.AddItem('No data available', null);
for (var i = 0; i < counts; i++)
whichCombo.AddItem(jData.geonames[i].name, jData.geonames[i].geonameId);
whichCombo.SetSelectedIndex(0);
}

In first instance, I pass the country's geonameid and "statecombo" to get the states list - works fine
When user selects a state, I pass the state's geonameid and "suburbcombo" to get the suburbs list - this also works fine.

b) User chooses just a country and enters a post code.
Here I do a post code lookup and populate state and suburb values "geomagically" (smiles).
I use the following call to achieve this:
$.getScript('http://api.geonames.org/postalCodeLookupJSON?postalcode=' + enteredpostcode + '&country=' + selectedCountryCode + '&username=veemltd' + '&callback=CheckPostcodes');

My callback function is:
function CheckPostcodes(jData) {
var counts = jData.postalcodes == null ? 0 : jData.postalcodes.length;
if (counts == 0) {
ResetStateSuburb(false);
return;
}
if (stateCombo != null) {
stateCombo.SetEnabled(counts > 0);
stateCombo.ClearItems();
stateCombo.AddItem(jData.postalcodes[0].adminName1);
stateCombo.SetSelectedIndex(0);
}
if (suburbCombo != null) {
suburbCombo.SetEnabled(counts > 0);
suburbCombo.ClearItems();
for (var i = 0; i < counts; i++)
suburbCombo.AddItem(jData.postalcodes[i].placeName, jData.postalcodes[i].placeName);
suburbCombo.SetSelectedIndex(0);
}
}

What I have noticed is as per example below:
Case 1:
I choose NETHERLANDS as country (geonameid-2750405).
I get suburb list including "North Holland" which I choose to get all suburbs/regions/cities.
In children list (suburbs/cities) I get "Gemeente Amsterdam" as one of the choices.
Case 2:
I choose NETHERLANDS as country.
I enter "1078 NL" as postcode
What I get is below:
State = Provincie Noord-Holland
and
Suburb/city = Amsterdam Oud Zuid en Rivierenbuurt

Is there a way we can consistently match the data obtained by both the methods?
That way we will be able to synchronise our data consistently.
Do drop in a line when you can please, much appreciated.
Regards
Dhaval
 
Forum Index -> Administrative Divisions
Go to:   
Powered by JForum 2.1.5 © JForum Team