I can get the following arcade expression to work by its self in a new label expression.
var cogo_distance = $feature.Distance;
IIF(Right(cogo_distance, 3) == ".00", Left(cogo_distance, Count(cogo_distance) - 3), cogo_distance)
The expression removes any distance that ends with ".00" from showing as part of the label.
What I need help with is where to insert this into the default COGO label expressions that get generated with the parcel fabric.
Any help is greatly appreciated.
Robert.
ArcPro ver. 3.4.2
fgdb.
Solved! Go to Solution.
// Change the settings portion to configure direction format, color, rounding and abbreviations
// This is an Arcade expression
// SETTINGS
var ShowDistance = true; //set as 'true' to show distance
var ShowDirection = true; //set as 'true' to show direction
var DirectionType = 1; // 1 = Quadrant Bearing; 2 = North Azimuth; 3 = South Azimuth
var ShowRadius = true; //set as 'true' to show radius
var ShowCurveParameter = true; //set as 'true' to show a curve parameter
var ShowCOGOType = true; //set as 'true' to show prefixes and postfixes defined below for each cogo line label
var COGOType_Entered = ['', ''] //Change prefix and postfix for Entered courses
var COGOType_Computed = ['±', ''] //Change prefix and postfix for Computed courses
var COGOType_FromGeom = ['<', '>'] //Change for prefix and postfix From Geometry courses. The < is a special character to represent the left angle bracket
var CurveParameter = "ArcLength"; //set as 'ArcLength' or 'Chord' or 'Angle' for central angle. Case sensitive!
var ErrorString = "COGO ERROR"; //set to display invalid COGO combinations
var RadiusAbbr = 'R='; //radius abbreviation
var Radius2Abbr = 'R2='; //radius2 abbreviation for spiral curves
var ArclengthAbrr = 'L='; //arclength abbreviation
var ChordAbbr = 'C='; //chord abbreviation
var AngleAbbr = 'A='; //central Angle abbreviation
var DistUnitRounding = 2; //number of decimal places for distance units: distance, radius, arclength & chord
var NumberFormat = "#,###.00" //number format. In this example: thousands separator with padding of 2 zeros
var directionColor = "blue='255'"; //direction color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var distanceColor = "black='255'"; //distance color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var radiusColor = "blue='255'"; //radius color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var curveParamColor = "black='255'"; //curve parameter color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var partialCOGOColor = "magenta='255'"; //partial COGO color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var invalidCOGOColor = "red='255'"; //invalid COGO color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var fontNameSize = "<FNT name = 'Arial' size = '10'>"; //font type and size
// VARIABLES
var cogo_direction = $feature.Direction;
var cogo_distance = $feature.Distance;
var cogo_radius = $feature.Radius;
var cogo_arclength = $feature.Arclength;
var cogo_radius2 = $feature.Radius2
var cogotype = $feature.COGOType
if (HasKey($feature, "labelPosition")){
var labelPosition = $feature.labelPosition
}
else {
var labelPosition = 1
}
var binaryDictionary; //binary dictionary to check COGO combinations
var checksum = 0; //initialize checksum
var validValuesArray; //array of valid values for COGO combinations
var partialValuesArray; //array of partial values for COGO
var directionStr = ""; //direction string using for label
var distanceStr = ""; //distance string using for label
var radiusStr = ""; //radius string using for label
var radius2Str = ""; //radius2 string using for labeling spiral curves
var curveStr = ""; //curve parameter string using for label
var prefixPostfix = ['', ''] //Used for prefix and postfix of COGO Type
var angleRad; //curve angle in radians
var COGOValidity; //COGO combinations validity. can be valid, partial or invalid.
if (IsEmpty(cogo_direction) && IsEmpty(cogo_distance) && IsEmpty(cogo_radius) && IsEmpty(cogo_radius2) && IsEmpty(cogo_arclength)){
return ""
}
function NorthAzimuth2Quadbearing(azimuth){
return ConvertDirection(azimuth, {directionType:'North', angleType: 'Degrees'}, {directionType:'Quadrant', angleType: 'DMS', outputType: 'text', format: 'pd[°]mm[\']ss["]b'})
}
function DMS_North(azimuth){
return ConvertDirection(azimuth, {directionType:'North', angleType: 'Degrees'}, {directionType:'North', angleType: 'DMS', outputType: 'text', format: 'd[°]mm[\']ss["]'})
}
function DMS_South(azimuth){
return ConvertDirection(azimuth, {directionType:'North', angleType: 'Degrees'}, {directionType:'South', angleType: 'DMS', outputType: 'text', format: 'd[°]mm[\']ss["]'})
}
function IsValidCOGO(cogo_direction, cogo_distance, cogo_radius, cogo_arclength, cogo_radius2) {
binaryDictionary= Dictionary('dir', 1, 'dist',2, 'rad',4, 'arc',8, 'rad2',16)
if (!IsEmpty(cogo_direction)) {checksum+=binaryDictionary.dir}
if (!IsEmpty(cogo_distance)) {checksum+=binaryDictionary.dist}
if (!IsEmpty(cogo_radius)) {checksum+=binaryDictionary.rad}
if (!IsEmpty(cogo_arclength)) {checksum+=binaryDictionary.arc}
if (!IsEmpty(cogo_radius2)) {checksum+=binaryDictionary.rad2}
validValuesArray=[0,3,13,29]; //array of valid combinations: '0' for nothing, ... '13' for direction & radius & arclength ...
partialValuesArray=[1,2,4,5,8,9,12,16,17,20,21,24,25,27,28]; //array of partial combinations: '1' for only direction, '2' for only distance, '4' for only radius...
//Invalid Values = [6,7,10,11,14,15,18,19,22,23,26,30,31]
if (IndexOf(validValuesArray,checksum)>-1) { // a negative value is returned if checksum value is not in the a valid combination array
return "valid";
}
if (IndexOf(partialValuesArray,checksum)>-1){
return "partial";
}
return "invalid";
}
function COGOTypePrefixPostfix(cogotypeValue){
if (ShowCOGOType){
if (cogotypeValue == 1) { //Entered
return COGOType_Entered
}
else if(cogotypeValue == 2) { //From Geometry
return COGOType_FromGeom
}
else if(cogotypeValue == 3) { //Computed
return COGOType_Computed
}
else { //If not set or invalid value
return ['', '']
}
}
else{
return(['', ''])
}
}
COGOValidity = IsValidCOGO(cogo_direction, cogo_distance, cogo_radius, cogo_arclength, cogo_radius2);
if ( COGOValidity == "invalid") { //if invalid COGO return error string
return "<BOL><CLR " + invalidCOGOColor + ">" + fontNameSize + ErrorString + "</FNT></CLR></BOL>";
}
else if (COGOValidity == "partial") { //if a partial COGO change colors
distanceColor = partialCOGOColor;
directionColor = partialCOGOColor;
radiusColor = partialCOGOColor;
curveParamColor = partialCOGOColor;
}
// Distance string
if (ShowDistance) {
if (IsEmpty(cogo_distance)==false) {
var rawDistanceStr = text(round(cogo_distance,DistUnitRounding), NumberFormat);
// Remove trailing ".00" if present
if (Right(rawDistanceStr, 3) == ".00") {
distanceStr = Left(rawDistanceStr, Count(rawDistanceStr) - 3);
} else {
distanceStr = rawDistanceStr;
}
}
}
//Radius String
if (ShowRadius) {
if (!IsEmpty(cogo_radius)) { //it can be a curve or a spiral
if (IsEmpty(cogo_radius2)) { //if radius2 is empty this is a curve
radiusStr = RadiusAbbr + " " + text(round(cogo_radius, DistUnitRounding), NumberFormat);
}
else { // it is a spiral
radiusStr = RadiusAbbr + " " + text(round(cogo_radius, DistUnitRounding),NumberFormat);
radius2Str = Radius2Abbr + " " + text(round(cogo_radius2, DistUnitRounding),NumberFormat);
if (cogo_radius == 0) { //substitute to infinity sign
radiusStr = RadiusAbbr + " ∞ ";
}
if (cogo_radius2 == 0) { //substitute to infinity sign
radius2Str = Radius2Abbr + " ∞ ";
}
}
}
}
// Curve Parameter
if (ShowCurveParameter) {
if (!IsEmpty(cogo_arclength)) {
if (CurveParameter == 'ArcLength') {
curveStr = text(round(cogo_arclength, DistUnitRounding), NumberFormat); //return Arc length
}
angleRad = cogo_arclength/(abs(cogo_radius)) //calculate angle in radians
if (CurveParameter == 'Angle') {
curveStr = DMS_North(angleRad * 180 / pi); // convert radian to degrees and show as DMS
}
if (CurveParameter == 'Chord') {
curveStr = text(round((2 * abs(cogo_radius) * Sin(angleRad/2)),DistUnitRounding), NumberFormat); //calculate chord length
}
}
}
//Determine type of curve displayed
var CurveTypePrefix = ""
if (!IsEmpty(curveStr)){
if (CurveParameter == 'ArcLength'){
CurveTypePrefix = ArclengthAbrr
}
else if (CurveParameter == 'Angle'){
CurveTypePrefix = AngleAbbr
}
else if (CurveParameter == 'Chord'){
CurveTypePrefix = ChordAbbr
}
}
var isStraightLine = IsEmpty(radiusStr) && IsEmpty(radius2Str) && IsEmpty(curveStr)
// Assemble label string
//Get prefix and postfix if either distance or curve is not empty. NOTE If both aren't empty it's invalid COGO
if (!IsEmpty(distanceStr) || !IsEmpty(curveStr)){
prefixPostfix = COGOTypePrefixPostfix(cogotype)
}
var sharedLabelBuffer = ""
if (labelPosition == 3) {
sharedLabelBuffer = " \n"
}
//Straight lines
if (isStraightLine){
if (!IsEmpty(directionStr) && !IsEmpty(distanceStr)){ //If Direction and Distance are both NOT Empty
return fontNameSize + "<CLR " + directionColor + ">" + directionStr + "</CLR>" + "\n" +
"<CLR " + distanceColor + ">" + prefixPostfix[0] + distanceStr + prefixPostfix[1] + "</CLR></FNT>";
}
else if (IsEmpty(directionStr)){ //If Direction is empty
return fontNameSize + sharedLabelBuffer + "<CLR " + distanceColor + ">" +
prefixPostfix[0] + distanceStr + prefixPostfix[1] + "</CLR></FNT>";
}
else{ //If Distance is empty
return fontNameSize + sharedLabelBuffer + "<CLR " + directionColor + ">" + directionStr + "</CLR></FNT>";
}
}
//Curves
//If one or both radii and the curve string are NOT empty show the full curve
if ((!IsEmpty(radiusStr) || !IsEmpty(radius2Str)) && !IsEmpty(curveStr)){
return fontNameSize + "<CLR " + radiusColor + ">" + radiusStr + "</CLR>" + " " +
"<CLR " + radiusColor + ">" + radius2Str + "</CLR>" + "\n" +
"<CLR " + curveParamColor + ">" + CurveTypePrefix + ' ' +
prefixPostfix[0] + curveStr + prefixPostfix[1] + "</CLR></FNT>";
}
//If the curve is empty
else if (IsEmpty(curveStr)){
return fontNameSize + sharedLabelBuffer + "<CLR " + radiusColor + ">" + radiusStr + "</CLR>" + " " +
"<CLR " + radiusColor + ">" + radius2Str + "</CLR></FNT>"
}
//If both radius are empty
else{
return fontNameSize + sharedLabelBuffer + "<CLR " + curveParamColor + ">" + CurveTypePrefix + ' ' +
prefixPostfix[0] + curveStr + prefixPostfix[1] + "</CLR></FNT>";
}
If you can provide the default label expression, I can insert it for you. : )
// Change the settings portion to configure direction format, color, rounding and abbreviations
// This is an Arcade expression
// SETTINGS
var ShowDistance = true; //set as 'true' to show distance
var ShowDirection = true; //set as 'true' to show direction
var DirectionType = 1; // 1 = Quadrant Bearing; 2 = North Azimuth; 3 = South Azimuth
var ShowRadius = true; //set as 'true' to show radius
var ShowCurveParameter = true; //set as 'true' to show a curve parameter
var ShowCOGOType = true; //set as 'true' to show prefixes and postfixes defined below for each cogo line label
var COGOType_Entered = ['', ''] //Change prefix and postfix for Entered courses
var COGOType_Computed = ['±', ''] //Change prefix and postfix for Computed courses
var COGOType_FromGeom = ['<', '>'] //Change for prefix and postfix From Geometry courses. The < is a special character to represent the left angle bracket
var CurveParameter = "ArcLength"; //set as 'ArcLength' or 'Chord' or 'Angle' for central angle. Case sensitive!
var ErrorString = "COGO ERROR"; //set to display invalid COGO combinations
var RadiusAbbr = 'R='; //radius abbreviation
var Radius2Abbr = 'R2='; //radius2 abbreviation for spiral curves
var ArclengthAbrr = 'L='; //arclength abbreviation
var ChordAbbr = 'C='; //chord abbreviation
var AngleAbbr = 'A='; //central Angle abbreviation
var DistUnitRounding = 2; //number of decimal places for distance units: distance, radius, arclength & chord
var NumberFormat = "#,###.00" //number format. In this example: thousands separator with padding of 2 zeros
var directionColor = "blue='255'"; //direction color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var distanceColor = "black='255'"; //distance color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var radiusColor = "blue='255'"; //radius color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var curveParamColor = "black='255'"; //curve parameter color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var partialCOGOColor = "magenta='255'"; //partial COGO color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var invalidCOGOColor = "red='255'"; //invalid COGO color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var fontNameSize = "<FNT name = 'Arial' size = '10'>"; //font type and size
// VARIABLES
var cogo_direction = $feature.Direction;
var cogo_distance = $feature.Distance;
var cogo_radius = $feature.Radius;
var cogo_arclength = $feature.Arclength;
var cogo_radius2 = $feature.Radius2
var cogotype = $feature.COGOType
if (HasKey($feature, "labelPosition")){
var labelPosition = $feature.labelPosition
}
else {
var labelPosition = 1
}
var binaryDictionary; //binary dictionary to check COGO combinations
var checksum = 0; //initialize checksum
var validValuesArray; //array of valid values for COGO combinations
var partialValuesArray; //array of partial values for COGO
var directionStr = ""; //direction string using for label
var distanceStr = ""; //distance string using for label
var radiusStr = ""; //radius string using for label
var radius2Str = ""; //radius2 string using for labeling spiral curves
var curveStr = ""; //curve parameter string using for label
var prefixPostfix = ['', ''] //Used for prefix and postfix of COGO Type
var angleRad; //curve angle in radians
var COGOValidity; //COGO combinations validity. can be valid, partial or invalid.
if (IsEmpty(cogo_direction) && IsEmpty(cogo_distance) && IsEmpty(cogo_radius) && IsEmpty(cogo_radius2) && IsEmpty(cogo_arclength)){
return ""
}
function NorthAzimuth2Quadbearing(azimuth){
return ConvertDirection(azimuth, {directionType:'North', angleType: 'Degrees'}, {directionType:'Quadrant', angleType: 'DMS', outputType: 'text', format: 'pd[°]mm[\']ss["]b'})
}
function DMS_North(azimuth){
return ConvertDirection(azimuth, {directionType:'North', angleType: 'Degrees'}, {directionType:'North', angleType: 'DMS', outputType: 'text', format: 'd[°]mm[\']ss["]'})
}
function DMS_South(azimuth){
return ConvertDirection(azimuth, {directionType:'North', angleType: 'Degrees'}, {directionType:'South', angleType: 'DMS', outputType: 'text', format: 'd[°]mm[\']ss["]'})
}
function IsValidCOGO(cogo_direction, cogo_distance, cogo_radius, cogo_arclength, cogo_radius2) {
binaryDictionary= Dictionary('dir', 1, 'dist',2, 'rad',4, 'arc',8, 'rad2',16)
if (!IsEmpty(cogo_direction)) {checksum+=binaryDictionary.dir}
if (!IsEmpty(cogo_distance)) {checksum+=binaryDictionary.dist}
if (!IsEmpty(cogo_radius)) {checksum+=binaryDictionary.rad}
if (!IsEmpty(cogo_arclength)) {checksum+=binaryDictionary.arc}
if (!IsEmpty(cogo_radius2)) {checksum+=binaryDictionary.rad2}
validValuesArray=[0,3,13,29]; //array of valid combinations: '0' for nothing, ... '13' for direction & radius & arclength ...
partialValuesArray=[1,2,4,5,8,9,12,16,17,20,21,24,25,27,28]; //array of partial combinations: '1' for only direction, '2' for only distance, '4' for only radius...
//Invalid Values = [6,7,10,11,14,15,18,19,22,23,26,30,31]
if (IndexOf(validValuesArray,checksum)>-1) { // a negative value is returned if checksum value is not in the a valid combination array
return "valid";
}
if (IndexOf(partialValuesArray,checksum)>-1){
return "partial";
}
return "invalid";
}
function COGOTypePrefixPostfix(cogotypeValue){
if (ShowCOGOType){
if (cogotypeValue == 1) { //Entered
return COGOType_Entered
}
else if(cogotypeValue == 2) { //From Geometry
return COGOType_FromGeom
}
else if(cogotypeValue == 3) { //Computed
return COGOType_Computed
}
else { //If not set or invalid value
return ['', '']
}
}
else{
return(['', ''])
}
}
COGOValidity = IsValidCOGO(cogo_direction, cogo_distance, cogo_radius, cogo_arclength, cogo_radius2);
if ( COGOValidity == "invalid") { //if invalid COGO return error string
return "<BOL><CLR " + invalidCOGOColor + ">" + fontNameSize + ErrorString + "</FNT></CLR></BOL>";
}
else if (COGOValidity == "partial") { //if a partial COGO change colors
distanceColor = partialCOGOColor;
directionColor = partialCOGOColor;
radiusColor = partialCOGOColor;
curveParamColor = partialCOGOColor;
}
// Direction string
if (ShowDirection) {
if (IsEmpty(cogo_direction)==false) {
if (DirectionType == 1) { //using quadrant bearing format
directionStr = NorthAzimuth2Quadbearing(cogo_direction);
}
else if (DirectionType == 2) { //using north azimuth format
directionStr = DMS_North(cogo_direction);
}
else if (DirectionType == 3) { //using south azimuth format
directionStr = DMS_South(cogo_direction);
}
}
}
// Distance string
if (ShowDistance) {
if (IsEmpty(cogo_distance)==false) {
distanceStr = text(round(cogo_distance,DistUnitRounding), NumberFormat);
}
}
//Radius String
if (ShowRadius) {
if (!IsEmpty(cogo_radius)) { //it can be a curve or a spiral
if (IsEmpty(cogo_radius2)) { //if radius2 is empty this is a curve
radiusStr = RadiusAbbr + " " + text(round(cogo_radius, DistUnitRounding), NumberFormat);
}
else { // it is a spiral
radiusStr = RadiusAbbr + " " + text(round(cogo_radius, DistUnitRounding),NumberFormat);
radius2Str = Radius2Abbr + " " + text(round(cogo_radius2, DistUnitRounding),NumberFormat);
if (cogo_radius == 0) { //substitute to infinity sign
radiusStr = RadiusAbbr + " ∞ ";
}
if (cogo_radius2 == 0) { //substitute to infinity sign
radius2Str = Radius2Abbr + " ∞ ";
}
}
}
}
// Curve Parameter
if (ShowCurveParameter) {
if (!IsEmpty(cogo_arclength)) {
if (CurveParameter == 'ArcLength') {
curveStr = text(round(cogo_arclength, DistUnitRounding), NumberFormat); //return Arc length
}
angleRad = cogo_arclength/(abs(cogo_radius)) //calculate angle in radians
if (CurveParameter == 'Angle') {
curveStr = DMS_North(angleRad * 180 / pi); // convert radian to degrees and show as DMS
}
if (CurveParameter == 'Chord') {
curveStr = text(round((2 * abs(cogo_radius) * Sin(angleRad/2)),DistUnitRounding), NumberFormat); //calculate chord length
}
}
}
//Determine type of curve displayed
var CurveTypePrefix = ""
if (!IsEmpty(curveStr)){
if (CurveParameter == 'ArcLength'){
CurveTypePrefix = ArclengthAbrr
}
else if (CurveParameter == 'Angle'){
CurveTypePrefix = AngleAbbr
}
else if (CurveParameter == 'Chord'){
CurveTypePrefix = ChordAbbr
}
}
var isStraightLine = IsEmpty(radiusStr) && IsEmpty(radius2Str) && IsEmpty(curveStr)
// Assemble label string
//Get prefix and postfix if either distance or curve is not empty. NOTE If both aren't empty it's invalid COGO
if (!IsEmpty(distanceStr) || !IsEmpty(curveStr)){
prefixPostfix = COGOTypePrefixPostfix(cogotype)
}
var sharedLabelBuffer = ""
if (labelPosition == 3) {
sharedLabelBuffer = " \n"
}
//Straight lines
if (isStraightLine){
if (!IsEmpty(directionStr) && !IsEmpty(distanceStr)){ //If Direction and Distance are both NOT Empty
return fontNameSize + "<CLR " + directionColor + ">" + directionStr + "</CLR>" + "\n" +
"<CLR " + distanceColor + ">" + prefixPostfix[0] + distanceStr + prefixPostfix[1] + "</CLR></FNT>";
}
else if (IsEmpty(directionStr)){ //If Direction is empty
return fontNameSize + sharedLabelBuffer + "<CLR " + distanceColor + ">" +
prefixPostfix[0] + distanceStr + prefixPostfix[1] + "</CLR></FNT>";
}
else{ //If Distance is empty
return fontNameSize + sharedLabelBuffer + "<CLR " + directionColor + ">" + directionStr + "</CLR></FNT>";
}
}
//Curves
//If one or both radii and the curve string are NOT empty show the full curve
if ((!IsEmpty(radiusStr) || !IsEmpty(radius2Str)) && !IsEmpty(curveStr)){
return fontNameSize + "<CLR " + radiusColor + ">" + radiusStr + "</CLR>" + " " +
"<CLR " + radiusColor + ">" + radius2Str + "</CLR>" + "\n" +
"<CLR " + curveParamColor + ">" + CurveTypePrefix + ' ' +
prefixPostfix[0] + curveStr + prefixPostfix[1] + "</CLR></FNT>";
}
//If the curve is empty
else if (IsEmpty(curveStr)){
return fontNameSize + sharedLabelBuffer + "<CLR " + radiusColor + ">" + radiusStr + "</CLR>" + " " +
"<CLR " + radiusColor + ">" + radius2Str + "</CLR></FNT>"
}
//If both radius are empty
else{
return fontNameSize + sharedLabelBuffer + "<CLR " + curveParamColor + ">" + CurveTypePrefix + ' ' +
prefixPostfix[0] + curveStr + prefixPostfix[1] + "</CLR></FNT>";
}
Thank you.
Robert
// Change the settings portion to configure direction format, color, rounding and abbreviations
// This is an Arcade expression
// SETTINGS
var ShowDistance = true; //set as 'true' to show distance
var ShowDirection = true; //set as 'true' to show direction
var DirectionType = 1; // 1 = Quadrant Bearing; 2 = North Azimuth; 3 = South Azimuth
var ShowRadius = true; //set as 'true' to show radius
var ShowCurveParameter = true; //set as 'true' to show a curve parameter
var ShowCOGOType = true; //set as 'true' to show prefixes and postfixes defined below for each cogo line label
var COGOType_Entered = ['', ''] //Change prefix and postfix for Entered courses
var COGOType_Computed = ['±', ''] //Change prefix and postfix for Computed courses
var COGOType_FromGeom = ['<', '>'] //Change for prefix and postfix From Geometry courses. The < is a special character to represent the left angle bracket
var CurveParameter = "ArcLength"; //set as 'ArcLength' or 'Chord' or 'Angle' for central angle. Case sensitive!
var ErrorString = "COGO ERROR"; //set to display invalid COGO combinations
var RadiusAbbr = 'R='; //radius abbreviation
var Radius2Abbr = 'R2='; //radius2 abbreviation for spiral curves
var ArclengthAbrr = 'L='; //arclength abbreviation
var ChordAbbr = 'C='; //chord abbreviation
var AngleAbbr = 'A='; //central Angle abbreviation
var DistUnitRounding = 2; //number of decimal places for distance units: distance, radius, arclength & chord
var NumberFormat = "#,###.00" //number format. In this example: thousands separator with padding of 2 zeros
var directionColor = "blue='255'"; //direction color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var distanceColor = "black='255'"; //distance color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var radiusColor = "blue='255'"; //radius color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var curveParamColor = "black='255'"; //curve parameter color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var partialCOGOColor = "magenta='255'"; //partial COGO color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var invalidCOGOColor = "red='255'"; //invalid COGO color: red, green, blue, cyan, magenta, yellow, black. You can also use RGB or CYMK combinations.
var fontNameSize = "<FNT name = 'Arial' size = '10'>"; //font type and size
// VARIABLES
var cogo_direction = $feature.Direction;
var cogo_distance = $feature.Distance;
var cogo_radius = $feature.Radius;
var cogo_arclength = $feature.Arclength;
var cogo_radius2 = $feature.Radius2
var cogotype = $feature.COGOType
if (HasKey($feature, "labelPosition")){
var labelPosition = $feature.labelPosition
}
else {
var labelPosition = 1
}
var binaryDictionary; //binary dictionary to check COGO combinations
var checksum = 0; //initialize checksum
var validValuesArray; //array of valid values for COGO combinations
var partialValuesArray; //array of partial values for COGO
var directionStr = ""; //direction string using for label
var distanceStr = ""; //distance string using for label
var radiusStr = ""; //radius string using for label
var radius2Str = ""; //radius2 string using for labeling spiral curves
var curveStr = ""; //curve parameter string using for label
var prefixPostfix = ['', ''] //Used for prefix and postfix of COGO Type
var angleRad; //curve angle in radians
var COGOValidity; //COGO combinations validity. can be valid, partial or invalid.
if (IsEmpty(cogo_direction) && IsEmpty(cogo_distance) && IsEmpty(cogo_radius) && IsEmpty(cogo_radius2) && IsEmpty(cogo_arclength)){
return ""
}
function NorthAzimuth2Quadbearing(azimuth){
return ConvertDirection(azimuth, {directionType:'North', angleType: 'Degrees'}, {directionType:'Quadrant', angleType: 'DMS', outputType: 'text', format: 'pd[°]mm[\']ss["]b'})
}
function DMS_North(azimuth){
return ConvertDirection(azimuth, {directionType:'North', angleType: 'Degrees'}, {directionType:'North', angleType: 'DMS', outputType: 'text', format: 'd[°]mm[\']ss["]'})
}
function DMS_South(azimuth){
return ConvertDirection(azimuth, {directionType:'North', angleType: 'Degrees'}, {directionType:'South', angleType: 'DMS', outputType: 'text', format: 'd[°]mm[\']ss["]'})
}
function IsValidCOGO(cogo_direction, cogo_distance, cogo_radius, cogo_arclength, cogo_radius2) {
binaryDictionary= Dictionary('dir', 1, 'dist',2, 'rad',4, 'arc',8, 'rad2',16)
if (!IsEmpty(cogo_direction)) {checksum+=binaryDictionary.dir}
if (!IsEmpty(cogo_distance)) {checksum+=binaryDictionary.dist}
if (!IsEmpty(cogo_radius)) {checksum+=binaryDictionary.rad}
if (!IsEmpty(cogo_arclength)) {checksum+=binaryDictionary.arc}
if (!IsEmpty(cogo_radius2)) {checksum+=binaryDictionary.rad2}
validValuesArray=[0,3,13,29]; //array of valid combinations: '0' for nothing, ... '13' for direction & radius & arclength ...
partialValuesArray=[1,2,4,5,8,9,12,16,17,20,21,24,25,27,28]; //array of partial combinations: '1' for only direction, '2' for only distance, '4' for only radius...
//Invalid Values = [6,7,10,11,14,15,18,19,22,23,26,30,31]
if (IndexOf(validValuesArray,checksum)>-1) { // a negative value is returned if checksum value is not in the a valid combination array
return "valid";
}
if (IndexOf(partialValuesArray,checksum)>-1){
return "partial";
}
return "invalid";
}
function COGOTypePrefixPostfix(cogotypeValue){
if (ShowCOGOType){
if (cogotypeValue == 1) { //Entered
return COGOType_Entered
}
else if(cogotypeValue == 2) { //From Geometry
return COGOType_FromGeom
}
else if(cogotypeValue == 3) { //Computed
return COGOType_Computed
}
else { //If not set or invalid value
return ['', '']
}
}
else{
return(['', ''])
}
}
COGOValidity = IsValidCOGO(cogo_direction, cogo_distance, cogo_radius, cogo_arclength, cogo_radius2);
if ( COGOValidity == "invalid") { //if invalid COGO return error string
return "<BOL><CLR " + invalidCOGOColor + ">" + fontNameSize + ErrorString + "</FNT></CLR></BOL>";
}
else if (COGOValidity == "partial") { //if a partial COGO change colors
distanceColor = partialCOGOColor;
directionColor = partialCOGOColor;
radiusColor = partialCOGOColor;
curveParamColor = partialCOGOColor;
}
// Distance string
if (ShowDistance) {
if (IsEmpty(cogo_distance)==false) {
var rawDistanceStr = text(round(cogo_distance,DistUnitRounding), NumberFormat);
// Remove trailing ".00" if present
if (Right(rawDistanceStr, 3) == ".00") {
distanceStr = Left(rawDistanceStr, Count(rawDistanceStr) - 3);
} else {
distanceStr = rawDistanceStr;
}
}
}
//Radius String
if (ShowRadius) {
if (!IsEmpty(cogo_radius)) { //it can be a curve or a spiral
if (IsEmpty(cogo_radius2)) { //if radius2 is empty this is a curve
radiusStr = RadiusAbbr + " " + text(round(cogo_radius, DistUnitRounding), NumberFormat);
}
else { // it is a spiral
radiusStr = RadiusAbbr + " " + text(round(cogo_radius, DistUnitRounding),NumberFormat);
radius2Str = Radius2Abbr + " " + text(round(cogo_radius2, DistUnitRounding),NumberFormat);
if (cogo_radius == 0) { //substitute to infinity sign
radiusStr = RadiusAbbr + " ∞ ";
}
if (cogo_radius2 == 0) { //substitute to infinity sign
radius2Str = Radius2Abbr + " ∞ ";
}
}
}
}
// Curve Parameter
if (ShowCurveParameter) {
if (!IsEmpty(cogo_arclength)) {
if (CurveParameter == 'ArcLength') {
curveStr = text(round(cogo_arclength, DistUnitRounding), NumberFormat); //return Arc length
}
angleRad = cogo_arclength/(abs(cogo_radius)) //calculate angle in radians
if (CurveParameter == 'Angle') {
curveStr = DMS_North(angleRad * 180 / pi); // convert radian to degrees and show as DMS
}
if (CurveParameter == 'Chord') {
curveStr = text(round((2 * abs(cogo_radius) * Sin(angleRad/2)),DistUnitRounding), NumberFormat); //calculate chord length
}
}
}
//Determine type of curve displayed
var CurveTypePrefix = ""
if (!IsEmpty(curveStr)){
if (CurveParameter == 'ArcLength'){
CurveTypePrefix = ArclengthAbrr
}
else if (CurveParameter == 'Angle'){
CurveTypePrefix = AngleAbbr
}
else if (CurveParameter == 'Chord'){
CurveTypePrefix = ChordAbbr
}
}
var isStraightLine = IsEmpty(radiusStr) && IsEmpty(radius2Str) && IsEmpty(curveStr)
// Assemble label string
//Get prefix and postfix if either distance or curve is not empty. NOTE If both aren't empty it's invalid COGO
if (!IsEmpty(distanceStr) || !IsEmpty(curveStr)){
prefixPostfix = COGOTypePrefixPostfix(cogotype)
}
var sharedLabelBuffer = ""
if (labelPosition == 3) {
sharedLabelBuffer = " \n"
}
//Straight lines
if (isStraightLine){
if (!IsEmpty(directionStr) && !IsEmpty(distanceStr)){ //If Direction and Distance are both NOT Empty
return fontNameSize + "<CLR " + directionColor + ">" + directionStr + "</CLR>" + "\n" +
"<CLR " + distanceColor + ">" + prefixPostfix[0] + distanceStr + prefixPostfix[1] + "</CLR></FNT>";
}
else if (IsEmpty(directionStr)){ //If Direction is empty
return fontNameSize + sharedLabelBuffer + "<CLR " + distanceColor + ">" +
prefixPostfix[0] + distanceStr + prefixPostfix[1] + "</CLR></FNT>";
}
else{ //If Distance is empty
return fontNameSize + sharedLabelBuffer + "<CLR " + directionColor + ">" + directionStr + "</CLR></FNT>";
}
}
//Curves
//If one or both radii and the curve string are NOT empty show the full curve
if ((!IsEmpty(radiusStr) || !IsEmpty(radius2Str)) && !IsEmpty(curveStr)){
return fontNameSize + "<CLR " + radiusColor + ">" + radiusStr + "</CLR>" + " " +
"<CLR " + radiusColor + ">" + radius2Str + "</CLR>" + "\n" +
"<CLR " + curveParamColor + ">" + CurveTypePrefix + ' ' +
prefixPostfix[0] + curveStr + prefixPostfix[1] + "</CLR></FNT>";
}
//If the curve is empty
else if (IsEmpty(curveStr)){
return fontNameSize + sharedLabelBuffer + "<CLR " + radiusColor + ">" + radiusStr + "</CLR>" + " " +
"<CLR " + radiusColor + ">" + radius2Str + "</CLR></FNT>"
}
//If both radius are empty
else{
return fontNameSize + sharedLabelBuffer + "<CLR " + curveParamColor + ">" + CurveTypePrefix + ' ' +
prefixPostfix[0] + curveStr + prefixPostfix[1] + "</CLR></FNT>";
}
This revision worked for me in ArcGIS Pro.
Your expression under the //Distance string worked.
// Distance string
if (ShowDistance) {
if (IsEmpty(cogo_distance)==false) {
var rawDistanceStr = text(round(cogo_distance,DistUnitRounding), NumberFormat);
// Remove trailing ".00" if present
if (Right(rawDistanceStr, 3) == ".00") {
distanceStr = Left(rawDistanceStr, Count(rawDistanceStr) - 3);
} else {
distanceStr = rawDistanceStr;
}
}
}
Thank you,
Robert.
If I understand correctly, you want to hide the trailing zeros if the distance ends with '.00' .
Is that also true for Radius and ArcLength?
The label expression we ship with the software has many options you can tweak. This could be another option. If you think many other organizations will want that please submit an idea for it.
Thanks,
Amir
Amir,
Yes, ideally the Radius and ArcLength would need to have the ".00" removed as well.
I have in the past made a few simple modification to the default COGO label expressions, I'll see about submitting this as an idea. For my Parcel Fabric clients, it's really trying to mimic what they were seeing with their dimension annotation.
Robert.