Skip to content

Commit

Permalink
Fix bbox multiple array and add two more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Oct 17, 2019
1 parent d7ac0bc commit 6fed2fa
Show file tree
Hide file tree
Showing 18 changed files with 248 additions and 48 deletions.
16 changes: 8 additions & 8 deletions resources/server/api/ogc/templates/wfs3/describeCollection.html
Expand Up @@ -18,13 +18,13 @@ <h3>Available CRSs</h3>
<h3>Extent</h3>
<dl>
<dd>West</dd>
<dt>{{ extent.spatial.0.0 }}</dt>
<dt>{{ extent.spatial.bbox.0.0 }}</dt>
<dd>South</dd>
<dt>{{ extent.spatial.0.1 }}</dt>
<dt>{{ extent.spatial.bbox.0.1 }}</dt>
<dd>East</dd>
<dt>{{ extent.spatial.0.2 }}</dt>
<dt>{{ extent.spatial.bbox.0.2 }}</dt>
<dd>North</dd>
<dt>{{ extent.spatial.0.3 }}</dt>
<dt>{{ extent.spatial.bbox.0.3 }}</dt>
</dl>

</div>
Expand All @@ -38,10 +38,10 @@ <h3>Extent</h3>
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map)
var west = {{ extent.spatial.0.0 }};
var south = {{ extent.spatial.0.1 }};
var east = {{ extent.spatial.0.2 }};
var north = {{ extent.spatial.0.3 }};
var west = {{ extent.spatial.bbox.0.0 }};
var south = {{ extent.spatial.bbox.0.1 }};
var east = {{ extent.spatial.bbox.0.2 }};
var north = {{ extent.spatial.bbox.0.3 }};
var p1 = new L.LatLng(south, west);
var p2 = new L.LatLng(north, west);
var p3 = new L.LatLng(north, east);
Expand Down
4 changes: 2 additions & 2 deletions src/server/services/wfs3/qgswfs3handlers.cpp
Expand Up @@ -491,7 +491,7 @@ void QgsWfs3CollectionsHandler::handleRequest( const QgsServerApiContext &contex
"extent", {
{
"spatial", {
{ "bbox", json::array( { QgsServerApiUtils::layerExtent( layer ) } ) },
{ "bbox", QgsServerApiUtils::layerExtent( layer ) },
{ "crs", "http://www.opengis.net/def/crs/OGC/1.3/CRS84" },
}
}
Expand Down Expand Up @@ -656,7 +656,7 @@ void QgsWfs3DescribeCollectionHandler::handleRequest( const QgsServerApiContext
"extent", {
{
"spatial", {
{ "bbox", json::array( { QgsServerApiUtils::layerExtent( mapLayer ) } ) },
{ "bbox", QgsServerApiUtils::layerExtent( mapLayer ) },
{ "crs", "http://www.opengis.net/def/crs/OGC/1.3/CRS84" },
}
}
Expand Down
14 changes: 14 additions & 0 deletions tests/src/python/test_qgsserver_api.py
Expand Up @@ -343,6 +343,20 @@ def test_wfs3_collections_content_type(self):
self.server.handleRequest(request, response, project)
self.assertEqual(response.headers()['Content-Type'], 'text/html')

def test_wfs3_collection_json(self):
"""Test WFS3 API collection"""
project = QgsProject()
project.read(unitTestDataPath('qgis_server') + '/test_project_api.qgs')
request = QgsBufferServerRequest('http://server.qgis.org/wfs3/collections/testlayer%20èé')
self.compareApi(request, project, 'test_wfs3_collection_testlayer_èé.json')

def test_wfs3_collection_html(self):
"""Test WFS3 API collection"""
project = QgsProject()
project.read(unitTestDataPath('qgis_server') + '/test_project_api.qgs')
request = QgsBufferServerRequest('http://server.qgis.org/wfs3/collections/testlayer%20èé.html')
self.compareApi(request, project, 'test_wfs3_collection_testlayer_èé.html')

def test_wfs3_collection_items(self):
"""Test WFS3 API items"""
project = QgsProject()
Expand Down
@@ -0,0 +1,144 @@
<!-- template for the WFS3 API collection page -->
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css"
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
crossorigin=""/>
<link rel="stylesheet" href="/wfs3/static/style.css" />
<script src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<link rel="stylesheet" href="/wfs3/static/jsonFormatter.min.css" crossorigin="anonymous"></script>
<script src="/wfs3/static/jsonFormatter.min.js" crossorigin="anonymous"></script>

<title>A test vector layer èé</title>
</head>
<body>
<nav class="navbar navbar-light bg-light navbar-expand-sm">
<div class="container">
<div id="navbar" class="navbar-collapse collapse d-flex justify-content-between align-items-center">
<ol class="breadcrumb bg-light my-0 pl-0">

<li class="breadcrumb-item"><a href="http://server.qgis.org/wfs3" >Landing page</a></li>

<li class="breadcrumb-item"><a href="http://server.qgis.org/wfs3/collections" >Collections</a></li>

<li class="breadcrumb-item active">
A test vector layer èé
</li>
</ol>
<ul class="list-unstyled list-separated m-0 p-0 text-muted">

<li><a rel="alternate" href="http://server.qgis.org/wfs3/collections/testlayer%20%C3%A8%C3%A9.json" target="_blank">JSON</a></li>

</ul>
</div>


</div>
</nav>
<div class="container pt-4">
<!-- END HEADER TEMPLATE header.html -->


<div class="row">
<div class="col-md-6">
<h1><a title="View items of: A test vector layer èé" href="
http://server.qgis.org/wfs3/collections/testlayer%20%C3%A8%C3%A9/items.html
">A test vector layer èé</a></h1>
<h3>Available CRSs</h3>
<ul>

<li>http://www.opengis.net/def/crs/OGC/1.3/CRS84</li>

<li>http://www.opengis.net/def/crs/EPSG/9.6.2/4326</li>

<li>http://www.opengis.net/def/crs/EPSG/9.6.2/3857</li>

</ul>

<h3>Extent</h3>
<dl>
<dd>West</dd>
<dt>8.203459307036344</dt>
<dd>South</dd>
<dt>44.90139483904469</dt>
<dd>East</dd>
<dt>8.203546993993488</dt>
<dd>North</dd>
<dt>44.901482526001836</dt>
</dl>

</div>

<div class="col-md-6">
<div id="mapid" class="small"></div>

<script type="text/javascript">
jQuery( document ).ready(function( $ ) {
var map = L.map('mapid').setView([0, 0], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map)
var west = 8.203459307036344;
var south = 44.90139483904469;
var east = 8.203546993993488;
var north = 44.901482526001836;
var p1 = new L.LatLng(south, west);
var p2 = new L.LatLng(north, west);
var p3 = new L.LatLng(north, east);
var p4 = new L.LatLng(south, east);
var polygonPoints = [p1, p2, p3, p4];

var jl = new L.Polygon(polygonPoints).addTo(map);
map.setView(jl.getBounds().getCenter());
if ( jl.getBounds().getEast() != jl.getBounds().getWest() && jl.getBounds().getNorth() != jl.getBounds().getSouth() )
{
map.fitBounds(jl.getBounds());
}

});

</script>
</div>

</div>

<!-- FOOTER TEMPLATE footer.html -->
</div> <!-- //container -->

<footer class="footer bg-light py-4 d-flex flex-column justify-content-around align-items-center">
<div class="container d-flex flex-row justify-content-between align-items-center w-100">
<span><span class="text-muted small mr-2">powered by</span><a class="navbar-brand" href="https://www.qgis.org/" target="_blank">QGIS Server</a></span>
</div>
</footer>

<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<!-- Make sure you put this AFTER Leaflet's CSS -->
<script src="https://unpkg.com/leaflet@1.5.1/dist/leaflet.js"
integrity="sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og=="
crossorigin=""></script>
<script>
jQuery('.jref').jsonFormatter();
</script>
</body>
</html>

@@ -0,0 +1,51 @@
Content-Type: application/json

{
"crs": [
"http://www.opengis.net/def/crs/OGC/1.3/CRS84",
"http://www.opengis.net/def/crs/EPSG/9.6.2/4326",
"http://www.opengis.net/def/crs/EPSG/9.6.2/3857"
],
"extent": {
"spatial": {
"bbox": [
[
8.203459307036344,
44.90139483904469,
8.203546993993488,
44.901482526001836
]
],
"crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
}
},
"id": "testlayer èé",
"links": [
{
"href": "http://server.qgis.org/wfs3/collections/testlayer%20%C3%A8%C3%A9.json",
"rel": "self",
"title": "Feature collection as JSON",
"type": "application/json"
},
{
"href": "http://server.qgis.org/wfs3/collections/testlayer%20%C3%A8%C3%A9.html",
"rel": "alternate",
"title": "Feature collection as HTML",
"type": "text/html"
},
{
"href": "http://server.qgis.org/wfs3/collections/testlayer%20%C3%A8%C3%A9/items.json",
"rel": "items",
"title": "A test vector layer èé",
"type": "application/json"
},
{
"href": "http://server.qgis.org/wfs3/collections/testlayer%20%C3%A8%C3%A9/items.html",
"rel": "items",
"title": "A test vector layer èé",
"type": "text/html"
}
],
"timeStamp": "2019-10-16T13:53:56Z",
"title": "A test vector layer èé"
}
Expand Up @@ -19,6 +19,5 @@ Content-Type: application/json
"type": "text/html"
}
],
"timeStamp": "2019-10-16T11:45:21Z"
"timeStamp": "2019-10-16T12:32:01Z"
"timeStamp": "2019-10-16T13:53:56Z"
}
Expand Up @@ -27,6 +27,6 @@ Content-Type: application/geo+json
"id": 1,
"utf8nameè": "one èé"
},
"timeStamp": "2019-10-16T12:32:02Z",
"timeStamp": "2019-10-16T13:53:57Z",
"type": "Feature"
}
Expand Up @@ -35,6 +35,6 @@ Content-Type: application/geo+json
],
"numberMatched": 1,
"numberReturned": 1,
"timeStamp": "2019-10-16T12:32:03Z",
"timeStamp": "2019-10-16T13:53:57Z",
"type": "FeatureCollection"
}
Expand Up @@ -35,6 +35,6 @@ Content-Type: application/geo+json
],
"numberMatched": 1,
"numberReturned": 1,
"timeStamp": "2019-10-16T12:32:02Z",
"timeStamp": "2019-10-16T13:53:57Z",
"type": "FeatureCollection"
}
Expand Up @@ -67,6 +67,6 @@ Content-Type: application/geo+json
],
"numberMatched": 3,
"numberReturned": 3,
"timeStamp": "2019-10-16T12:32:00Z",
"timeStamp": "2019-10-16T13:53:55Z",
"type": "FeatureCollection"
}
Expand Up @@ -35,6 +35,6 @@ Content-Type: application/geo+json
],
"numberMatched": 1,
"numberReturned": 1,
"timeStamp": "2019-10-16T12:32:00Z",
"timeStamp": "2019-10-16T13:53:55Z",
"type": "FeatureCollection"
}
Expand Up @@ -51,6 +51,6 @@ Content-Type: application/geo+json
],
"numberMatched": 2,
"numberReturned": 2,
"timeStamp": "2019-10-16T12:32:00Z",
"timeStamp": "2019-10-16T13:53:55Z",
"type": "FeatureCollection"
}
Expand Up @@ -67,6 +67,6 @@ Content-Type: application/geo+json
],
"numberMatched": 3,
"numberReturned": 3,
"timeStamp": "2019-10-16T12:32:01Z",
"timeStamp": "2019-10-16T13:53:55Z",
"type": "FeatureCollection"
}
Expand Up @@ -42,6 +42,6 @@ Content-Type: application/geo+json
],
"numberMatched": 3,
"numberReturned": 1,
"timeStamp": "2019-10-16T12:32:01Z",
"timeStamp": "2019-10-16T13:53:55Z",
"type": "FeatureCollection"
}
Expand Up @@ -49,6 +49,6 @@ Content-Type: application/geo+json
],
"numberMatched": 3,
"numberReturned": 1,
"timeStamp": "2019-10-16T12:32:01Z",
"timeStamp": "2019-10-16T13:53:55Z",
"type": "FeatureCollection"
}

0 comments on commit 6fed2fa

Please sign in to comment.