Esempio n. 1
0
    def test_date_utc_eq(self):
        value = date(2019, 8, 6)
        texas_utc_offset = timezone(timedelta(hours=-6))
        time_filter = utils.pb_timestampfield(
            rel_type=enum.FilterRelationship.EQ,
            value=value,
            tzinfo=texas_utc_offset)

        stac_request = StacRequest(datetime=time_filter, limit=2)

        # get a client interface to the gRPC channel
        for stac_item in client.search(stac_request):
            print("STAC item date, {0}, is before {1}: {2}".format(
                datetime.fromtimestamp(stac_item.observed.seconds,
                                       tz=timezone.utc).isoformat(),
                datetime.fromtimestamp(time_filter.end.seconds,
                                       tz=texas_utc_offset).isoformat(),
                stac_item.observed.seconds < time_filter.end.seconds))

        start = date(2019, 8, 6)
        time_filter = utils.pb_timestampfield(rel_type=FilterRelationship.EQ,
                                              value=start,
                                              tzinfo=timezone(
                                                  timedelta(hours=-6)))
        stac_request = StacRequest(datetime=time_filter, limit=2)
        count = 0
        for _ in client.search(stac_request):
            count += 1

        self.assertEqual(2, count)
Esempio n. 2
0
 def test_date_LT_OR_EQ(self):
     bd = date(2014, 11, 3)
     observed_range = utils.pb_timestampfield(
         rel_type=FilterRelationship.LTE, value=bd)
     stac_request = StacRequest(observed=observed_range,
                                mission_enum=enum.Mission.NAIP)
     stac_item = client.search_one(stac_request)
     self.assertIsNotNone(stac_item)
     self.assertLessEqual(
         utils.pb_timestamp(bd).seconds, stac_item.datetime.seconds)
 def set_updated(
         self,
         rel_type: enum.FilterRelationship,
         value: Union[datetime, date] = None,
         start: Union[datetime, date] = None,
         end: Union[datetime, date] = None,
         sort_direction: enum.SortDirection = enum.SortDirection.NOT_SORTED,
         tzinfo: timezone = timezone.utc):
     self._stac_data.updated.CopyFrom(
         utils.pb_timestampfield(rel_type=rel_type,
                                 value=value,
                                 start=start,
                                 end=end,
                                 sort_direction=sort_direction,
                                 tzinfo=tzinfo))
Esempio n. 4
0
    def test_2000(self):
        start = datetime(1999, 4, 1, 12, 45, 59, tzinfo=timezone.utc)
        end = datetime(1999, 4, 6, 12, 52, 59, tzinfo=timezone.utc)
        observed_range = utils.pb_timestampfield(
            rel_type=FilterRelationship.BETWEEN, start=start, end=end)

        stac_request = StacRequest(observed=observed_range,
                                   limit=20,
                                   landsat=LandsatRequest())
        for stac_item in client.search(stac_request):
            self.assertEqual(Mission.LANDSAT, stac_item.mission_enum)
            print(
                datetime.fromtimestamp(stac_item.datetime.seconds,
                                       tz=timezone.utc))
            self.assertGreaterEqual(
                utils.pb_timestamp(end).seconds, stac_item.datetime.seconds)
            self.assertLessEqual(
                utils.pb_timestamp(start).seconds, stac_item.datetime.seconds)

        self.assertEquals(2728, client.count(stac_request))