|
1 | 1 | """This subpackage contains the code that reads, writes, and processes data using GeoTrellis."""
|
2 | 2 | from collections import namedtuple
|
3 | 3 | import warnings
|
| 4 | +import datetime |
4 | 5 | import functools
|
5 | 6 | import datetime
|
6 | 7 | from shapely.geometry import box
|
|
9 | 10 | from geopyspark.geotrellis.constants import CellType, NO_DATA_INT
|
10 | 11 |
|
11 | 12 |
|
| 13 | +_EPOCH = datetime.datetime.utcfromtimestamp(0) |
| 14 | + |
| 15 | + |
| 16 | +def _convert_to_unix_time(date_time): |
| 17 | + return int((date_time - _EPOCH).total_seconds() * 1000) |
| 18 | + |
| 19 | + |
12 | 20 | def deprecated(func):
|
13 | 21 | """This is a decorator which can be used to mark functions
|
14 | 22 | as deprecated. It will result in a warning being emmitted
|
@@ -399,15 +407,12 @@ class Bounds(namedtuple("Bounds", 'minKey maxKey')):
|
399 | 407 | __slots__ = []
|
400 | 408 |
|
401 | 409 | def _asdict(self):
|
402 |
| - if isinstance(self.minKey, dict): |
403 |
| - min_key_dict = self.minKey |
404 |
| - else: |
405 |
| - min_key_dict = self.minKey._asdict() |
| 410 | + min_key_dict = self.minKey._asdict() |
| 411 | + max_key_dict = self.maxKey._asdict() |
406 | 412 |
|
407 |
| - if isinstance(self.maxKey, dict): |
408 |
| - max_key_dict = self.maxKey |
409 |
| - else: |
410 |
| - max_key_dict = self.maxKey._asdict() |
| 413 | + if hasattr(self.minKey, 'instant'): |
| 414 | + min_key_dict['instant'] = _convert_to_unix_time(min_key_dict['instant']) |
| 415 | + max_key_dict['instant'] = _convert_to_unix_time(max_key_dict['instant']) |
411 | 416 |
|
412 | 417 | return {'minKey': min_key_dict, 'maxKey': max_key_dict}
|
413 | 418 |
|
|
0 commit comments