Closed foto-andreas closed 8 years ago
The java client does not parse the GeoJson string. It just sends the string to the server. The server needs to parse GeoJson independent of locale.
For anyone out there getting the exception "com.aerospike.client.AerospikeException: Error Code 160" (AS_PROTO_RESULT_FAIL_GEO_INVALID_GEOJSON)
use
String.format(Locale.ENGLISH,"{ \"type\": \"Point\", \"coordinates\": [%f, %f] }", plng, plat)
instead of
String.format("{ \"type\": \"Point\", \"coordinates\": [%f, %f] }", plng, plat)
@BrianNichols In my experience if you don't force java to use "English locale" in string formatting; the GeoJSON becomes i.e. { "type": "Point", "coordinates": [59,000000, 59,000000] } and application throws an exception at com.aerospike.client.command.WriteCommand.parseResult(WriteCommand.java:72)
.
(This may be reproduced on a windows PC having a locale that uses commas for decimal numbers)
//...
double plng=59;double plat=59;
String geoPointStr = String.format("{ \"type\": \"Point\", \"coordinates\": [%f, %f] }", plng, plat);
Bin newBin = new Bin("binName", Value.getAsGeoJSON(geoPointStr));
//...
see here: https://discuss.aerospike.com/t/error-code-204-index-error-in-small-geo-test-program/2484/5
under german locale settings this
new GeoJSONValue("{ \"type\": \"Point\", \"coordinates\": [50, 50] }"));
is parsed like ...[50.50]... which is not a valid point coordinate. The meaning "," and "." in numeric locale is swapped between LANG=de_DE.UTF-8 and LANG=C.Andreas