Server OAPIF: expose XML schema for collections

Also make sure links to parent paths end with /
This commit is contained in:
Alessandro Pasotti 2019-11-08 14:40:44 +01:00
parent 9dbfb6a0e6
commit cadb7916b5
15 changed files with 57 additions and 25 deletions

View File

@ -55,7 +55,8 @@ as instances of QgsServerOgcApiHandler.
GEOJSON, GEOJSON,
OPENAPI3, OPENAPI3,
JSON, JSON,
HTML HTML,
XML
}; };
QgsServerOgcApi( QgsServerInterface *serverIface, QgsServerOgcApi( QgsServerInterface *serverIface,

View File

@ -33,6 +33,7 @@ QMap<QgsServerOgcApi::ContentType, QStringList> QgsServerOgcApi::sContentTypeMim
}; };
map[QgsServerOgcApi::ContentType::HTML] = QStringList { QStringLiteral( "text/html" ) }; map[QgsServerOgcApi::ContentType::HTML] = QStringList { QStringLiteral( "text/html" ) };
map[QgsServerOgcApi::ContentType::OPENAPI3] = QStringList { QStringLiteral( "application/openapi+json;version=3.0" ) }; map[QgsServerOgcApi::ContentType::OPENAPI3] = QStringList { QStringLiteral( "application/openapi+json;version=3.0" ) };
map[QgsServerOgcApi::ContentType::XML] = QStringList { QStringLiteral( "application/xml" ) };
return map; return map;
}(); }();

View File

@ -72,7 +72,8 @@ class SERVER_EXPORT QgsServerOgcApi : public QgsServerApi
GEOJSON, GEOJSON,
OPENAPI3, //! "application/openapi+json;version=3.0" OPENAPI3, //! "application/openapi+json;version=3.0"
JSON, JSON,
HTML HTML,
XML
}; };
Q_ENUM( ContentType ) Q_ENUM( ContentType )

View File

@ -122,6 +122,9 @@ void QgsServerOgcApiHandler::write( json &data, const QgsServerApiContext &conte
case QgsServerOgcApi::ContentType::OPENAPI3: case QgsServerOgcApi::ContentType::OPENAPI3:
jsonDump( data, context, QgsServerOgcApi::contentTypeMimes().value( contentType ).first() ); jsonDump( data, context, QgsServerOgcApi::contentTypeMimes().value( contentType ).first() );
break; break;
case QgsServerOgcApi::ContentType::XML:
// Not handled yet
break;
} }
} }
@ -512,6 +515,11 @@ QString QgsServerOgcApiHandler::parentLink( const QUrl &url, int levels )
qi.push_back( i ); qi.push_back( i );
} }
} }
// Make sure the parent link ends with a slash
if ( ! path.endsWith( '/' ) )
{
path.append( '/' );
}
result.setQueryItems( qi ); result.setQueryItems( qi );
result.setPath( path ); result.setPath( path );
return result.toString(); return result.toString();

View File

@ -637,16 +637,22 @@ void QgsWfs3DescribeCollectionHandler::handleRequest( const QgsServerApiContext
{ "rel", QgsServerOgcApi::relToString( QgsServerOgcApi::Rel::items ) }, { "rel", QgsServerOgcApi::relToString( QgsServerOgcApi::Rel::items ) },
{ "type", QgsServerOgcApi::mimeType( QgsServerOgcApi::ContentType::HTML ) }, { "type", QgsServerOgcApi::mimeType( QgsServerOgcApi::ContentType::HTML ) },
{ "title", title } { "title", title }
} } );
/* TODO: not sure what these "concepts" are about, neither if they are mandatory
,{ linksList.push_back(
{ "href", href( api, *context.request() , QStringLiteral( "/concepts" ), QStringLiteral( "html") ) }, {
{ "rel", QgsServerOgcApi::relToString( QgsServerOgcApi::Rel::item ) }, {
{ "type", "text/html" }, "href", parentLink( context.request()->url(), 3 ).toStdString() +
{ "title", "Describe " + title } "?request=DescribeFeatureType&typenames=" +
} QUrlQuery( shortName ).toString( QUrl::EncodeSpaces ).toStdString() +
*/ "&service=WFS&version=2.0"
); },
{ "rel", QgsServerOgcApi::relToString( QgsServerOgcApi::Rel::describedBy ) },
{ "type", QgsServerOgcApi::mimeType( QgsServerOgcApi::ContentType::XML ) },
{ "title", "Schema for " + title }
} );
json crss = json::array(); json crss = json::array();
for ( const auto &crs : QgsServerApiUtils::publishedCrsList( context.project() ) ) for ( const auto &crs : QgsServerApiUtils::publishedCrsList( context.project() ) )
{ {

View File

@ -1466,7 +1466,7 @@ Content-Type: application/openapi+json;version=3.0
}, },
"servers": [ "servers": [
{ {
"url": "http://server.qgis.org/wfs3" "url": "http://server.qgis.org/wfs3/"
} }
], ],
"tags": [ "tags": [
@ -1478,5 +1478,6 @@ Content-Type: application/openapi+json;version=3.0
"description": "Access to data (features).", "description": "Access to data (features).",
"name": "Features" "name": "Features"
} }
] ],
"timeStamp": "2019-07-05T12:27:07Z"
} }

View File

@ -53,8 +53,14 @@ Content-Type: application/json
"rel": "items", "rel": "items",
"title": "points", "title": "points",
"type": "text/html" "type": "text/html"
},
{
"href": "http://server.qgis.org/?request=DescribeFeatureType&typenames=points&service=WFS&version=2.0",
"rel": "describedBy",
"title": "Schema for points",
"type": "application/xml"
} }
], ],
"timeStamp": "2019-10-20T16:29:01Z", "timeStamp": "2019-07-05T12:27:07Z",
"title": "points" "title": "points"
} }

View File

@ -26,9 +26,9 @@
<div id="navbar" class="navbar-collapse collapse d-flex justify-content-between align-items-center"> <div id="navbar" class="navbar-collapse collapse d-flex justify-content-between align-items-center">
<ol class="breadcrumb bg-light my-0 pl-0"> <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/" >Landing page</a></li>
<li class="breadcrumb-item"><a href="http://server.qgis.org/wfs3/collections" >Collections</a></li> <li class="breadcrumb-item"><a href="http://server.qgis.org/wfs3/collections/" >Collections</a></li>
<li class="breadcrumb-item active"> <li class="breadcrumb-item active">
A test vector layer èé A test vector layer èé
@ -60,6 +60,8 @@
http://server.qgis.org/wfs3/collections/testlayer%20%C3%A8%C3%A9/items.html http://server.qgis.org/wfs3/collections/testlayer%20%C3%A8%C3%A9/items.html
">A test vector layer èé</a></h1> ">A test vector layer èé</a></h1>
<h3>Available CRSs</h3> <h3>Available CRSs</h3>
<ul> <ul>

View File

@ -48,8 +48,14 @@ Content-Type: application/json
"rel": "items", "rel": "items",
"title": "A test vector layer èé", "title": "A test vector layer èé",
"type": "text/html" "type": "text/html"
},
{
"href": "http://server.qgis.org/?request=DescribeFeatureType&typenames=testlayer%20èé&service=WFS&version=2.0",
"rel": "describedBy",
"title": "Schema for A test vector layer èé",
"type": "application/xml"
} }
], ],
"timeStamp": "2019-11-02T15:56:20Z", "timeStamp": "2019-07-05T12:27:07Z",
"title": "A test vector layer èé" "title": "A test vector layer èé"
} }

View File

@ -26,7 +26,7 @@
<div id="navbar" class="navbar-collapse collapse d-flex justify-content-between align-items-center"> <div id="navbar" class="navbar-collapse collapse d-flex justify-content-between align-items-center">
<ol class="breadcrumb bg-light my-0 pl-0"> <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/" >Landing page</a></li>
<li class="breadcrumb-item active"> <li class="breadcrumb-item active">
Feature collections Feature collections

View File

@ -290,7 +290,7 @@ Content-Type: application/geo+json
6880002.440273 6880002.440273
], ],
[ [
1194091.1897780001, 1194091.189778,
6880070.493797 6880070.493797
], ],
[ [
@ -440,7 +440,7 @@ Content-Type: application/geo+json
6882593.73528 6882593.73528
], ],
[ [
1190969.1369710001, 1190969.136971,
6881661.977825 6881661.977825
], ],
[ [
@ -994,6 +994,6 @@ Content-Type: application/geo+json
], ],
"numberMatched": 38, "numberMatched": 38,
"numberReturned": 10, "numberReturned": 10,
"timeStamp": "2019-11-02T15:56:20Z", "timeStamp": "2019-07-05T12:27:07Z",
"type": "FeatureCollection" "type": "FeatureCollection"
} }

View File

@ -994,6 +994,6 @@ Content-Type: application/geo+json
], ],
"numberMatched": 38, "numberMatched": 38,
"numberReturned": 10, "numberReturned": 10,
"timeStamp": "2019-11-02T15:56:20Z", "timeStamp": "2019-07-05T12:27:07Z",
"type": "FeatureCollection" "type": "FeatureCollection"
} }

View File

@ -67,6 +67,6 @@ Content-Type: application/geo+json
], ],
"numberMatched": 3, "numberMatched": 3,
"numberReturned": 3, "numberReturned": 3,
"timeStamp": "2019-11-02T15:56:20Z", "timeStamp": "2019-07-05T12:27:07Z",
"type": "FeatureCollection" "type": "FeatureCollection"
} }

View File

@ -26,7 +26,7 @@
<div id="navbar" class="navbar-collapse collapse d-flex justify-content-between align-items-center"> <div id="navbar" class="navbar-collapse collapse d-flex justify-content-between align-items-center">
<ol class="breadcrumb bg-light my-0 pl-0"> <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/" >Landing page</a></li>
<li class="breadcrumb-item active"> <li class="breadcrumb-item active">
Feature collections Feature collections