-
Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathLabelsHelper.cpp
More file actions
73 lines (69 loc) · 2.04 KB
/
Copy pathLabelsHelper.cpp
File metadata and controls
73 lines (69 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "stdafx.h"
#include "LabelsHelper.h"
#include "ShapefileHelper.h"
// *******************************************************
// UpdateLabelsPositioning()
// *******************************************************
// Should be called after change of shapefile type (CreateNew, Open, Resource, Close)
void LabelsHelper::UpdateLabelsPositioning(IShapefile* sf)
{
ShpfileType type = ShapefileHelper::GetShapeType2D(sf);
CComPtr<ILabels> labels = NULL;
sf->get_Labels(&labels);
if (labels)
{
if (type == SHP_POINT || type == SHP_MULTIPOINT)
{
labels->put_Positioning(lpCenter);
}
else if (type == SHP_POLYLINE)
{
labels->put_Positioning(lpLongestSegement);
}
else if (type == SHP_POLYGON)
{
labels->put_Positioning(lpCentroid);
}
else
{
labels->put_Positioning(lpNone);
}
}
}
// *******************************************************
// GetFloatNumberFormat()
// *******************************************************
CString LabelsHelper::GetFloatNumberFormat(ILabels* labels)
{
if (!labels) return m_globalSettings.floatNumberFormat;
USES_CONVERSION;
CComBSTR bstrFormat;
labels->get_FloatNumberFormat(&bstrFormat);
CString format = OLE2A(bstrFormat);
if (format.GetLength() == 0)
format = m_globalSettings.floatNumberFormat;
return format;
}
// *******************************************************
// GetCount()
// *******************************************************
long LabelsHelper::GetCount(ILabels* labels)
{
if (!labels) return 0;
long count;
labels->get_Count(&count);
return count;
}
// ******************************************************************
// LabelPositionForShapeType
// ******************************************************************
tkLabelPositioning LabelsHelper::LabelPositionForShapeType(ShpfileType shpType)
{
shpType = ShapeUtility::Convert2D(shpType);
if (shpType == SHP_POLYGON)
return lpCentroid;
else if (shpType == SHP_POLYLINE)
return lpLongestSegement;
else
return lpCenter;
}