How to size a graphic properly

156
6
Jump to solution
05-21-2020 02:26 PM
Highlighted
New Contributor II

Sorry to ask this question which I think demonstrates my ignorance to all things GIS.  I am integrating ArcGIS runtime for QT with an existing user interface which until now has had a home-grown mapping system.

What I want to do sounds so easy; yet I am hopelessly lost trying to understand graphic scaling; especially as it pertains to spatial references, the Geometry Engine and reference scales.

I'm using the Runtime API version 100.8 and QT 5.14 on an Ubuntu system.

The simple-seeming question:

I have a square that is 100 meters x 100 meters.  This square is at a known location.  I want to draw it such that it is actually represented as 100 meters x 100 meters onscreen.

The map is a Topographic Vector.  The mapView is a MapGraphicsView.

I set a reference scale to a positive number on the map.  More on this below.

I added a GraphicsOverlay named overlay with scaleSymbols set to true.

My graphic, a QImage named origGraphic, which represents a 100mx100m square, is 100pix x 100pix.

Using this methodology (after ensuring mapView units are LinearUnit with a type of meters):

width = origGraphic.width() / mapView->unitsPerDIP();
height = origGraphic.height() / mapView->unitsPerDip();
QImage newGraphic = origGraphic.scaled(width, height);

PictureMarkerSymbol img = new PictureMarkerSymbol(newGraphic);
Point point(location.x, location.y, SpatialReference::wgs_84());
overlay->graphics()->append(new Graphic(point, img, this);

After running this, I am left with the following, at the map reference scales shown:

1:1  - a square whose sides are 0.073 meters long

1:1000 - A square whose sides are 73.213 meters long.

So I can see a relationship there; but I don't understand it.  I can add that the map's Viewpoint scale is set to 1000 in both cases.  The mapView->unitsPerDip is .264583 at the zoom level of the viewpoint.

I guess what I really am asking is for an explanation of how I can put something that I know is 100 meters x 100 meters on a map, such that it is represented at that "size" on the map.  If anyone can point me towards a guide, or a relevant section of the API I would be forever in your debt!

Sorry again for the ignorance behind this question.  I hate to waste your time.

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
New Contributor II

Hi Brian.

I would recommend looking at KmlGroundOverlay, I believe it suits your use case pretty well. It's perfectly possible to use a KmlGroundOverlay in either a 2-D map or 3-D scene.

I've attached a gif of me using a KmlGroundOverlay to overlay a 2d black and white .jpg image over a map at the exact scale. I believe you're after something similar to this.

View solution in original post

Reply
0 Kudos
6 Replies
Highlighted
New Contributor II

Hi there Brian.

First, i'd like to thank you for the well written question. Nice.

If I'm understanding you correctly, you're having trouble with your PictureMarkerSymbol appearing to get bigger or smaller in the world as you zoom in or out, (ie, scaling with the view)?

I wonder if I could point you to the setScaleSymbols method on GraphicsOverlay : GraphicsOverlay Class | ArcGIS for Developers 

Setting this flag to true may allow you to size your graphic directly according to the reference scale, and hopefully not have to worry about screenDips.

Reply
0 Kudos
Highlighted
New Contributor II

Hi Elliot,

  Thanks for the response!  I am editing this because I understand now the notion of setScaleSymbols and how it can enable me to ignore MapGraphicsView->unitsPerDIP. 

  Unfortunately I still am having a hard time understanding the relationship of Map->referenceScale and mapView->referenceScale.  If I'm using this to create my map object:

   m_map = new Map(Basemap::topographicVector(this), this);

  How would I know what's an appropriate referenceScale to set?  The m_map member has to have a referenceScale set to something positive in order for the GraphicsOverlay->setScaleSymbols to take affect, right?

  In short I'm trying to understand the relationship between Map->referenceScale, and mapView->mapScale and how to use these values to properly render the (known size) QImage properly via a PictureMarkerSymbol.

Reply
0 Kudos
Highlighted
New Contributor II

Hi Brian.

Sorry for the late response, I fear I got lost down the same rabbit hole you did, attempting to get the reference scale set right and working out the maths with all the DIP stuff, etc. To no avail I'm afraid, this isn't as simple as you might want it to be using a PictureMarkerSymbol and a Point geometry.


I hope you've solved it yourself by now, but if not, I imagine the best way to accomplish the sort of thing you're looking for is likely to use an Envelope geometry instead, and use a Picture Fill Symbol instead of Picture Marker Symbol.

This will produce a tiled image over an exact scale geometry.

However, if you require a non-tiled image, the other, perhaps another solution could be to use a KmlGroundOverlay. We have a sample showing that use case here.

Reply
0 Kudos
Highlighted
New Contributor II

Hi Elliot,

  Thanks again for the response and no problem on the delay!  I'm glad to hear (in some ways) that I was struggling with something that turns out to be a little complicated.

  

   You've provided me several leads that I will definitely pursue.  Thanks!  But I guess I need to expand upon the problem I'm trying to solve a little more... because I think it may illuminate that I am going about my goal the wrong way.

  Instead of a 100 x 100 meter square, the real goal here is to display sensor information (in this case the sensor is a sonar) on the map.  So the imagery will be constantly updating.

  I'm aware of the new ImageOverlay with 100.8, and I thought it would be the solution I am looking for - however, we are rendering a 2-D map, and unless I read the documentation incorrectly, ImageOverlays don't work with 2-D maps?  

  So the problem set I'm trying to solve behind my original question is that of displaying a graphic at a location at a scale that is what we're "seeing" in real life.  Should I be looking straight at a KmlGroundOverlay or is there still a possibility of using a Picture Fill Symbol and an Envelope?

  Thanks again for your response,

  Brian Crist

Reply
0 Kudos
Highlighted
New Contributor II

Hi Brian.

I would recommend looking at KmlGroundOverlay, I believe it suits your use case pretty well. It's perfectly possible to use a KmlGroundOverlay in either a 2-D map or 3-D scene.

I've attached a gif of me using a KmlGroundOverlay to overlay a 2d black and white .jpg image over a map at the exact scale. I believe you're after something similar to this.

View solution in original post

Reply
0 Kudos
Highlighted
New Contributor II

Thank you so much.  I think that will work perfectly!

Reply
0 Kudos