Hexagon Geospatial
MENU

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
yly
Contributor
Posts: 71
Registered: ‎11-17-2015
Accepted Solution

GM - Adding WMS Layer programatically - reprojection problem

Hello,

 

We add a WMS layer programatically in GeoMedia.

It is displayed well when GWS csf is 4326. The legend entry is not displayed when changing GWS csf to another EPSG (supported by the service).

By adding the WMS layer manually by right clic on the legend, no problem.

 

Do we missed something in the simple code bellow?

 

 

Thank you for your help!

Yohann.

 

 

 

// Create originating pipe using WMS connection -------------------------------
connection.CreateOriginatingPipe(out pipe);

// Set table as WMS layer name -----------------------------------------------------
pipe.Table = WMSlayer;

// Get recordset --------------------------------------------------------------------------
rs = pipe.OutputRecordset;

// Set legend entry and add to legend entries ------------------------------------
legendEntry.InputRecordset = (Intergraph.GeoMedia.GDO.GRecordset)rs;
legendEntry.Name = WMSlayer;
legendEntry.GeometryFieldName = "Geometry";
legend.LegendEntries.Append(legendEntry);
gMProperty = (Intergraph.GeoMedia.PDBPipe.GMProperty)application.CreateService("GeoMedia.GMProperty");
gMProperty.Name = "Title";
gMProperty.Value = WMSlayer;
legendEntry.PropertySet.Append(gMProperty);

 

// Set legend entry style as image ---------------------------------------------------
l_ssStyleService = (Intergraph.GeoMedia.PView.StyleService)application.CreateService("Geomedia.StyleService");
l_ssStyleService.GetStyle("Image Style", out l_sdStyle);
legendEntry.Style = l_sdStyle;

 

// Load data --------------------------------------------------------------------------------
legendEntry.LoadData(true);

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

Re: GM - Adding WMS Layer programatically - reprojection problem

Hi Yohann,

 

yes, you missed basically two steps:

 

  1. You need to add CSSTransformPipe between Originating pipe and legend entry
  2. You must add the Query object from the OriginatingPipe based recordset into Document.QueryFolder.QuerySubfolder["Features"]

Then it should start to work. Let me know if you need more details.

 

Pavel

yly
Contributor
Posts: 71
Registered: ‎11-17-2015

Re: GM - Adding WMS Layer programatically - reprojection problem

Hello Pavel,

 

Using a CSSTransformPipe as you said solves the problem. Thank you!

 

I didn't add the query to subfolders. Is it required? Can this lead to errors? 

 

Thank you very much!

Yohann.

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

Re: GM - Adding WMS Layer programatically - reprojection problem

Hi Yohann,

 

it is good to populate the QueryFolder so that your code is compatible with GM framework. I am not sure what consequences not adding the query might have. Maybe when saving and opening the gws. But you will see, if some problems occur, you know where the problem might be.

 

Pavel

yly
Contributor
Posts: 71
Registered: ‎11-17-2015

Re: GM - Adding WMS Layer programatically - reprojection problem

Perfect, thank you Pavel!

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.