How to implement georeferenced MapQuickItem












1















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.










share|improve this question

























  • if your item doesn't have to be deformed, you can easily calculate meters to pixels at a given zoom level. So you can fix the "zoomLevel" property of the MQI to the appropriate value once you computed it.

    – Pa_
    Nov 29 '18 at 14:06
















1















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.










share|improve this question

























  • if your item doesn't have to be deformed, you can easily calculate meters to pixels at a given zoom level. So you can fix the "zoomLevel" property of the MQI to the appropriate value once you computed it.

    – Pa_
    Nov 29 '18 at 14:06














1












1








1








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.










share|improve this question
















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.







qt qml qtlocation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 11:44









eyllanesc

77.5k103156




77.5k103156










asked Nov 14 '18 at 8:48









zgyarmatizgyarmati

30729




30729













  • if your item doesn't have to be deformed, you can easily calculate meters to pixels at a given zoom level. So you can fix the "zoomLevel" property of the MQI to the appropriate value once you computed it.

    – Pa_
    Nov 29 '18 at 14:06



















  • if your item doesn't have to be deformed, you can easily calculate meters to pixels at a given zoom level. So you can fix the "zoomLevel" property of the MQI to the appropriate value once you computed it.

    – Pa_
    Nov 29 '18 at 14:06

















if your item doesn't have to be deformed, you can easily calculate meters to pixels at a given zoom level. So you can fix the "zoomLevel" property of the MQI to the appropriate value once you computed it.

– Pa_
Nov 29 '18 at 14:06





if your item doesn't have to be deformed, you can easily calculate meters to pixels at a given zoom level. So you can fix the "zoomLevel" property of the MQI to the appropriate value once you computed it.

– Pa_
Nov 29 '18 at 14:06












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53296143%2fhow-to-implement-georeferenced-mapquickitem%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53296143%2fhow-to-implement-georeferenced-mapquickitem%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma