diff --git a/autotest/gdrivers/eedai.py b/autotest/gdrivers/eedai.py index 0780ccfc1b35..c226d506e1ea 100644 --- a/autotest/gdrivers/eedai.py +++ b/autotest/gdrivers/eedai.py @@ -740,7 +740,7 @@ def test_eedai_real_service(): ds = gdal.Open('EEDAI:USDA/NAIP/DOQQ/n_4010064_se_14_2_20070725') assert ds is not None res = gdal.Info(ds, format='json') - expected = {'files': [], 'cornerCoordinates': {'upperRight': [415016.0, 4435536.0], 'lowerLeft': [408970.0, 4427936.0], 'lowerRight': [415016.0, 4427936.0], 'upperLeft': [408970.0, 4435536.0], 'center': [411993.0, 4431736.0]}, 'wgs84Extent': {'type': 'Polygon', 'coordinates': [[]]}, 'description': 'EEDAI:USDA/NAIP/DOQQ/n_4010064_se_14_2_20070725', 'driverShortName': 'EEDAI', 'driverLongName': 'Earth Engine Data API Image', 'bands': [{'description': 'R', 'band': 1, 'colorInterpretation': 'Red', 'overviews': [{'size': [1511, 1900]}, {'size': [755, 950]}, {'size': [377, 475]}, {'size': [188, 237]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}, {'description': 'G', 'band': 2, 'colorInterpretation': 'Green', 'overviews': [{'size': [1511, 1900]}, {'size': [755, 950]}, {'size': [377, 475]}, {'size': [188, 237]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}, {'description': 'B', 'band': 3, 'colorInterpretation': 'Blue', 'overviews': [{'size': [1511, 1900]}, {'size': [755, 950]}, {'size': [377, 475]}, {'size': [188, 237]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}], 'coordinateSystem': {'wkt': 'PROJCS["NAD83 / UTM zone 14N",\n GEOGCS["NAD83",\n DATUM["North_American_Datum_1983",\n SPHEROID["GRS 1980",6378137,298.257222101,\n AUTHORITY["EPSG","7019"]],\n TOWGS84[0,0,0,0,0,0,0],\n AUTHORITY["EPSG","6269"]],\n PRIMEM["Greenwich",0,\n AUTHORITY["EPSG","8901"]],\n UNIT["degree",0.0174532925199433,\n AUTHORITY["EPSG","9122"]],\n AUTHORITY["EPSG","4269"]],\n PROJECTION["Transverse_Mercator"],\n PARAMETER["latitude_of_origin",0],\n PARAMETER["central_meridian",-99],\n PARAMETER["scale_factor",0.9996],\n PARAMETER["false_easting",500000],\n PARAMETER["false_northing",0],\n UNIT["metre",1,\n AUTHORITY["EPSG","9001"]],\n AXIS["Easting",EAST],\n AXIS["Northing",NORTH],\n AUTHORITY["EPSG","26914"]]'}, 'geoTransform': [408970.0, 2.0, 0.0, 4435536.0, 0.0, -2.0], 'metadata': {'IMAGE_STRUCTURE': {'INTERLEAVE': 'PIXEL'}}, 'size': [3023, 3800]} + expected = {'files': [], 'cornerCoordinates': {'upperRight': [415016.0, 4435536.0], 'lowerLeft': [408970.0, 4427936.0], 'lowerRight': [415016.0, 4427936.0], 'upperLeft': [408970.0, 4435536.0], 'center': [411993.0, 4431736.0]}, 'wgs84Extent': {'type': 'Polygon', 'coordinates': [[[-100.067433, 40.0651671], [-100.0663662, 39.9967049], [-99.9955511, 39.9973349], [-99.9965471, 40.0657986], [-100.067433, 40.0651671]]]}, 'description': 'EEDAI:USDA/NAIP/DOQQ/n_4010064_se_14_2_20070725', 'driverShortName': 'EEDAI', 'driverLongName': 'Earth Engine Data API Image', 'bands': [{'description': 'R', 'band': 1, 'colorInterpretation': 'Red', 'overviews': [{'size': [1511, 1900]}, {'size': [755, 950]}, {'size': [377, 475]}, {'size': [188, 237]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}, {'description': 'G', 'band': 2, 'colorInterpretation': 'Green', 'overviews': [{'size': [1511, 1900]}, {'size': [755, 950]}, {'size': [377, 475]}, {'size': [188, 237]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}, {'description': 'B', 'band': 3, 'colorInterpretation': 'Blue', 'overviews': [{'size': [1511, 1900]}, {'size': [755, 950]}, {'size': [377, 475]}, {'size': [188, 237]}], 'type': 'Byte', 'block': [256, 256], 'metadata': {}}], 'coordinateSystem': {'wkt': 'PROJCS["NAD83 / UTM zone 14N",\n GEOGCS["NAD83",\n DATUM["North_American_Datum_1983",\n SPHEROID["GRS 1980",6378137,298.257222101,\n AUTHORITY["EPSG","7019"]],\n TOWGS84[0,0,0,0,0,0,0],\n AUTHORITY["EPSG","6269"]],\n PRIMEM["Greenwich",0,\n AUTHORITY["EPSG","8901"]],\n UNIT["degree",0.0174532925199433,\n AUTHORITY["EPSG","9122"]],\n AUTHORITY["EPSG","4269"]],\n PROJECTION["Transverse_Mercator"],\n PARAMETER["latitude_of_origin",0],\n PARAMETER["central_meridian",-99],\n PARAMETER["scale_factor",0.9996],\n PARAMETER["false_easting",500000],\n PARAMETER["false_northing",0],\n UNIT["metre",1,\n AUTHORITY["EPSG","9001"]],\n AXIS["Easting",EAST],\n AXIS["Northing",NORTH],\n AUTHORITY["EPSG","26914"]]'}, 'geoTransform': [408970.0, 2.0, 0.0, 4435536.0, 0.0, -2.0], 'metadata': {'IMAGE_STRUCTURE': {'INTERLEAVE': 'PIXEL'}}, 'size': [3023, 3800]} assert expected == res assert ds.ReadRaster(0, 0, 1, 1) is not None diff --git a/autotest/ogr/ogr_eeda.py b/autotest/ogr/ogr_eeda.py index 2104010d3875..f3db998fbf43 100644 --- a/autotest/ogr/ogr_eeda.py +++ b/autotest/ogr/ogr_eeda.py @@ -210,7 +210,6 @@ def test_eeda_2(): lyr.SetAttributeFilter(None) lyr.SetAttributeFilter("startTime >= '1980-01-01T00:00:00Z' AND " + - "startTime <= '2100-01-01T00:00:00Z' AND " + "string_field = 'bar' AND " + "int_field > 0 AND " + "int_field < 2 AND " + @@ -220,7 +219,7 @@ def test_eeda_2(): "string_field IN ('bar', 'baz') AND " + "NOT( int_field IN (0) OR double_field IN (3.5) )") - ogrtest.eeda_drv_tmpfile = '/vsimem/ee/projects/earthengine-public/assets/collection:listImages?region=%7B%20%22type%22%3A%20%22Polygon%22%2C%20%22coordinates%22%3A%20%5B%20%5B%20%5B%20%2D180%2E0%2C%20%2D90%2E0%20%5D%2C%20%5B%20%2D180%2E0%2C%2090%2E0%20%5D%2C%20%5B%20180%2E0%2C%2090%2E0%20%5D%2C%20%5B%20180%2E0%2C%20%2D90%2E0%20%5D%2C%20%5B%20%2D180%2E0%2C%20%2D90%2E0%20%5D%20%5D%20%5D%20%7D&filter=%28%28%28%28%28%28%28string%5Ffield%20%3D%20%22bar%22%20AND%20int%5Ffield%20%3E%200%29%20AND%20int%5Ffield%20%3C%202%29%20AND%20int64%5Ffield%20%3E%3D%200%29%20AND%20int64%5Ffield%20%3C%3D%209999999999999%29%20AND%20double%5Ffield%20%21%3D%203%2E5%29%20AND%20string%5Ffield%20%3D%20%22bar%22%20OR%20string%5Ffield%20%3D%20%22baz%22%29%20AND%20%28NOT%20%28int%5Ffield%20%3D%200%20OR%20double%5Ffield%20%3D%203%2E5%29%29%29&startTime=1980%2D01%2D01T00%3A00%3A00Z&endTime=2100%2D01%2D01T00%3A00%3A00Z' + ogrtest.eeda_drv_tmpfile = '/vsimem/ee/projects/earthengine-public/assets/collection:listImages?region=%7B%20%22type%22%3A%20%22Polygon%22%2C%20%22coordinates%22%3A%20%5B%20%5B%20%5B%20%2D180%2E0%2C%20%2D90%2E0%20%5D%2C%20%5B%20%2D180%2E0%2C%2090%2E0%20%5D%2C%20%5B%20180%2E0%2C%2090%2E0%20%5D%2C%20%5B%20180%2E0%2C%20%2D90%2E0%20%5D%2C%20%5B%20%2D180%2E0%2C%20%2D90%2E0%20%5D%20%5D%20%5D%20%7D&filter=%28%28%28%28%28%28%28string%5Ffield%20%3D%20%22bar%22%20AND%20int%5Ffield%20%3E%200%29%20AND%20int%5Ffield%20%3C%202%29%20AND%20int64%5Ffield%20%3E%3D%200%29%20AND%20int64%5Ffield%20%3C%3D%209999999999999%29%20AND%20double%5Ffield%20%21%3D%203%2E5%29%20AND%20string%5Ffield%20%3D%20%22bar%22%20OR%20string%5Ffield%20%3D%20%22baz%22%29%20AND%20%28NOT%20%28int%5Ffield%20%3D%200%20OR%20double%5Ffield%20%3D%203%2E5%29%29%29&startTime=1980%2D01%2D01T00%3A00%3A00Z' gdal.FileFromMemBuffer(ogrtest.eeda_drv_tmpfile, json.dumps({ 'images': [ { @@ -254,14 +253,15 @@ def test_eeda_2(): lyr.SetSpatialFilter(None) # Test time equality with second granularity - lyr.SetAttributeFilter("startTime = '1980-01-01T00:00:00Z'") + lyr.SetAttributeFilter("startTime >= '1980-01-01T00:00:00Z' AND endTime <= '1980-01-02T23:59:00Z'") ogrtest.eeda_drv_tmpfile = '/vsimem/ee/projects/earthengine-public/assets/collection:listImages?startTime=1980%2D01%2D01T00%3A00%3A00Z&endTime=1980%2D01%2D01T00%3A00%3A01Z' gdal.FileFromMemBuffer(ogrtest.eeda_drv_tmpfile, json.dumps({ 'images': [ { 'name': 'projects/earthengine-public/assets/collection/filtered_feature', - 'startTime': '1980-01-01T00:00:00Z' + 'startTime': '1980-01-01T00:00:00Z', + 'endTime': '1980-01-02T23:59:59Z' }, { 'name': 'projects/earthengine-public/assets/collection/second_feature' @@ -275,14 +275,15 @@ def test_eeda_2(): assert f.GetField('name') == 'projects/earthengine-public/assets/collection/filtered_feature' # Test time equality with day granularity - lyr.SetAttributeFilter("startTime = '1980-01-01'") + lyr.SetAttributeFilter("startTime = '1980-01-01' AND endTime = '1980-01-02'") - ogrtest.eeda_drv_tmpfile = '/vsimem/ee/projects/earthengine-public/assets/collection:listImages?startTime=1980%2D01%2D01T00%3A00%3A00Z&endTime=1980%2D01%2D01T23%3A59%3A59Z' + ogrtest.eeda_drv_tmpfile = '/vsimem/ee/projects/earthengine-public/assets/collection:listImages?startTime=1980%2D01%2D01T00%3A00%3A00Z&endTime=1980%2D01%2D02T23%3A59%3A59Z' gdal.FileFromMemBuffer(ogrtest.eeda_drv_tmpfile, json.dumps({ 'images': [ { 'name': 'projects/earthengine-public/assets/collection/filtered_feature', 'startTime': '1980-01-01T12:00:00Z', + 'endTime': '1980-01-02T23:59:59Z' }, { 'name': 'projects/earthengine-public/assets/collection/second_feature' diff --git a/gdal/frmts/eeda/drv_eeda.html b/gdal/frmts/eeda/drv_eeda.html index d2a0f6bf7e70..fa43fb9671eb 100644 --- a/gdal/frmts/eeda/drv_eeda.html +++ b/gdal/frmts/eeda/drv_eeda.html @@ -89,7 +89,8 @@

Attributes

idStringImage ID; equivalent to name without the "projects/*/assets/" prefix (e.g. users/USER/ASSET)No pathString(Deprecated) Image path; equivalent to idNo gdal_datasetStringGDAL dataset name (e.g. EEDAI:projects/earthengine-public/assets/COPERNICUS/S2/20170430T190351_20170430T190351_T10SEG)
that can be opened with the Google Earth Engine Data API Image driverNo -timeDateTimeAcquisition dateYes +startTimeDateTimeAcquisition start dateYes (restricted to >= comparison on top level) +endTimeDateTimeAcquisition end dateYes (restricted to <= comparison on top level) updateTimeDateTimeUpdate dateNo sizeBytesInteger64File size in bytesNo band_countIntegerNumber of bandsNo @@ -154,7 +155,7 @@

Examples

  • Listing all images available matching criteria :
    -ogrinfo -ro -al "EEDA:projects/earthengine-public/assets/COPERNICUS/S2" -where "time >= '2015/03/26 00:00:00' AND CLOUDY_PIXEL_PERCENTAGE < 10" --config EEDA_CLIENT_EMAIL "my@email" --config EEDA_PRIVATE_KEY_FILE my.pem
    +ogrinfo -ro -al "EEDA:projects/earthengine-public/assets/COPERNICUS/S2" -where "startTime >= '2015/03/26 00:00:00' AND endTime <= '2015/06/30 00:00:00' AND CLOUDY_PIXEL_PERCENTAGE < 10" --config EEDA_CLIENT_EMAIL "my@email" --config EEDA_PRIVATE_KEY_FILE my.pem
     

    diff --git a/gdal/frmts/eeda/eedadataset.cpp b/gdal/frmts/eeda/eedadataset.cpp index 4b9ad69ac4c4..73b9e13b1f6a 100644 --- a/gdal/frmts/eeda/eedadataset.cpp +++ b/gdal/frmts/eeda/eedadataset.cpp @@ -793,8 +793,7 @@ CPLString GDALEEDALayer::BuildFilter(swq_expr_node* poNode, bool bIsAndTopLevel) else if( bIsAndTopLevel && poNode->eNodeType == SNT_OPERATION && (poNode->nOperation == SWQ_EQ || - poNode->nOperation == SWQ_GE || - poNode->nOperation == SWQ_LE) && + poNode->nOperation == SWQ_GE) && poNode->nSubExprCount == 2 && poNode->papoSubExpr[0]->eNodeType == SNT_COLUMN && poNode->papoSubExpr[1]->eNodeType == SNT_CONSTANT && @@ -802,46 +801,53 @@ CPLString GDALEEDALayer::BuildFilter(swq_expr_node* poNode, bool bIsAndTopLevel) m_poFeatureDefn->GetFieldIndex("startTime") && poNode->papoSubExpr[1]->field_type == SWQ_TIMESTAMP ) { - if( poNode->nOperation == SWQ_GE || poNode->nOperation == SWQ_EQ ) + int nTerms = GDALEEDALayerParseDateTime(poNode->papoSubExpr[1]->string_value, + SWQ_GE, + nYear, nMonth, nDay, nHour, nMinute, nSecond); + if( nTerms >= 3 ) { - int nTerms = GDALEEDALayerParseDateTime(poNode->papoSubExpr[1]->string_value, - SWQ_GE, - nYear, nMonth, nDay, nHour, nMinute, nSecond); - if( nTerms >= 3 ) - { - m_osStartTime = CPLSPrintf("%04d-%02d-%02dT%02d:%02d:%02dZ", - nYear, nMonth, nDay, nHour, nMinute, nSecond); - } - else - { - m_bFilterMustBeClientSideEvaluated = true; - } + m_osStartTime = CPLSPrintf("%04d-%02d-%02dT%02d:%02d:%02dZ", + nYear, nMonth, nDay, nHour, nMinute, nSecond); } - if( poNode->nOperation == SWQ_LE || poNode->nOperation == SWQ_EQ ) + else { - int nTerms = GDALEEDALayerParseDateTime(poNode->papoSubExpr[1]->string_value, - SWQ_LE, - nYear, nMonth, nDay, nHour, nMinute, nSecond); - if( nTerms >= 3 ) - { - if( poNode->nOperation == SWQ_EQ && nTerms == 6 ) - { - if( nSecond < 59 ) - nSecond ++; - else if( nMinute < 59 ) - nMinute ++; - else if( nHour < 23 ) - nHour ++; - else - nDay ++; - } - m_osEndTime = CPLSPrintf("%04d-%02d-%02dT%02d:%02d:%02dZ", - nYear, nMonth, nDay, nHour, nMinute, nSecond); - } - else + m_bFilterMustBeClientSideEvaluated = true; + } + return ""; + } + else if( bIsAndTopLevel && + poNode->eNodeType == SNT_OPERATION && + (poNode->nOperation == SWQ_EQ || + poNode->nOperation == SWQ_LE) && + poNode->nSubExprCount == 2 && + poNode->papoSubExpr[0]->eNodeType == SNT_COLUMN && + poNode->papoSubExpr[1]->eNodeType == SNT_CONSTANT && + poNode->papoSubExpr[0]->field_index == + m_poFeatureDefn->GetFieldIndex("endTime") && + poNode->papoSubExpr[1]->field_type == SWQ_TIMESTAMP ) + { + int nTerms = GDALEEDALayerParseDateTime(poNode->papoSubExpr[1]->string_value, + SWQ_LE, + nYear, nMonth, nDay, nHour, nMinute, nSecond); + if( nTerms >= 3 ) + { + if( poNode->nOperation == SWQ_EQ && nTerms == 6 ) { - m_bFilterMustBeClientSideEvaluated = true; + if( nSecond < 59 ) + nSecond ++; + else if( nMinute < 59 ) + nMinute ++; + else if( nHour < 23 ) + nHour ++; + else + nDay ++; } + m_osEndTime = CPLSPrintf("%04d-%02d-%02dT%02d:%02d:%02dZ", + nYear, nMonth, nDay, nHour, nMinute, nSecond); + } + else + { + m_bFilterMustBeClientSideEvaluated = true; } return ""; }