ntquach closed pull request #11: SDAP-41 Update NEXUS tile service to apply a 
mask for start/end time
URL: https://github.com/apache/incubator-sdap-nexus/pull/11
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/data-access/nexustiles/nexustiles.py 
b/data-access/nexustiles/nexustiles.py
index 1330c03..1568f16 100644
--- a/data-access/nexustiles/nexustiles.py
+++ b/data-access/nexustiles/nexustiles.py
@@ -219,12 +219,16 @@ def get_tiles_bounded_by_box(self, min_lat, max_lat, 
min_lon, max_lon, ds=None,
                                  **kwargs):
         tiles = self.find_tiles_in_box(min_lat, max_lat, min_lon, max_lon, ds, 
start_time, end_time, **kwargs)
         tiles = self.mask_tiles_to_bbox(min_lat, max_lat, min_lon, max_lon, 
tiles)
+        if 0 < start_time <= end_time:
+            tiles = self.mask_tiles_to_time_range(start_time, end_time, tiles)
 
         return tiles
 
     def get_tiles_bounded_by_polygon(self, polygon, ds=None, start_time=0, 
end_time=-1, **kwargs):
         tiles = self.find_tiles_in_polygon(polygon, ds, start_time, end_time, 
**kwargs)
         tiles = self.mask_tiles_to_polygon(polygon, tiles)
+        if 0 < start_time <= end_time:
+            tiles = self.mask_tiles_to_time_range(start_time, end_time, tiles)
 
         return tiles
 
@@ -238,19 +242,19 @@ def get_dataset_overall_stats(self, ds):
 
     def get_tiles_bounded_by_box_at_time(self, min_lat, max_lat, min_lon, 
max_lon, dataset, time, **kwargs):
         tiles = self.find_all_tiles_in_box_at_time(min_lat, max_lat, min_lon, 
max_lon, dataset, time, **kwargs)
-        tiles = self.mask_tiles_to_bbox(min_lat, max_lat, min_lon, max_lon, 
tiles)
+        tiles = self.mask_tiles_to_bbox_and_time(min_lat, max_lat, min_lon, 
max_lon, time, time, tiles)
 
         return tiles
 
     def get_tiles_bounded_by_polygon_at_time(self, polygon, dataset, time, 
**kwargs):
         tiles = self.find_all_tiles_in_polygon_at_time(polygon, dataset, time, 
**kwargs)
-        tiles = self.mask_tiles_to_polygon(polygon, tiles)
+        tiles = self.mask_tiles_to_polygon_and_time(polygon, time, time, tiles)
 
         return tiles
 
     def get_boundary_tiles_at_time(self, min_lat, max_lat, min_lon, max_lon, 
dataset, time, **kwargs):
         tiles = self.find_all_boundary_tiles_at_time(min_lat, max_lat, 
min_lon, max_lon, dataset, time, **kwargs)
-        tiles = self.mask_tiles_to_bbox(min_lat, max_lat, min_lon, max_lon, 
tiles)
+        tiles = self.mask_tiles_to_bbox_and_time(min_lat, max_lat, min_lon, 
max_lon, time, time, tiles)
 
         return tiles
 
@@ -322,11 +326,9 @@ def mask_tiles_to_bbox(self, min_lat, max_lat, min_lon, 
max_lon, tiles):
 
         return tiles
 
-    def mask_tiles_to_polygon(self, bounding_polygon, tiles):
-
-        min_lon, min_lat, max_lon, max_lat = bounding_polygon.bounds
-
+    def mask_tiles_to_bbox_and_time(self, min_lat, max_lat, min_lon, max_lon, 
start_time, end_time, tiles):
         for tile in tiles:
+            tile.times = ma.masked_outside(tile.times, start_time, end_time)
             tile.latitudes = ma.masked_outside(tile.latitudes, min_lat, 
max_lat)
             tile.longitudes = ma.masked_outside(tile.longitudes, min_lon, 
max_lon)
 
@@ -341,6 +343,17 @@ def mask_tiles_to_polygon(self, bounding_polygon, tiles):
 
         return tiles
 
+    def mask_tiles_to_polygon(self, bounding_polygon, tiles):
+
+        min_lon, min_lat, max_lon, max_lat = bounding_polygon.bounds
+
+        return self.mask_tiles_to_bbox(min_lat, max_lat, min_lon, max_lon, 
tiles)
+
+    def mask_tiles_to_polygon_and_time(self, bounding_polygon, start_time, 
end_time, tiles):
+        min_lon, min_lat, max_lon, max_lat = bounding_polygon.bounds
+
+        return self.mask_tiles_to_bbox_and_time(min_lat, max_lat, min_lon, 
max_lon, start_time, end_time, tiles)
+
     def mask_tiles_to_time_range(self, start_time, end_time, tiles):
         """
         Masks data in tiles to specified time range.


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to