Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Contributor
Posts: 22
Registered: ‎04-04-2016
Accepted Solution

Import MapView to Layout sheet

Hi,


I would like to programmatically import an area of my MapView to a Layout Sheet. Is it possible to choose an area having the shape of a polygon?

The only possibility I have found so far is to use the CreateEmbed method of a SmartFrames2d object and define an area in its second parameter, the mapstring.
But this area always results in an axis-aligned rectangle, whereas I would like to have a polygon shaped area.

Doeas anyone have an idea if this is possible and if yes, how?

I am very grateful for any hints!

Thanks and regards
Cecilia

Technical Evangelist
Posts: 535
Registered: ‎09-11-2015

Re: Import MapView to Layout sheet

Hi Cecilia,

 

I am afraid that this is not possible. The only idea I have is to somehow use the Boundary2d object. Otherwise it is only possible to set the SmartFrame2d area to be rectangle or ellipse via the ShapeOption property.

 

Pavel

Contributor
Posts: 22
Registered: ‎04-04-2016

Re: Import MapView to Layout sheet

Hi Pavel,

 

thank you for your answer!

Actually it would be ok if the SmartFrames2d area is a rectangle as long as the area of the map which I import is polygon shaped. In GeoMedia it is possible to manually choose a polygon shaped map area to import, and my question was if it is also possible to do so programmatically?

 

Regards Cecilia

Technical Evangelist
Posts: 535
Registered: ‎09-11-2015

Re: Import MapView to Layout sheet

Hi Cecillia,

 

can you specify in more details what command/workflow do you mean by "manually choose a polygon shaped map area to import"?

 

Thanks, Pavel

Contributor
Posts: 22
Registered: ‎04-04-2016

Re: Import MapView to Layout sheet

Hi Pavel,

 

in GeoMedia in the LayoutWindow you can click on "Map and Marginalia", then on "Insert Map..." and you get the following dialog, where as method for the Geographic extent you can choose e.g. Polygon:

 

InsertMap.PNG

 

After clicking OK you see you MapView, and you can click on the map to identify your polygon and then insert this area to the layout window and get e.g. something like this:

PoygonMapArea.PNG

My question is, if it is possible to program this workflow. The only option I have found to insert an area from you map view to the layout window is to choose the createEmbed method of the SmartFrames2d object, but here the area of the inserted map is always a rectangle.

 

I hope that I could clarify the workflow and thanks for your effort!

 

Regards Cecilia

Technical Evangelist
Posts: 535
Registered: ‎09-11-2015

Re: Import MapView to Layout sheet

Hi Cecilia,

 

so actually this is possible using the Boundary2d object, as I suggested in my first post. You should set the SmartFrame2d.ShapeOption to igBoundaryFrame, and then call the SmartFrame2d.SetClippingBoundary method with appropriate Boundary2d object as an argument. The most tricky part is to construct the Boundary2d object, as it should be in the paper units. So you should scale the real coordinates using CoordSystem.StorageToProjectionScale/MapView.DisplayScale ratio. And also you should translate the coordinates using the SmartFrame2d.GetOrigin values.

 

Pavel

Contributor
Posts: 22
Registered: ‎04-04-2016

Re: Import MapView to Layout sheet

Hi Pavel,

 

thank you very much for your answer. I am trying to test it right now and I have one more question:

 

I would like to create the Boundary2d object using the AddByPoints method of the Boundaries2d object. Can you tell me which type the second parameter of this method should be?

I.e., I am programming in C# and want to do the following:

 

Boundary2d objBoundary = objBoundaries.AddByPoints(points.Count, points);

 

where objBoundaries is an Boundaries2d object. As points I tried to use a PBasic.Points object but I get an error. I suppose that the type is wrong. Do you have an idea which type to use?

 

Thanks and regards

Cecilia

Technical Evangelist
Posts: 535
Registered: ‎09-11-2015

Re: Import MapView to Layout sheet

Hi Cecilia,

 

it should be just a simple array of doubles, with the length 2*points_count. Each pair holds the X and Y coordinates. So for example:

 

double my_points = new double[2*my_points_count];

my_points[0] = X1;

my_points[1] = Y1;

...

 

Pavel

Contributor
Posts: 22
Registered: ‎04-04-2016

Re: Import MapView to Layout sheet

Thank you very much!

Now it works :-)

 

Regards

Cecilia