当前位置: 首页>>代码示例>>Python>>正文


Python SentinelAPI.format_query方法代码示例

本文整理汇总了Python中sentinelsat.SentinelAPI.format_query方法的典型用法代码示例。如果您正苦于以下问题:Python SentinelAPI.format_query方法的具体用法?Python SentinelAPI.format_query怎么用?Python SentinelAPI.format_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sentinelsat.SentinelAPI的用法示例。


在下文中一共展示了SentinelAPI.format_query方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_api_query_format_escape_spaces

# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import format_query [as 别名]
def test_api_query_format_escape_spaces(api):
    query = SentinelAPI.format_query(ingestiondate=('NOW-1DAY', 'NOW'))
    assert query == 'ingestiondate:[NOW-1DAY TO NOW]'

    query = SentinelAPI.format_query(ingestiondate='[NOW-1DAY TO NOW]')
    assert query == 'ingestiondate:[NOW-1DAY TO NOW]'

    query = SentinelAPI.format_query(ingestiondate=' [NOW-1DAY TO NOW] ')
    assert query == 'ingestiondate:[NOW-1DAY TO NOW]'

    query = SentinelAPI.format_query(relativeorbitnumber=' {101 TO 103} ')
    assert query == 'relativeorbitnumber:{101 TO 103}'

    query = SentinelAPI.format_query(filename='S3A_OL_2* ')
    assert query == 'filename:S3A_OL_2*'

    query = SentinelAPI.format_query(timeliness='Non Time Critical')
    assert query == r'timeliness:Non\ Time\ Critical'

    query = SentinelAPI.format_query(timeliness='Non\tTime\tCritical')
    assert query == r'timeliness:Non\ Time\ Critical'

    assert api.count(timeliness='Non Time Critical') > 0

    # Allow for regex weirdness
    query = SentinelAPI.format_query(timeliness='.+ Critical')
    assert query == r'timeliness:.+\ Critical'
    assert api.count(timeliness='.+ Critical') > 0

    query = SentinelAPI.format_query(identifier='/S[123 ]A.*/')
    assert query == r'identifier:/S[123 ]A.*/'
    assert api.count(identifier='/S[123 ]A.*/') > 0
开发者ID:valgur,项目名称:sentinelsat,代码行数:34,代码来源:test_mod.py

示例2: raw_products

# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import format_query [as 别名]
def raw_products():
    """A fixture for tests that need some non-specific set of products in the form of a raw response as input."""
    api = SentinelAPI(**_api_auth)
    raw_products = api._load_query(api.format_query(
        geojson_to_wkt(read_geojson('tests/map.geojson')),
        "20151219", "20151228")
    )
    return raw_products
开发者ID:ibamacsr,项目名称:sentinelsat,代码行数:10,代码来源:test_mod.py

示例3: raw_products

# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import format_query [as 别名]
def raw_products(api_kwargs, vcr, test_wkt):
    """A fixture for tests that need some non-specific set of products in the form of a raw response as input."""
    with vcr.use_cassette('products_fixture', decode_compressed_response=False):
        api = SentinelAPI(**api_kwargs)
        raw_products = api._load_query(
            api.format_query(test_wkt, ("20151219", "20151228"))
        )[0]
    return raw_products
开发者ID:valgur,项目名称:sentinelsat,代码行数:10,代码来源:conftest.py

示例4: test_api_query_format

# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import format_query [as 别名]
def test_api_query_format():
    api = SentinelAPI("mock_user", "mock_password")
    wkt = 'POLYGON((0 0,1 1,0 1,0 0))'

    now = datetime.now()
    last_24h = _format_query_date(now - timedelta(hours=24))
    query = api.format_query(wkt, initial_date=last_24h, end_date=now)
    assert query == '(beginPosition:[%s TO %s]) ' % (last_24h, _format_query_date(now)) + \
                    'AND (footprint:"Intersects(POLYGON((0 0,1 1,0 1,0 0)))")'

    query = api.format_query(wkt, end_date=now, producttype='SLC')
    assert query == '(beginPosition:[NOW-1DAY TO %s]) ' % (_format_query_date(now)) + \
                    'AND (footprint:"Intersects(POLYGON((0 0,1 1,0 1,0 0)))") ' + \
                    'AND (producttype:SLC)'

    query = api.format_query()
    assert query == '(beginPosition:[NOW-1DAY TO NOW])'

    query = api.format_query(area=None, initial_date=None, end_date=None)
    assert query == ''
开发者ID:ibamacsr,项目名称:sentinelsat,代码行数:22,代码来源:test_mod.py

示例5: test_api_query_format_ranges

# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import format_query [as 别名]
def test_api_query_format_ranges():
    query = SentinelAPI.format_query(cloudcoverpercentage=(0, 30))
    assert query == 'cloudcoverpercentage:[0 TO 30]'

    query = SentinelAPI.format_query(cloudcoverpercentage=[0, 30])
    assert query == 'cloudcoverpercentage:[0 TO 30]'

    with pytest.raises(ValueError):
        SentinelAPI.format_query(cloudcoverpercentage=[])

    with pytest.raises(ValueError):
        SentinelAPI.format_query(cloudcoverpercentage=[0])

    with pytest.raises(ValueError):
        SentinelAPI.format_query(cloudcoverpercentage=[0, 1, 2])
开发者ID:NiklasKeck,项目名称:sentinelsat,代码行数:17,代码来源:test_mod.py

示例6: test_api_query_format_with_duplicates

# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import format_query [as 别名]
def test_api_query_format_with_duplicates():
    with pytest.raises(ValueError) as excinfo:
        SentinelAPI.format_query(date=('NOW-1DAY', 'NOW'), beginPosition=('NOW-3DAY', 'NOW'))
    assert 'duplicate' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        SentinelAPI.format_query(ingestiondate=('NOW-1DAY', 'NOW'), ingestionDate=('NOW-3DAY', 'NOW'))
    assert 'duplicate' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        SentinelAPI.format_query(area='POINT(0, 0)', footprint='POINT(0, 0)')
    assert 'duplicate' in str(excinfo.value)
开发者ID:valgur,项目名称:sentinelsat,代码行数:14,代码来源:test_mod.py

示例7: test_api_query_format

# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import format_query [as 别名]
def test_api_query_format():
    wkt = 'POLYGON((0 0,1 1,0 1,0 0))'

    now = datetime.now()
    last_24h = format_query_date(now - timedelta(hours=24))
    query = SentinelAPI.format_query(wkt, (last_24h, now))
    assert query == 'beginPosition:[%s TO %s] ' % (last_24h, format_query_date(now)) + \
                    'footprint:"Intersects(POLYGON((0 0,1 1,0 1,0 0)))"'

    query = SentinelAPI.format_query(wkt, date=(last_24h, "NOW"), producttype='SLC', raw='IW')
    assert query == 'beginPosition:[%s TO NOW] ' % (format_query_date(last_24h)) + \
                    'producttype:SLC IW footprint:"Intersects(POLYGON((0 0,1 1,0 1,0 0)))"'

    query = SentinelAPI.format_query(wkt, producttype='SLC', raw='IW')
    assert query == 'producttype:SLC IW footprint:"Intersects(POLYGON((0 0,1 1,0 1,0 0)))"'

    query = SentinelAPI.format_query(area=None, date=None)
    assert query == ''

    query = SentinelAPI.format_query()
    assert query == ''

    query = SentinelAPI.format_query(raw='test')
    assert query == 'test'
开发者ID:NiklasKeck,项目名称:sentinelsat,代码行数:26,代码来源:test_mod.py

示例8: test_api_query_format_dates

# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import format_query [as 别名]
def test_api_query_format_dates():
    query = SentinelAPI.format_query(ingestiondate=('NOW-1DAY', 'NOW'))
    assert query == 'ingestiondate:[NOW-1DAY TO NOW]'

    query = SentinelAPI.format_query(ingestiondate=(date(2017, 1, 1), '20170203'))
    assert query == 'ingestiondate:[2017-01-01T00:00:00Z TO 2017-02-03T00:00:00Z]'

    query = SentinelAPI.format_query(ingestiondate='[NOW-1DAY TO NOW]')
    assert query == 'ingestiondate:[NOW-1DAY TO NOW]'

    with pytest.raises(ValueError):
        SentinelAPI.format_query(date="NOW")

    with pytest.raises(ValueError):
        SentinelAPI.format_query(date=["NOW"])

    with pytest.raises(ValueError):
        SentinelAPI.format_query(ingestiondate=[])

    with pytest.raises(ValueError):
        SentinelAPI.format_query(ingestiondate=[None, 'NOW'])
开发者ID:NiklasKeck,项目名称:sentinelsat,代码行数:23,代码来源:test_mod.py

示例9: test_api_query_format_ranges

# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import format_query [as 别名]
def test_api_query_format_ranges():
    query = SentinelAPI.format_query(cloudcoverpercentage=(0, 30))
    assert query == 'cloudcoverpercentage:[0 TO 30]'

    query = SentinelAPI.format_query(cloudcoverpercentage=[0, 30])
    assert query == 'cloudcoverpercentage:[0 TO 30]'

    query = SentinelAPI.format_query(cloudcoverpercentage=[None, 30])
    assert query == 'cloudcoverpercentage:[* TO 30]'

    query = SentinelAPI.format_query(orbitnumber=(16302, None))
    assert query == 'orbitnumber:[16302 TO *]'

    query = SentinelAPI.format_query(orbitnumber=(16302, '*'))
    assert query == 'orbitnumber:[16302 TO *]'

    for value in [(None, None), ('*', None), (None, '*'), ('*', '*')]:
        query = SentinelAPI.format_query(orbitnumber=value)
        assert query == ''

    with pytest.raises(ValueError):
        SentinelAPI.format_query(cloudcoverpercentage=[])

    with pytest.raises(ValueError):
        SentinelAPI.format_query(cloudcoverpercentage=[0])

    with pytest.raises(ValueError):
        SentinelAPI.format_query(cloudcoverpercentage=[0, 1, 2])
开发者ID:valgur,项目名称:sentinelsat,代码行数:30,代码来源:test_mod.py


注:本文中的sentinelsat.SentinelAPI.format_query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。