Hexagon Geospatial

Shared Samples

GeoMedia, a comprehensive and dynamic GIS, extracts compelling intelligence from geospatial data and integrates it to present actionable information. Please note a HGDN subscription is required to download code samples
Showing results for 
Search instead for 
Do you mean 

Generating Labels

by Technical Evangelist ‎10-02-2015 06:06 AM - edited ‎10-02-2015 06:07 AM (627 Views)


The GenerateLabels sample application is an example of a GeoMedia custom application.  
It's primary purpose is to demonstrate using the GraphicsTextPipe to generate and display labels.






Code snippet


// Run the recordset through the CenterPointPipe to get their geometric centers.
PPipe.CenterPointPipe oCenterPipe = new PPipe.CenterPointPipe();
oCenterPipe.InputGeometryFieldName = sGeomFld;
oCenterPipe.InputRecordset = (GDO.GRecordset)oCSSPipe.OutputRecordset;
oCenterPipe.OutputGeometryFieldName = sGeomFld + "2";

//Run the recordset through the GraphicsTextPipe to generate the labels.
GMService.GraphicsTextPipe oTextPipe = new GMService.GraphicsTextPipe();
oTextPipe.InputGeometryFieldName = sGeomFld + "2";
oTextPipe.InputRecordset = (PClient.GRecordset)oCenterPipe.OutputRecordset;
oTextPipe.OutputGeometryFieldName = sGeomFld + "3";
oTextPipe.StringContent = "[" + sAttribute + "]";

// Define Style
PView.StyleService objstyleservice = new PView.StyleService();
PView.StyleDefinition objstyledef = null;
objstyleservice.GetStyle("Text Style", out objstyledef);
objstyledef.StyleProperties[PView.StylePropertyConstants.gmgroPropertyColor].Value = GetNextQBColor();
objstyledef.StyleProperties[PView.StylePropertyConstants.gmgroPropertyUnitType].Value = PView.StyleUnitTypeConstants.gmgroUnitTypeNonscalingPaper;
objstyledef.StyleProperties[PView.StylePropertyConstants.gmgroPropertyFontName].Value = "Arial";
objstyledef.StyleProperties[PView.StylePropertyConstants.gmgroPropertyFontSize].Value = 352;

// Define legend title
PDBPipe.GMProperty objgmprop = new PDBPipe.GMProperty();
objgmprop.Name = "Title";
objgmprop.Value = sFeature + " Labels";

// Create the legend entry.
PView.LegendEntry oLE = new PView.LegendEntry();
oLE.GeometryFieldName = sGeomFld + "3";
oLE.InputRecordset = (GDO.GRecordset)oTextPipe.OutputRecordset;
oLE.Style = objstyledef;



Setup instructions

Compile the solution using Visual Studio 2013 and run the program, GenerateLabels.exe.
You will be prompted for an Access warehouse.

  • Choose View > Features to see the chosen feature(s) in your map view
  • Choose View > Generate Labels to create the labels.

Download links

C# for GeoMedia 2015HGDN / App_GenerateLabels_2015CS


Knowledge level:


by Courchesnep
on ‎05-14-2018 11:59 AM

The download link to App_GenerateLabels_2015CS redirect me to Bitbucket and gives an access denied.


My objective is to get an example of the best way to generate labels with a custom application with GeoMedia Objects 2016.


Also, in the GM 2016 Release Notes, it's indicated that the display performance of dynamic labels is improved. Does this apply to labeling with GM Objects ?


Thank you,


by Technical Evangelist
on ‎05-17-2018 05:50 AM

Hi Patrick.  The dynamic labeling referenced in that statement is the functionality incorporated several years ago into the GeoMedia Desktop product, from the former GeoMedia separately-sold add-on product call "GeoLabel" provided by our partner MapText.  That functionality is exclusively available through the user interface of GeoMedia Desktop (all three tiers), but is not available through API and is not available with GeoMedia Objects.


If you are already doing labeling with GeoMedia Objects through API, then this must be via the prior built-in labeling system of GeoMedia, which continues to be available (e.g. on the "Vector" ribbon tab of GeoMedia Desktop, see the "Text and Labels" group).  Its performance is not affected by these changes mentioned in the Release Guide.


  - Hal