NACompactStreetDirection

A class that contains information describing traveling on a portion of a route.

Property

Type

Description

Azimuth

double

The azimuth is an angle, measured clockwise in decimal degrees, that represents the observers view direction relative to the North Pole.

CompressedGeometry

string

A compressed line geometry representing the street corresponding to the direction element.

ETA

DateTime

The estimated time of arrival at the direction element.

Events

NAStreetDirectionEvent[]

Array of street direction event objects.

Length

double

The length of the direction element.

ManeuverType

esriDirectionsManeuverType

The type of maneuver that the direction represents

Strings

string[]

The set of textual strings conveying directional information.

StringTypes

esriDirectionsStringType[]

The type of each direction string in the property Strings.

Text

string

The text of the direction element.

Time

double

The time to travel along the direction element.

TurnAngle

double

The turn angle at the maneuver point of the item.

Remarks

This object is significantly smaller than the NAStreetDirection object. In particular, there is less information stored about the direction, and the geometry representing the traversed streets is highly compressed. Due to their smaller size, these directions are better suited for passing across low bandwidth connections in server applications.

Examples of what the Text element might return include:

The sample code references in the example below will decompress a compressed geometry into an array of XY.

Examples

C#

//Below is some sample code that will decompress a CompressedGeometry into an array of XY.

private struct XY

{
      public double x;
      public double y;

}

 

private char[] m_abc = {'0','1','2','3','4','5','6','7','8','9',

'a','b','c','d','e','f','g','h','i','j',

'k','l','m','n','o','p','q','r','s','t','u','v'};

 

private XY[] ExtractPointsFromCompressedGeometry(System.String compresedGeometry)

{

      // initialize result storage

      System.Collections.Generic.List< XY > result = new System.Collections.Generic.List< XY >(); // memory exception

      int nIndex = 0;

      double dMultBy = (double)ExtractInt(compresedGeometry, ref nIndex); // exception

      int nLastDiffX = 0;

      int nLastDiffY = 0;

      int nLength = compresedGeometry.Length; // reduce call stack

      while (nIndex != nLength)

      {

            // extract number

            int nDiffX = ExtractInt(compresedGeometry, ref nIndex); // exception

            int nDiffY = ExtractInt(compresedGeometry, ref nIndex); // exception

            // decompress

            int nX = nDiffX + nLastDiffX;

            int nY = nDiffY + nLastDiffY;

            double dX = (double)nX / dMultBy;

            double dY = (double)nY / dMultBy;

            // add result item

            XY point = new XY();

            point.x = dX;

            point.y = dY;

            result.Add(point); // memory exception

            // prepare for next calculation

            nLastDiffX = nX;

            nLastDiffY = nY;

      }

      // return result

      return result.ToArray();

}

// Read one integer from compressed geometry string by using passed position

// Returns extracted integer, and re-writes nStartPos for the next integer

private int ExtractInt(string src, ref int nStartPos) // exception

{

      bool bStop = false;

      System.Text.StringBuilder result = new System.Text.StringBuilder();

      int nCurrentPos = nStartPos;

      while (!bStop)

      {

      char cCurrent = src[nCurrentPos];

      if (cCurrent == '+' || cCurrent == '-')

      {

            if (nCurrentPos != nStartPos)

      {

            bStop = true;

            continue;

      }

}

result.Append(cCurrent); // exception

nCurrentPos++;

if (nCurrentPos == src.Length) // check overflow

{

      bStop = true;

}

int nResult = int.MinValue;

if (result.Length != 0)

{

      nResult = FromStringRadix32(result.ToString());

      nStartPos = nCurrentPos;

}

return nResult;

}

// Sample input and output: +1lmo -> 55000

private int FromStringRadix32(string s) // exception

{

      int result = 0;

      for (int i = 1; i < s.Length; i++)

      {

            char cur = s[i];

            System.Diagnostics.Debug.Assert((cur >= '0' && cur <= '9') || (cur >= 'a' && cur <= 'v'));

            if (cur >= '0' && cur <= '9')

            {

                  result = (result << 5) + System.Convert.ToInt32(cur) - System.Convert.ToInt32('0');

            }

            else if (cur >= 'a' && cur <= 'v')

            {

                  result = (result << 5) + System.Convert.ToInt32(cur) - System.Convert.ToInt32('a') + 10;

            }

            else

            {

                  throw new System.ArgumentOutOfRangeException(); // exception

            }

      }

      if (s[0] == '-')

      {

            result = -result;

      }

      else if (s[0] != '+')

      {

            throw new System.ArgumentOutOfRangeException(); // exception

      }

      return result;

}

10/23/2013