# Polyline Label Generation problem

**URL:** <https://mapwindow.discourse.group/t/polyline-label-generation-problem/1147>\
**Category:** Uncategorized\
**Created:** [November 20, 2021, 11:51am UTC](https://mapwindow.discourse.group/t/polyline-label-generation-problem/1147 "2021-11-20T11:51:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Airmech](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/airmech/32/573_2.png) [@Airmech](https://mapwindow.discourse.group/u/Airmech)\
**Post date:** [November 20, 2021, 11:51am UTC](https://mapwindow.discourse.group/t/polyline-label-generation-problem/1147/1 "2021-11-20T11:51:17Z")

</div>

Hi,  
I have another problem, this time generating labels for polyline shapes. Labels work for point shapes but not for polyline. I’ve checked that I have the same number of shapes as I do entries in the .dbf file and looking at the data in the dbf it looks okay. Anybody encountered this before or have a solution?  
Thanks

Trevor

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [November 22, 2021, 6:00am UTC](https://mapwindow.discourse.group/t/polyline-label-generation-problem/1147/2 "2021-11-22T06:00:44Z")

</div>

Hello Trevor.

This is not an issue I am aware of, and if anything is perhaps an edge case, since I know that polyline labeling is working in general.

If you could post the code you use to set up labeling for this layer, and perhaps even provide the layer, we may be able to determine the issue.

Thank you, and Regards.  
Jerry.

---

<div class="post-metadata">

**Author:** ![Airmech](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/airmech/32/573_2.png) [@Airmech](https://mapwindow.discourse.group/u/Airmech)\
**Post date:** [November 22, 2021, 9:26am UTC](https://mapwindow.discourse.group/t/polyline-label-generation-problem/1147/3 "2021-11-22T09:26:38Z")

</div>

Hi Jerry,

This is what I’m using to generate the polyline labels:  
shape-\>Labels-\>FontSize = 7;  
shape-\>Labels-\>FontBold = 1;  
shape-\>Labels-\>LineOrientation = tkLineLabelOrientation::lorHorizontal;  
shape-\>Labels-\>set\_FrameType(tkLabelFrameType::lfPointedRectangle);  
shape-\>Labels-\>FrameVisible = true;  
shape-\>Labels-\>Generate(L"[Name]" ,tkLabelPositioning::lpCentroid,false);  
shape-\>Labels-\>Visible = true;

As I said, it works for point shapes but not polylines.  
Thanks  
Trevor

---

<div class="post-metadata">

**Author:** ![Airmech](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/airmech/32/573_2.png) [@Airmech](https://mapwindow.discourse.group/u/Airmech)\
**Post date:** [November 22, 2021, 10:30am UTC](https://mapwindow.discourse.group/t/polyline-label-generation-problem/1147/4 "2021-11-22T10:30:11Z")

</div>

Hi Jerry,

here is the shapefile and associated files.  
[LNM.zip](https://mapwindow.discourse.group/uploads/short-url/AcAwsnCVchvdR0vlJHFlDmhH5Lj.zip) (524.9 KB)

---

<div class="post-metadata">

**Author:** ![josimar](https://avatars.discourse-cdn.com/v4/letter/j/cab0a1/32.png) [@josimar](https://mapwindow.discourse.group/u/josimar)\
**Post date:** [January 11, 2022, 1:48pm UTC](https://mapwindow.discourse.group/t/polyline-label-generation-problem/1147/5 "2022-01-11T13:48:50Z")

</div>

Hi, I have the same problem. I have a polyline the represets a open polygon (not closed) and when I call Centroid function I get a error. Here is my code:  
for i:=0 to shp.NumShapes-1 do begin  
xlbl := shp.Shape[i].Centroid.x ; '\<-- error  
ylbl := shp.Shape[i].Centroid.y ;  
lbltext := shp.CellValue[fieldIndex, i];  
lblShp.AddLabel(lbltext, xlbl, ylbl, 0, 0 ,0,0); //cat red  
end;
