Hello guys,
I am trying to store documents with location in GeoJSON format
Code:
....
"location" : {
"type" : "Point",
"coordinates" : [longitude, latitude]
}
...
However, after data are persisted, in SOME cases order of these coordinates is not kept. The problem is, that I am creating geospatial "2dsphere" index on "location" field and if order is not preserved, I can't use geo queries at all :(.
From what I have read so far, mongo driver should keep order of items within array during persistence. Am I missing something or ?
Java code of GeoJSON object in my application:
Code:
@Embeddable
public class GeoJSON {
/**
* Geo object type
*/
private String type;
/**
* List of coordinates [lon, lat]
*/
@ElementCollection(fetch = FetchType.EAGER)
private List<Double> coordinates;
}
Thanks in advance!