Select to view content in your preferred language

Overlaying a regularly changing image on a 2D map

1735
9
06-17-2021 04:38 AM
LeeCarter
Emerging Contributor

I am developing an application using Qt 15.1 and ArcGIS Runtime SDK v100.9.  The application is C++ and does not use any QML.

I have a MapGraphicsView with a basemap loaded and various GraphicsOverlay to which Graphic objects are being added and correctly displayed.

I have a dynamically generated QPixmap representing some sensor data that I want to display such that it is scaled to cover a known geographic area which can be described using an Envelope (i.e. it is a simple rectangular area with known lat/lon coordinates).  The QPixmap can easily be converted to a QImage, but the data is not available via a web service or as a file on disk.  The sensor data updates approximately once a second.

I am trying to find a sensible/suitable way to overlay this sensor data on the map such that it scales/stretches to fill the known area (rather than being tiled to fill the area) and it will be correctly resized when the map scale changes as the user zooms in/out.

My current implementation is using PictureMarkerSymbol but this is requiring me to manually resize the PictureMarkerSymbol when the map scale is changed and there seems to be a memory leak when the PictureMarkerSymbol is replaced with a new one for the new sensor data (even when I explicitly delete the old PictureMarkerSymbol).  Also using setScaleSymbols(true) does not cause the symbol to update as expected in terms of resizing the image.

I believe ImageOverlay class is only supported for 3D SceneViews and everything else I have found in the SDK appears to want the load the image via a URL with no option to use a QImage or similar for an image already in memory.

Can anyone suggest a different/better approach to the one that I am currently using?

0 Kudos
9 Replies
by Anonymous User
Not applicable

Hi Lee.

Sorry you're having trouble, you're right that ImageOverlay is only supported for 3d, we have several requests for it in 2d, it would be handy. Other users have tried to solve this same problem using PictureMarkerSymbol, and it's always a bit of a struggle.

Your best bet for right now might be to use a KmlGroundOverlay , which I believe supports both 2d and 3d displays. There is a sample here showing how to use this to display images on a scene, although the example should be pretty easily convertible into a 2d context.

Hope that helps

Elliot.

0 Kudos
LeeCarter
Emerging Contributor

Hi Elliot,

I looked at KmlGroundOverlay and it appears that it has to be used with KmlIcon which can only be constructed using a QUrl to reference the data to be displayed, but my data/image is in memory as it is generated on the fly at runtime.  I don't really want to be writing images to disk constantly in order to be able to load them via a QUrl which, unless I'm missing something, is what I would have to do - unless you can suggest something else?

0 Kudos
by Anonymous User
Not applicable

Hi Lee.

Yeah, that is the real issue isn't it. What you really want is a 2D-capable ImageOverlay...

I was discussing this issue with some colleagues, and the concept came up to use a QImageProvider to create a QUrl that references an in-memory image, which you could then use to construct the icon. We're not really sure if this will work or not, as it's not a workflow we've ever explored before, but I thought I'd mention it as perhaps worth a look. You mention in your first post that you're not using QML as well, and it looks like this approach might require you to go through a QML object, alas.

Other than that, this does look to be an area where the api could use some enhancements.

0 Kudos
FatmaAkdemir
Frequent Contributor

Hi @LeeCarter ,

I just wanted to say that we had a similar problem like yours and we solved it by using ImageOverlay. We had a constantly changing QImage coming from network as raw data and we managed to display it on SceneGraphicsView. You can convert QPixmap to QImage if you want to use ImageOverlay.

void MainMapWidget::slotRadarImageChanged(const QImage &image){
	 std::unique_ptr<ImageFrame> m_imageFrame = std::make_unique<ImageFrame>(image, m_pacificSouthwestEnvelope, this);
	 m_imageOverlay->setImageFrame(m_imageFrame.get());
}
0 Kudos
LeeCarter
Emerging Contributor

Hi @FatmaAkdemir ,

Thank you for the suggestion, unfortunately, I am not using a 3D scene and ImageOverlay does not work with a 2D map view.

0 Kudos
BrianCrist
Emerging Contributor

Hi Lee,

  I had a similar problem with trying to display a sonar fan which refreshes at 15-20Hz; I cobbled something together which basically can manage about a 3-5Hz refresh rate.  (on an Ubuntu system running with 12 cores).

  The framework of what we did was:

1) Use a KML Icon.

2) Create a memory-file (I didn't use the QImageProvider; and that is probably a better route than what I did do, which was to use a Temporary File directly) based on the image from the sensor.

3) Have a timer going (at that 3-5 hz rate) at which time the "QUrl" of the file is applied to a new KML Icon.

...yes, NEW KML Icon.  There are some bugs in the KML framework that I haven't had time to report yet.  Primarily is that the `refresh` of KML Icons cannot be set to less than 1000ms or they will just cease happening.  I had found another earlier this year but again, been too bombed under with work to try and submit a case.

 

So I am not from Esri, and I would definitely defer to their knowledge.  I do know that there were all sorts of problems with the KML Icon "pathway" until ArcGIS for QT 100.10, which was released early this year.  So if you're still on 100.9 I would definitely suggest upgrading before attempting anything in the KML framework. 

(You can look at my post history for cases I had involving this topic).

I'm happy to discuss ideas around this topic.  Displaying sonar information on the map is a very key piece of functionality for us, and we're always looking for ways to improve!

 

 

LeeCarter
Emerging Contributor

Hi @BrianCrist ,

Thank you for the information on what you did, sounds like we want to do something very similar.  I have put in a pin in this for now while I wait to see if ESRI makes progress on an "In Product Plan" enhancement they have for adding support for ImageOverlay to 2D MapViews.

We are still on v100.9 of the SDK and updating to newer SDK versions has knock-on implications as there is often a higher version of the Qt framework needed but if I get the opportunity to experiment I may take a look at KmlIcon again.

I'll post here if I get any news about the enhancement but the latest I was told was that there is no planned SDK version number for the release of the enhancement so I'm not holding my breath.

BrianCrist
Emerging Contributor

This: 

while I wait to see if ESRI makes progress on an "In Product Plan" 
enhancement they have for adding support for ImageOverlay to 2D MapViews.

is the most exciting thing I've heard in a while... 🙂  Our implementation definitely leaves much to be desired.

Do you have a link or anything to where that product plan is discussed?

 

0 Kudos
LeeCarter
Emerging Contributor

The case/issue/story for the enhancement has been linked to the support area of my Esri account and I do not know if it is sensible to share such links.

I suggest that anyone interested in the ability to use an ImageOverlay on a 2D MapView should contact ESRI support and request that they have ENH-000134745 linked to their account.  Once you have visibility of the enhancement you should even be able to Escalate it in order to add more weight to the need/demand for the enhancement.

0 Kudos