示例#1
0
def test_query_hits_sqlite_geopackage(config_sqlite):
    """Testing hits results type for sqlite/geopackage"""

    p = SQLiteGPKGProvider(config_sqlite)
    results = p.query(resulttype="hits")
    assert results["numberMatched"] == 177
    results = p.query(bbox=[28.3373, -5.4099, 32.3761, -3.3924],
                      properties=[("continent", "Africa")],
                      resulttype="hits")
    assert results["numberMatched"] == 3
示例#2
0
def test_get_geopackage_skip_geometry(config_geopackage):
    """Testing query for skipped geometry"""
    p = SQLiteGPKGProvider(config_geopackage)

    feature_collection = p.query(skip_geometry=True)
    for feature in feature_collection['features']:
        assert feature['geomtry'] is None
示例#3
0
def test_query_with_property_filter_bbox_sqlite_geopackage(config_sqlite):
    """Test query  valid features when filtering by property"""
    p = SQLiteGPKGProvider(config_sqlite)
    feature_collection = p.query(properties=[("continent", "Europe")],
                                 bbox=[29.3373, -3.4099, 29.3761, -3.3924])
    features = feature_collection.get('features', None)
    assert len(features) == 0
示例#4
0
def test_query_with_property_filter_sqlite_geopackage(config_sqlite):
    """Test query  valid features when filtering by property"""

    p = SQLiteGPKGProvider(config_sqlite)
    feature_collection = p.query(properties=[("continent", "Europe")],
                                 limit=100)
    features = feature_collection.get('features', None)
    assert len(features) == 39
示例#5
0
def test_query_bbox_geopackage(config_geopackage):
    """Test query with a specified bounding box"""

    psp = SQLiteGPKGProvider(config_geopackage)
    boxed_feature_collection = psp.query(
        bbox=[-16.3991310876, 33.0063015781, -16.3366454278, 33.0560854323]
    )

    assert len(boxed_feature_collection['features']) == 5
示例#6
0
def test_query_bbox_sqlite_geopackage(config_sqlite):
    """Test query with a specified bounding box"""

    psp = SQLiteGPKGProvider(config_sqlite)
    boxed_feature_collection = psp.query(
        bbox=[29.3373, -3.4099, 29.3761, -3.3924])

    assert len(boxed_feature_collection['features']) == 1
    assert 'Burundi' in \
        boxed_feature_collection['features'][0]['properties']['name']
示例#7
0
def test_query_with_property_filter_bbox_geopackage(config_geopackage):
    """Test query  valid features when filtering by property"""
    p = SQLiteGPKGProvider(config_geopackage)
    feature_collection = p.query(properties=[("fclass", "cafe")],
                                 bbox=[
                                     -16.3991310876,
                                     33.0063015781,
                                     -16.3366454278,
                                     33.0560854323
                                     ])
    features = feature_collection.get('features', None)
    assert len(features) == 0
示例#8
0
def test_query_geopackage(config_geopackage):
    """Testing query for a valid JSON object with geometry for geopackage"""

    p = SQLiteGPKGProvider(config_geopackage)
    feature_collection = p.query()
    assert feature_collection.get('type', None) == 'FeatureCollection'
    features = feature_collection.get('features', None)
    assert features is not None
    feature = features[0]
    properties = feature.get('properties', None)
    assert properties is not None
    geometry = feature.get('geometry', None)
    assert geometry is not None