How to implement georeferenced MapQuickItem

354 views Asked by At

I'm implementing a QtLocation based map to display sort of a heatmap, with colored areas ("pixels") on the map. One pixel of this heatmap covers around 100*100m area, therefore there can be a huge amount of them. My first attempt to implement this was to use a MapRectangle item for each pixel, by setting the color of each pixel according to its value, but with a fully loaded map the performance degraded drastically. What I'm trying to implement now is to partition the data into groups of these pixels, where each pixel is painted with OpenGL in my QQuickItem subclass called ColorTileItem. This ColorTileItem is used as a sourceItem of a MapQuickItem, which is a delegate of a MapItemView fed by my model called colorTileModel. The colorTimeModel's item is one "tile", and carries the number of pixels in the tile, the color of each pixel, and the coordinates. My QML code currently looks like as:

MapItemView
{
    id:colorTileView
    model: colorTileModel

     delegate: MapQuickItem
     {
           id: tile
           coordinate: model.item.centralcoordinate
           zoomLevel: mapBase.zoomLevel
           visible: true
           sourceItem: ColorTileItem
           {
               id: colorcell
               width:  10
               height: 10
               opacity: 1
               visible: true
               tile: model.item

           }
     }
}

My problem is that these tile items need to be properly georeferenced, to cover an exact area of the map, regardless of the zoom level, but for the MapQuickItem expects its size as pixel values, rather than distance on the map. I was experimenting with different zoomLevel values, but (obviously) it works correctly only on a specific zoomlevel of the parent map. Is there any way to set the size of the MapQuickItem in meters, or set the corners of the MapQuickItem as geocoordinates (as in MapRectangle)?

A handy solution would be to subclass QDeclarativeRectangleMapItem or maybe QDeclarativeGeoMapItemBase, but unfortunately those are private classes, and i would like to avoid to rely on a specific Qt version, if possible.

0

There are 0 answers