我正在尝试从简短的开放位置代码中获取完整的开放位置代码,我做错了什么?我在我的 android 项目中使用 Java Open Location Code -library。
// 63.7740574, 23.9011008
// This is an full olc (I searched it from web)
// input = "9GM5QWF2+JC";
// This is an short olc (also searched from the web)
// input = "QWF2+JC";
// And this is an olc which is copied to clipboard from google maps application
input = "QWF2+JC Hautala";
boolean isFullCode = OpenLocationCode.isFullCode(input);
boolean isShortCode = OpenLocationCode.isShortCode(input);
if (isFullCode || isShortCode)
{
OpenLocationCode olc = new OpenLocationCode(input);
Double lat = olc.decode().getCenterLatitude(); // Crashes here if we are parsing input to short code
Double lng = olc.decode().getCenterLatitude(); // But doesn't crash if we are using full lenght code
result = new LatLng(lat, lng);
}