func PointInPolygon(ctx *gin.Context, conn *store.Connection, lat float64, lon float64) store.Response { chans := make([]<-chan int64, 0) search := geo.NewPoint(lat, lon) resp := conn.ListKeys(Constituency{}) keys := resp.Data.([]*datastore.Key) for _, k := range keys { if Cache[k.IntID()] == nil { con := &Constituency{Id: k.IntID()} resp = conn.Get(con) Cache[k.IntID()] = BuildPolygon(con) } chans = append(chans, Process(k.IntID(), search)) } resp.Data = new(map[string]string) for n := range merge(chans) { if n != 0 { con := &Constituency{Id: n} resp = conn.Get(con) con.Points = nil resp.Data = con } } return resp }