Add check for duplicate fields for labels and headings
This commit is contained in:
parent
ff8c99cd8d
commit
6c5f9a6ca0
1 changed files with 23 additions and 12 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
import arcpy # type: ignore
|
||||
|
||||
# Define constants
|
||||
DEFAULT_LINE_WIDTH = 0.7
|
||||
DEFAULT_COLOR = [
|
||||
0,
|
||||
|
@ -310,32 +311,42 @@ class FeatureRenderer:
|
|||
|
||||
# Retrieve label texts for custom labels
|
||||
add_labels = False
|
||||
custom_labels = {}
|
||||
if label_field_1 or label_field_2:
|
||||
add_labels = True
|
||||
custom_labels = {}
|
||||
labels = [primary_key_field]
|
||||
if label_field_1:
|
||||
labels.append(label_field_1)
|
||||
if label_field_2:
|
||||
labels.append(label_field_2)
|
||||
fields = [primary_key_field]
|
||||
if label_field_1 and label_field_1 not in fields:
|
||||
fields.append(label_field_1)
|
||||
if label_field_2 and label_field_2 not in fields:
|
||||
fields.append(label_field_2)
|
||||
|
||||
with arcpy.da.SearchCursor(
|
||||
table,
|
||||
labels,
|
||||
fields,
|
||||
) as search_cursor:
|
||||
for row in search_cursor:
|
||||
if len(fields) == 3:
|
||||
custom_labels[row[0]] = f"{row[1]}{label_delimieter}{row[2]}"
|
||||
elif len(fields) == 2:
|
||||
custom_labels[row[0]] = f"{row[1]}"
|
||||
elif len(fields) == 1:
|
||||
custom_labels[row[0]] = f"{row[0]}"
|
||||
|
||||
# Retrieve headings
|
||||
headings = {}
|
||||
if heading_field:
|
||||
labels = [primary_key_field, heading_field]
|
||||
fields = [primary_key_field]
|
||||
if heading_field not in fields:
|
||||
fields.append(heading_field)
|
||||
with arcpy.da.SearchCursor(
|
||||
table,
|
||||
labels,
|
||||
fields,
|
||||
) as search_cursor:
|
||||
for row in search_cursor:
|
||||
if len(fields) == 2:
|
||||
headings[str(row[0])] = row[1]
|
||||
elif len(fields) == 1:
|
||||
headings[str(row[0])] = row[0]
|
||||
|
||||
# Retrieve outline color codes
|
||||
outline_codes = {}
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue