Discussion:
Geocoding Stepdown...
(too old to reply)
markthegrea
2009-02-24 19:06:01 UTC
Permalink
I am attempting to geocode specific addresses, and have come across several
stopping points...

When I do a search on kenabunkport, maine usa

I get:
latitude="39.449999928474426" longitude="-98.90799969434738"

which is the middle of Kansas. It does not seem to step down, AND, most
other API's correct spelling to some extent.

1. Does VE correct spelling (still talking about the web services here)?
2. Is there something I am doing wrong?

GeocodeServiceStub.Geocode geo = new GeocodeServiceStub.Geocode();
GeocodeServiceStub.GeocodeRequest gr = new
GeocodeServiceStub.GeocodeRequest();
GeocodeServiceStub.Credentials cred = new GeocodeServiceStub.Credentials();
cred.setToken(TokenStorage.getInstance().fetchToken("veToken"));
gr.setCredentials(cred);
gr.setCulture("en-US");

GeocodeServiceStub.Address address = new GeocodeServiceStub.Address();
address.setAddressLine(dlAddress.getStreetAddress());
address.setLocality(dlAddress.getCity());
address.setDistrict(dlAddress.getState());
address.setPostalCode(StringUtils.upperCase(dlAddress.getPostalCode()));
address.setCountryRegion(dlAddress.getCountry().getName());//not sure
// here.

if ("US".equals(dlAddress.getCountry().getISOCode()) ||
"CA".equals(dlAddress.getCountry().getISOCode())) {
if (StringUtils.isNotEmpty(dlAddress.getPostalCode())) {
address.setLocality("");
}
}

gr.setAddress(address);
//gr.setQuery("Kenabunkport maine");
geo.setRequest(gr);

GeocodeServiceStub.GeocodeResponse0 response = null;
try {
GeocodeServiceStub stub = new GeocodeServiceStub(CONTEXT);
response = stub.Geocode(geo);
stub._getServiceClient().cleanupTransport();
} catch (RemoteException re) {
cat.dds.webservice.ve.IGeocodeService_ReverseGeocode_ResponseSummaryFault_FaultMessage
mark =
(cat.dds.webservice.ve.IGeocodeService_ReverseGeocode_ResponseSummaryFault_FaultMessage) re.getCause()
System.out.println(mark.getFaultMessage().getResponseSummary().getFaultReason());
} catch (Exception e) {
e.printStackTrace();
}
markthegrea
2009-02-24 21:57:02 UTC
Permalink
I recieved the answer from Mappoint support...

One should use setQuery instead of setAddress. Put the data in this order
and format:

street, zip, state country

Notice no comma between state and country. Now the tech didn't tell me
where to put City, so I put it after the address. Seems to work much better.


I have also noticed that an incorrect zip throws this thing ito a tizzy, so
if geocoding fails, I remove it and try again!
Post by markthegrea
I am attempting to geocode specific addresses, and have come across several
stopping points...
When I do a search on kenabunkport, maine usa
latitude="39.449999928474426" longitude="-98.90799969434738"
which is the middle of Kansas. It does not seem to step down, AND, most
other API's correct spelling to some extent.
1. Does VE correct spelling (still talking about the web services here)?
2. Is there something I am doing wrong?
GeocodeServiceStub.Geocode geo = new GeocodeServiceStub.Geocode();
GeocodeServiceStub.GeocodeRequest gr = new
GeocodeServiceStub.GeocodeRequest();
GeocodeServiceStub.Credentials cred = new GeocodeServiceStub.Credentials();
cred.setToken(TokenStorage.getInstance().fetchToken("veToken"));
gr.setCredentials(cred);
gr.setCulture("en-US");
GeocodeServiceStub.Address address = new GeocodeServiceStub.Address();
address.setAddressLine(dlAddress.getStreetAddress());
address.setLocality(dlAddress.getCity());
address.setDistrict(dlAddress.getState());
address.setPostalCode(StringUtils.upperCase(dlAddress.getPostalCode()));
address.setCountryRegion(dlAddress.getCountry().getName());//not sure
// here.
if ("US".equals(dlAddress.getCountry().getISOCode()) ||
"CA".equals(dlAddress.getCountry().getISOCode())) {
if (StringUtils.isNotEmpty(dlAddress.getPostalCode())) {
address.setLocality("");
}
}
gr.setAddress(address);
//gr.setQuery("Kenabunkport maine");
geo.setRequest(gr);
GeocodeServiceStub.GeocodeResponse0 response = null;
try {
GeocodeServiceStub stub = new GeocodeServiceStub(CONTEXT);
response = stub.Geocode(geo);
stub._getServiceClient().cleanupTransport();
} catch (RemoteException re) {
cat.dds.webservice.ve.IGeocodeService_ReverseGeocode_ResponseSummaryFault_FaultMessage
mark =
(cat.dds.webservice.ve.IGeocodeService_ReverseGeocode_ResponseSummaryFault_FaultMessage) re.getCause();
System.out.println(mark.getFaultMessage().getResponseSummary().getFaultReason());
} catch (Exception e) {
e.printStackTrace();
}
Loading...