Geocoding API: Overriding preferences (Java) - geo_addressing_sdk - 5.0

Geo Addressing SDK Developer Guide

Product type
Software
Portfolio
Locate
Product family
Geo Addressing
Product
Geo Addressing SDK
Version
5.0
Language
English
Product name
Geo Addressing SDK
Title
Geo Addressing SDK Developer Guide
Copyright
2023
First publish date
2007
Last updated
2024-09-12
Published on
2024-09-12T14:50:21.470801

Scenario

We want to return one candidate in the Thai language, within 100 feet of the point. Call the reverse geocoding java api and override the preferences for search distance and max candidates.

Request

double latitude = 16.471625;
double longitude = 99.53375;

String coordsysName = "epsg:4326";

Preferences preferences = new GeocoderPreferences();
preferences.setReturnAllCandidateInfo(true);
preferences.setClientLocale(Locale.forLanguageTag("th-TH"));
preferences.setDistance(100);
preferences.setDistanceUnits(DistanceUnit.FEET);
preferences.setMaxReturnedCandidates(1);

System.out.println("number of matches: " + response.getTotalPossibleCandidates());  
if (response.getTotalMatches() > 0) {  
for (Candidate candidate : response.getCandidates())

{ System.out.println("mainAddressLine: " + candidate.getFormattedStreetAddress()); 
System.out.println("addressLastLine: " + candidate.getFormattedLocationAddress());
System.out.println("precisionCode: " + candidate.getPrecisionCode());
System.out.println("latitude:" + candidate.getPoint().getY());
System.out.println("longitude:" + candidate.getPoint().getX()); }

}

Response

number of matches: 1
mainAddressLine: ถนนบำรุงราษฎร์
addressLastLine: ในเมือง จ.กำแพงเพชร 62000
precisionCode: RS4A
latitude:16.471625
longitude:99.53375