From d055098540df99a5d426360e9322c659e678e5ee Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Wed, 27 Nov 2019 15:37:07 +0100 Subject: Enable mercator-to-screen projection in GLSL With this change, all the geo-to-screen conversion, and the triangulation operations for geo polylines and geo polygon are performed either at set time or in the shader. A separate bounding box geometry is processed in the old way to provide a correct QtQuick Item geometry, that can be used for nesting mouse areas, performing translations, input event delivery, etc. With this approach, performance are improved by more than one order of magnitude in average, but complex geometries will of course benefit more. It also adds correct rendering support for polygons with holes, previously only rendered correctly by the MapboxGL plugin. The polyline shader has basic miter joins. The miter is skipped if the angle is too sharp to avoid complicating the implementation. This shader introduces some glitches when the polyline is minified, for which the real fix is to have LOD for the geometry, and render simplified geometries at low zoom levels (added in a subsequent patch). Note: this approach, at least in its current implementation, does not support enabling layers on individual items, only on the Map element. Task-number: QTBUG-49303 Task-number: QTBUG-38459 Change-Id: I0c2dc0bf364d32f74ca7c4014f6d66e6219c8ae4 Reviewed-by: Alexandru Croitor --- .../location/geojson_viewer/GeoJsonDelegate.qml | 12 +++++++---- examples/location/geojson_viewer/main.qml | 23 ++++++++++++++++++++-- 2 files changed, 29 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/location/geojson_viewer/GeoJsonDelegate.qml b/examples/location/geojson_viewer/GeoJsonDelegate.qml index ff0fbffa..afbafe95 100644 --- a/examples/location/geojson_viewer/GeoJsonDelegate.qml +++ b/examples/location/geojson_viewer/GeoJsonDelegate.qml @@ -51,14 +51,15 @@ import QtQuick 2.12 import QtPositioning 5.12 -import QtLocation 5.12 +import QtLocation 5.15 import Qt.labs.qmlmodels 1.0 DelegateChooser { id: dc role: "type" property color defaultColor: "grey" - property real defaultOpacity: 0.7 + property real defaultOpacity: 0.6 + property bool openGLBackends: false DelegateChoice { roleValue: "Point" @@ -82,8 +83,9 @@ DelegateChooser { delegate: MapPolyline { property string geojsonType: "LineString" property var props: modelData.properties + backend: (dc.openGLBackends) ? MapPolyline.OpenGLExtruded : MapPolyline.Software geoShape: modelData.data - line.width: 3 + line.width: 4 opacity: dc.defaultOpacity line.color: (props && props.color) || (parent && parent.props && parent.props.color) || dc.defaultColor } @@ -97,7 +99,9 @@ DelegateChooser { geoShape: modelData.data opacity: dc.defaultOpacity color: (props && props.color) || (parent && parent.props && parent.props.color) || dc.defaultColor - border.width: 0 + border.width: 4 + border.color: 'black' + backend: (dc.openGLBackends) ? MapPolygon.OpenGL : MapPolygon.Software MouseArea { anchors.fill: parent onClicked: { diff --git a/examples/location/geojson_viewer/main.qml b/examples/location/geojson_viewer/main.qml index 01faef5f..b2fc3524 100644 --- a/examples/location/geojson_viewer/main.qml +++ b/examples/location/geojson_viewer/main.qml @@ -61,11 +61,13 @@ import Qt.labs.qmlmodels 1.0 import Qt.GeoJson 1.0 C1.ApplicationWindow { + id: win visible: true width: 1024 height: 1024 menuBar: mainMenu title: qsTr("GeoJSON Viewer") + property bool openGLBackends: glBackendSelector.checked FileDialog { visible: false @@ -141,6 +143,12 @@ C1.ApplicationWindow { geoJsoner.print(miv) } } + C1.MenuItem { + text: "&OpenGL Item backends" + id: glBackendSelector + checkable: true + checked: false + } } } @@ -149,17 +157,28 @@ C1.ApplicationWindow { id: geoJsoner } + Shortcut { + sequence: "Ctrl+P" + onActivated: { + + console.log("Center : QtPositioning.coordinate(",map.center.latitude,",",map.center.longitude,")") + console.log("Zoom : ",map.zoomLevel) + } + } + Map { id: map anchors.fill: parent center: QtPositioning.coordinate(43.59, 13.50) // Starting coordinates: Ancona, the city where I am studying :) - plugin: Plugin { name: "mapboxgl" } + plugin: Plugin { name: "osm" } zoomLevel: 4 MapItemView { id: miv model: geoJsoner.model - delegate: GeoJsonDelegate {} + delegate: GeoJsonDelegate { + openGLBackends: win.openGLBackends + } } } } -- cgit v1.2.3