I just stumbled on this after struggling with the error: "GeoJSON coordinates must be in an array" and I finally solved my issue. Attention to detail is always key. It doesn't seem to make logical sense to me, but you have to use a 3d slice, not a 2d slice. This is probably obvious for people who write GIS queries or can look at documentation one time and catch every detail, but it wasn't obvious for me.
So the way I fixed it was to take my polygon: [][]float64 and insert it into a slice of interface: // box is my [][]float64 newBox := []interface{}{box} that did the trick. On Wednesday, February 3, 2016 at 6:44:44 AM UTC-5, Gustavo Niemeyer wrote: > > > Same way you'd do it in Go elsewhere: > > coords := [][][]int{{{0, 0}, {3, 6}, {6, 1}, {0, 0}}} > > > > On Tue, Feb 2, 2016 at 8:56 PM, CMC <car...@gmail.com <javascript:>> > wrote: > >> Hi there, sorry if I make mistakes but English is not my native language >> >> I have 4 slices as float64, do you know how I have to form "coordinates" >> field?? >> >> thanks >> >> db.places.find( >> { >> loc: { >> $geoWithin: { >> $geometry: { >> type : "Polygon" , >> coordinates: [ [ [ 0, 0 ], [ 3, 6 ], [ 6, 1 ], [ 0, 0 ] ] ] >> } >> } >> } >> } >> } >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > > gustavo @ http://niemeyer.net > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.