You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sdap.apache.org by nc...@apache.org on 2018/03/15 03:42:22 UTC

[incubator-sdap-nexus] branch master updated: SDAP-41 Update NEXUS tile service to apply a mask for start/end time (#11)

This is an automated email from the ASF dual-hosted git repository.

nchung pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-nexus.git


The following commit(s) were added to refs/heads/master by this push:
     new 556ddc1  SDAP-41 Update NEXUS tile service to apply a mask for start/end time (#11)
556ddc1 is described below

commit 556ddc1bd3ba9d3a54f8c9b87f78729746ead984
Author: Nga Quach <ng...@gmail.com>
AuthorDate: Wed Mar 14 20:42:20 2018 -0700

    SDAP-41 Update NEXUS tile service to apply a mask for start/end time (#11)
---
 data-access/nexustiles/nexustiles.py | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/data-access/nexustiles/nexustiles.py b/data-access/nexustiles/nexustiles.py
index 90622ae..c3b08cd 100644
--- a/data-access/nexustiles/nexustiles.py
+++ b/data-access/nexustiles/nexustiles.py
@@ -219,12 +219,16 @@ class NexusTileService(object):
                                  **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 @@ class NexusTileService(object):
 
     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 @@ class NexusTileService(object):
 
         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 @@ class NexusTileService(object):
 
         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.

-- 
To stop receiving notification emails like this one, please contact
nchung@apache.org.