How to give a correct envelope for ImageOverlay?

1316
6
Jump to solution
12-01-2020 12:07 AM
FatmaAkdemir
Occasional Contributor II

We have SceneGraphicsView where we add a QImage (radar image) as an ImageOverlay. Our image is a circle with 40km radius. I want to give the center point of this circle as the Envelope's center point. However, the ImageOverlay does not appear in the given point. (Lon: 29.444835, Lat: 40.785893) What am I missing?

When I change the width and height parameters in Envelope constructor, size of the imageOverlay does not change too much.

 

void MainMapWidget::addImageToMap(){
m_imageOverlay = new ImageOverlay();
m_sceneView->imageOverlays()->append(m_imageOverlay);
const Point pointForImageFrame(29.444835, 40.785893, SpatialReference::wgs84());
m_pacificSouthwestEnvelope = Envelope(pointForImageFrame, 0.474571, 0.361748);
m_imageOverlay->setOpacity(0.5);
Camera camera(40.785893, 29.444835, 10010.0, 0, 0, 0.0);
m_sceneView->setViewpointCameraAndWait(camera);

}

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

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
KoushikHajra
Esri Contributor

Hello,

Thank you for reaching out to us. I don't see anything that's obviously wrong in your code. Can you please let me know a couple of things? 

 - When you say the image is not rendering at the right location, where does it render? Is it rendering at 0, 0? 

- If you print the json of the envelope in the slot slotRadarImageChanged, do you get a valid geometry?

 - I am guessing the images themselves are not georeferenced? But I just want to double check.

 - Also, can you try just a single image and see if that works? Something like below:

// clear any existing overlays
  m_sceneView->imageOverlays()->clear();

  const QImage image(imagePath);
  ImageFrame* imgFrame = new ImageFrame(image, m_env, this);
  connect(imgFrame, &ImageFrame::doneLoading, this, [this, imgFrame](Error error)
  {
    Viewpoint vp(imgFrame->extent());
    m_sceneView->setViewpoint(vp);
  });

  ImageOverlay* imgOverlay = new ImageOverlay(this);
  imgOverlay->setImageFrame(imgFrame);
  m_sceneView->imageOverlays()->append(imgOverlay);

 

View solution in original post

Tags (1)
0 Kudos
6 Replies
KoushikHajra
Esri Contributor

Hello,

Thank you for reaching out to us. I don't see anything that's obviously wrong in your code. Can you please let me know a couple of things? 

 - When you say the image is not rendering at the right location, where does it render? Is it rendering at 0, 0? 

- If you print the json of the envelope in the slot slotRadarImageChanged, do you get a valid geometry?

 - I am guessing the images themselves are not georeferenced? But I just want to double check.

 - Also, can you try just a single image and see if that works? Something like below:

// clear any existing overlays
  m_sceneView->imageOverlays()->clear();

  const QImage image(imagePath);
  ImageFrame* imgFrame = new ImageFrame(image, m_env, this);
  connect(imgFrame, &ImageFrame::doneLoading, this, [this, imgFrame](Error error)
  {
    Viewpoint vp(imgFrame->extent());
    m_sceneView->setViewpoint(vp);
  });

  ImageOverlay* imgOverlay = new ImageOverlay(this);
  imgOverlay->setImageFrame(imgFrame);
  m_sceneView->imageOverlays()->append(imgOverlay);

 

Tags (1)
0 Kudos
FatmaAkdemir
Occasional Contributor II

In fact I also wanted ask how to give the width and height when defining an envelope? When should I give a negative width/height and what is the unit of width/height? How can I represent a 40 km width?

0 Kudos
KoushikHajra
Esri Contributor

Hi @FatmaAkdemir: In an ideal world, your problem is a perfect use case for the following constructor for an ImageFrame - 

 

ImageFrame::ImageFrame(const QImage &image, const Esri::ArcGISRuntime::Polygon &quadrilateral, QObject *parent = nullptr)

 

However, currently we take only 4 points to define the quad. 

The width and height should be map units. I am not fully sure how to represent a 40km width other than using some goemetry engine calculations. I will find out and let you know. But WM is not a good projection to represent accurate distance. Looking up the best projection for it, is something I'd start with.

0 Kudos
FatmaAkdemir
Occasional Contributor II

Hi @KoushikHajra ,

I wanted to inform you that my problem was solved. There were empty parts in my QImage which caused the image to be printed in the wrong place. Thank you very much for your help.

0 Kudos
KoushikHajra
Esri Contributor

@FatmaAkdemir I am happy that it worked! 

0 Kudos
FatmaAkdemir
Occasional Contributor II

I tried your code and it prints the image in the correct place. No problem when I try a .png image. However when I give our QImage which is filled by radar data, it does not scale and shows up in a wrong place. Are we using the wrong format for QImage?

mpImage = new QImage(QSize(MY_WIDTH,MY_HEIGHT), QImage::Format_RGBA64_Premultiplied);
mpImage->fill(qRgba(0,0,0,0));

0 Kudos