From ea4813b438cd009925d71c01c266f8a31aec2044 Mon Sep 17 00:00:00 2001 From: Remi Cresson <remi.cresson@irstea.fr> Date: Thu, 14 Apr 2022 16:05:11 +0200 Subject: [PATCH] REFAC: big refactoring --- scenes/dates.py | 4 ++++ scenes/indexation.py | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/scenes/dates.py b/scenes/dates.py index 4622b82..7cbe206 100644 --- a/scenes/dates.py +++ b/scenes/dates.py @@ -5,6 +5,10 @@ This module aims to deal with dates import datetime +MINDATE = datetime.datetime.strptime("1000-01-01", "%Y-%m-%d") +MAXDATE = datetime.datetime.strptime("3000-01-01", "%Y-%m-%d") + + def get_timestamp(dt): """Converts datetime.datetime into a timestamp (in seconds) diff --git a/scenes/indexation.py b/scenes/indexation.py index 7ddc8d6..cd0ee5f 100644 --- a/scenes/indexation.py +++ b/scenes/indexation.py @@ -3,7 +3,7 @@ This module contains stuff for the spatio-temporal indexation of scenes """ import datetime import rtree -from scenes.dates import get_timestamp, any2datetime +from scenes.dates import get_timestamp, any2datetime, MINDATE, MAXDATE from scenes.vector import reproject_ogr_layer, get_bbox_wgs84, ogr_open from scenes.spatial import poly_overlap @@ -64,9 +64,9 @@ class Index: """ if not date_min: - date_min = datetime.datetime.strptime("2000-01-01", "%Y-%m-%d") + date_min = MINDATE if not date_max: - date_max = datetime.datetime.strptime("3000-01-01", "%Y-%m-%d") + date_max = MAXDATE # Use the bounding box from the vector data, or from the specified one actual_bbox_wgs84 = vector_or_bbox -- GitLab