String Formats

While it is possible to use floating point values to get and set the value of an AngularValue or LinearValue, or to specify the position of a GeodeticPoint or ProjectedPoint, it is also possible to do this using formatted strings. This can be helpful when displaying information to the user or retrieving information from the user, since formatted strings can be more readable than floating point values, in some cases.

There are many different formats that can be used to express AngularValues and LinearValues. In order to use these, it is necessary to first set the Format property with the appropriate formatting string. Formatting strings generally consist of three parts: reserved characters, special characters, and other characters. There are also some special cases for Angular Values format strings that are included for backwards compatibility.

Note that String-based Coordinates such as MGRS are handled in their own separate StringPoint and StringCoordSys.

 

Reserved Characters

Reserved characters are the characters 'D', 'd', 'M', 'm', 'S', and 's' for angular values, and 'X' and 'x' for linear values. These characters are used to represent the locations where numerical values will be located when using the ToString method and will determine how we translate the input string when using the FromString method. The capital letters denote the whole portion and the lower case letters denote the decimal portion of angular units (D, d) and linear units (X,x). When the angular units are degrees (as opposed to radians, etc.), reserve characters for minutes (M, m) and seconds (S,s) may also be used.

 

Special Characters

Special characters are the characters 'N', 'E', 'P', and (for Angular Values in degrees only) 'o'. All special characters must be preceded the '$' character. These characters will be replaced with an appropriate character when the ToString method is called. They will have no effect when calling the FromString method.

Special Character Replacement Character Notes

N

N or S

N when the value is positive and S when negative
This character should be placed before or after all reserve characters

E

E or W

E when the value is positive and W when negative
This character should be placed before or after all reserve characters

P

" " or -

- when the value is negative, and no symbol when the value is positive
This character should be placed before or after all reserve characters

o

°

The degrees symbol since it isn't accessible via the keyboard. Note that this is only used for Angular Values in degrees. If a Linear Value format string contains $o an exception will be thrown.

 

Special Cases

The following formats are special cases that are included for backward compatibility. These format strings may be applied to an Angular Value, and will be "translated" into the actual format specified in the table below. Note that these formats are only valid when units are degrees.

Format String

Translates To

DDdMM

DD-MM.mmmmmmmmmmmmmmm

DDdMMdSS

DD-MM-SS.sssssssssssssss

DD_MM

DD MM.mmmmmmmmmmmmmmm

DD_MM_SS

DD MM SS.sssssssssssssss

DM

DD.MMmmmmmmmmmmmmmmm

DMS

DD.MMSSsssssssssssssss

Packed DMS

DDMMSSsssssssssssssss

 

Rules for AngularValue Format Strings

Rules for AngularValue::FromString

Rules for AngularValue::ToString

Rules for LinearValue Format Strings

General Rules for LinearValue::FromString

General Rules for LinearValue::ToString

AngularValue::FromString Examples

Format String

Input String

Value in Degrees

DM

N18.3075

18.5125

DMS

N18.3045

18.5125

Packed DMS

0183045

18.5125

DDdMM

18-30.75

18.5125

DDdMMdSS

18_30_45

18.5125

DD_MM

18 30.75

18.5125

DD_MM_SS

18 30 45

18.5125

DDMMSS

012345.67

1.3960194444444

DDMMSS

013 45

1.0625

$P DDMMSS

12 34567

12.062686111111

$P DDMMSS

-12 34567

-12.062686111111

DDMMSSs

1233025333

12.550703694444

DDMMSS.

123302.5333

12.550703694444

DDMMSS

  12345

1.3958333333333

$P DDMMSS

 12345

1.3958333333333

$P DDMMSS

- 12345

|-1.3958333333333

DDMM SS

1234 56

12.582222222222

DDMM SS

123456

12.576

DD.MMSS

123.302333

123.50648055556

DD.MM

12.30

12.5

DD MM SS

123 30 25.333

123.50703694444

DD MM SS

123 30 23

123.50638888889

DD&MM&SS

123&30&23

123.50638888889

DD MM SS

123°30'23"|

123.50638888889

DD MM SS

123 - 30 23

123.50638888889

DD MM SS.s

123 30 25.333

123.50703694444

DD.ddd

156.7896

156.7896

DD

12345

105

DD.dd

11.11 S

-11.11

$NDD.dd

S 11.11

-11.11

$NDD.dd

S11.11

-11.11

DD.dd$N

-11.11

-11.11

DD.dd$N

S 11.11

-11.11

DD.MM

12.30.12

12.502

DD.d

123

123

DD MM SS

123

123

DD.d

.123

0.123

DD.d

123 S

-123

DD.MM

12 -30

12.5

DD.MM

12 30.

12.5

DD.MMSS

123 30.333

123.50555

DD

123 30 25.333

123.50703694444

DD.

123 30 25.333

123.50703694444

DD.d

123 30 25.333

123.50703694444

DD.d

123 34

123.56666666667

DDd

123 30 25.333

123.50703694444

DD.d

123%

Will throw exception on FromString

DDMM SS

12345 67

Will throw exception on FromString

DDMMSS

12345

Will throw exception on FromString

AngularValue::ToString Examples

Format String

Value in Degrees

Output String

DM

18.5125

18.30749999999999957

DMS

18.5125

18.3044999999999997442

Packed DMS

18.5125

0183044999999999997442

DDdMM

18.5125

18-30.749999999999957

DDdMMdSS

18.5125

18-30-44.999999999997442

DD_MM

18.5125

18 30.749999999999957

DD_MM_SS

18.5125

18 30 44.999999999997442

<no format>

123.5

123.500000000000000

DD-MM-SS.sss

123.50703694444

123-30-25.333

DD MM SS.sss

123.50703694444

123 30 25.333

DD%MM%SS.sss

123.50703694444

123%30%25.333

DD$o MM' SS.sss" $N

123.5678912

123° 34' 04.408" N

DDMMSSs

123.5678912

12334044

DDMMSS.sss

123.50703694444

1233025.333

DD.MMSS

123.50703694444

123.3025

DD.ddd

|.235

00.235

DD

123.5

124

DDD.ddd

23.5

023.500

DD.

123

123.

DDdd

123.556

12356

$P DD.dddd

-123.5678912

- 123.5679

$N DD.dddd %

-123.5678912

S 123.5679 %

LinearValue::FromString Examples

Format String

Input String

Value in Meters

XX.x%

123

123

XX.xx

11.11 S

-11.11

$NXX.xx

S11.11

-11.11

$NXX.xx

11.11

11.11

$NXX.xx

-11.11

-11.11

$NXX.xx

S 11.11

-11.11

XX.xx$N

S11.11

-11.11

XX.xx$N

+11.11

11.11

XX.xx$N

11.11-

-11.11

XX.xx$N

S 11.11

-11.11

XX.x

123|

123

XX.x

.123

0.123

XX.x

123 S

|-123

D XX.x

123

123.0

XX.x %

123 %

123

XX &

123 &

123

XX.xxxx

123.5678912-

-123.5678912

XX.x &

123 %

Will throw exception on FromString

LinearValue::ToString Examples

Format

Value in Meters

Output String

XX.x%|

123

123.0%

XX.xxx

|.235

0.235

XX.xxx

1.235

01.235

XX.xxx

12.235

12.235

XX.xxx

123.235

123.235

XX

123.5

124

XX.

123

123.

XXX.xxx

23.5

023.500

$P XX.xxxx

-123.5678912

- 123.5679

$N XX.xxxx %

-123.5678912

S 123.5679 %

XX.xxxx $P

-123.5678912

123.5679 -

XX.xxxx$N

-123.5678912

123.5679S

<no format>

123.5

123.500000000000000

LinearValue::MGRS Examples

Input

Valid or Not?

42TVQ2118583437

VALID

1234

INVALID

1234567890123456

INVALID

42TVQ211858343

INVALID

1ATVQ2118583437

INVALID

422VQ2118583437

INVALID

42TVQ211858R437

INVALID

61TVQ2118583437

INVALID

32XVQ2118583437

INVALID