w3w java wrapper
3.1.21
What3words v3 api를 사용하는 Java 라이브러리.
API 메소드는 What3wordsv3 인스턴스로 중앙에서 관리 할 수있는 단일 서비스 객체로 그룹화됩니다. 모든 API 엔드 포인트의 공장 역할을하며 API 키로 자동 초기화됩니다.
API 키를 얻으려면 https://what3words.com/select-plan을 방문하여 계정에 가입하십시오.
아티팩트는 Maven Central을 통해 제공됩니다.
< dependency >
< groupId >com.what3words</ groupId >
< artifactId >w3w-java-wrapper</ artifactId >
< version >3.1.19</ version >
</ dependency >
구현 'com. What3words : W3W-Java-Wrapper : 3.1.19'
What3words 공개 API 문서를 참조하십시오
// For all requests a what3words API key is needed
What3WordsV3 api = new What3WordsV3 ( "what3words-api-key" );
// In the case that you run our Enterprise Suite API Server yourself, you may specify the URL to your own server like so:
//What3WordsV3 api = new What3WordsV3("what3words-api-key", "https://api.yourserver.com/v3/");
/**
* Additionally, if you run the Enterprise Suite API Server there is another optional setup() parameter: customHeaders.
* Use this if you need to send custom headers to your own server:
*/
//Map<String, String> headers = new HashMap<String, String>();
//headers.put("Name1", "Value1");
//headers.put("Name2", "Value2");
//What3WordsV3 api = new What3WordsV3("what3words-api-key", "https://api.yourserver.com/v3/", headers);
// Create and execute a request with the 3 word address such as "filled.count.soap"
ConvertToCoordinates coordinates = api . convertToCoordinates ( "filled.count.soap" ). execute ();
if ( coordinates . isSuccessful ()) { // the request was successful
System . out . println ( "Coordinates: " + coordinates );
} else { // the request was not successful
What3WordsError error = coordinates . getError ();
if ( error == What3WordsError . BAD_WORDS ) { // The three word address provided is invalid
System . out . println ( "BadWords: " + error . getMessage ());
} else if ( error == What3WordsError . INTERNAL_SERVER_ERROR ) { // Server Error
System . out . println ( "InternalServerError: " + error . getMessage ());
} else if ( error == What3WordsError . NETWORK_ERROR ) { // Network Error
System . out . println ( "NetworkError: " + error . getMessage ());
} else { // Unknown Error
System . out . println ( error + ": " + error . getMessage ());
}
}
문자열이 가능한지 확인하십시오. 이것이 텍스트의 형식을 확인하므로 가능한 What3words 주소인지 확인하기 위해 텍스트의 형식을 확인하므로 가능한 3WA라고합니다.
Boolean isPossible = What3WordsV3 . isPossible3wa ( "filled.count.soap" ); // returns true
Boolean isPossible = What3WordsV3 . isPossible3wa ( "not a 3wa" ); // returns false
Boolean isPossible = What3WordsV3 . isPossible3wa ( "not.3wa address" ); //returns false
문자열이 가능한지 확인하십시오 이것은 단지 텍스트 형식을 확인하므로 DidyouMean3WA라고 불리는 이유를 알리면 실제 What3words 주소인지 확인하십시오.
Boolean isDym = What3WordsV3 . didYouMean3wa ( "filled-count-soap" ); // returns true
Boolean isDym = What3WordsV3 . didYouMean3wa ( "not valid" ); // returns false
Boolean isDym = What3WordsV3 . didYouMean3wa ( "not.3wa address" ); // returns false
Boolean isDym = What3WordsV3 . didYouMean3wa ( "not.threewa address" ); // returns true
텍스트에서 3WORDS 주소가 가능한 모든 것을 얻으십시오. 가능한 주소가없는 경우 빈 목록을 반환합니다. 이것이 단지 텍스트 형식을 확인하므로 FindSoSsible3WA라고 불리는 이유를 알리십시오. 실제 What3words 주소인지 확인하십시오.
List < String > possible = What3WordsV3 . findPossible3wa ( "Please leave by my porch at filled.count.soap" ); //returns ["filled.count.soap"]
List < String > possible = What3WordsV3 . findPossible3wa ( "Please leave by my porch at filled.count.soap or deed.tulip.judge" ); // returns ["filled.count.soap", "deed.tulip.judge"]
List < String > possible = What3WordsV3 . findPossible3wa ( "Please leave by my porch at" ); // returns []