def find_all_tiles_within_box_at_time()

in data-access/nexustiles/dao/ElasticsearchProxy.py [0:0]


    def find_all_tiles_within_box_at_time(self, min_lat, max_lat, min_lon, max_lon, ds, time, **kwargs):

        the_time = datetime.utcfromtimestamp(time).strftime(ELASTICSEARCH_FORMAT)
        
        params = {
            "size": 1000,
            "query": {
                "bool": {
                    "filter": [
                        {
                            "term": {
                                "dataset_s": {
                                    "value": ds
                                }
                            }
                        },
                        {
                            "geo_shape": {
                                "geo": {
                                    "shape": {
                                        "type": "envelope",
                                        "coordinates": [[min_lon, max_lat],[max_lon, min_lat]]
                                    },
                                    "relation": "within"
                                }
                            }
                        },
                        {
                            "range": {
                                "tile_count_i": {
                                    "gte": 1
                                }
                            }
                        },
                        { 
                            "range": {
                                "tile_min_time_dt": {
                                    "lte": the_time
                                }
                            } 
                        },
                        { 
                            "range": {
                                "tile_max_time_dt": {
                                    "gte": the_time
                                }
                            }
                        }
                    ]
                }
            }
        }


        self._merge_kwargs(params, **kwargs)

        return self.do_query_all(*(None, "product(tile_avg_val_d, tile_count_i),*", None, False, None), **params)