/// <summary>
        /// Encode the list of coordinate triples.
        /// The third dimension value will be eligible for encoding only when ThirdDimension is other than ABSENT.
        /// This is lossy compression based on precision accuracy.
        /// </summary>
        /// <param name="coordinates">coordinates {@link List} of coordinate triples that to be encoded.</param>
        /// <param name="precision">Floating point precision of the coordinate to be encoded.</param>
        /// <param name="thirdDimension">{@link ThirdDimension} which may be a level, altitude, elevation or some other custom value</param>
        /// <param name="thirdDimPrecision">Floating point precision for thirdDimension value</param>
        /// <returns>URL-safe encoded {@link String} for the given coordinates.</returns>
        public static string Encode(List <LatLngZ> coordinates, int precision, ThirdDimension thirdDimension, int thirdDimPrecision)
        {
            if (coordinates == null || coordinates.Count == 0)
            {
                throw new ArgumentException("Invalid coordinates!");
            }

            if (!Enum.IsDefined(typeof(ThirdDimension), thirdDimension))
            {
                throw new ArgumentException("Invalid thirdDimension");
                //thirdDimension = ThirdDimension.Absent;
            }

            Encoder enc = new Encoder(precision, thirdDimension, thirdDimPrecision);

            foreach (var coordinate in coordinates)
            {
                enc.Add(coordinate);
            }

            return(enc.GetEncoded());
        }
Пример #2
0
        //public static List<ErrorData> ErrorList { get; } = new List<ErrorData>();

        /*
         * /// <summary>
         * /// Gets the can talon.
         * /// </summary>
         * /// <param name="id">The identifier.</param>
         * /// <returns></returns>
         * public static CanTalonData GetCanTalon(int id)
         * {
         *  CanTalonData data;
         *  bool retVal = s_canTalon.TryGetValue(id, out data);
         *  if (retVal)
         *  {
         *      //Contains key. Just return it
         *      return data;
         *  }
         *  else
         *  {
         *      //CAN Talon does not exist yet. Return null.
         *      return null;
         *  }
         * }
         *
         * /// <summary>
         * /// Initializes the can talon.
         * /// </summary>
         * /// <param name="id">The identifier.</param>
         * /// <returns></returns>
         * public static bool InitializeCanTalon(int id)
         * {
         *  CanTalonData data;
         *  bool retVal = s_canTalon.TryGetValue(id, out data);
         *  if (retVal)
         *  {
         *      //Contains key. return false saying we did not initialize a new one.
         *      return false;
         *  }
         *  else
         *  {
         *      //Create a new Can Talon data and return true.
         *      data = new CanTalonData();
         *      s_canTalon.Add(id, data);
         *      OnTalonSRXAddedOrRemoved?.Invoke(id, new TalonSRXEventArgs(true));
         *      return true;
         *  }
         * }
         *
         * /// <summary>
         * /// Removes the can talon.
         * /// </summary>
         * /// <param name="id">The identifier.</param>
         * public static void RemoveCanTalon(int id)
         * {
         *  s_canTalon.Remove(id);
         *  OnTalonSRXAddedOrRemoved?.Invoke(id, new TalonSRXEventArgs(false));
         * }
         *
         * /// <summary>
         * /// Gets the PCM.
         * /// </summary>
         * /// <param name="id">The identifier.</param>
         * /// <returns></returns>
         * public static PCMData GetPCM(int id)
         * {
         *  PCMData data;
         *  bool retVal = s_pcm.TryGetValue(id, out data);
         *  if (retVal)
         *  {
         *      //Contains key. Just return it
         *      return data;
         *  }
         *  else
         *  {
         *      data = new PCMData();
         *      s_pcm.Add(id, data);
         *      OnPCMAdded?.Invoke(data, null);
         *      return data;
         *  }
         * }
         *
         * /// <summary>
         * /// Initializes the PCM.
         * /// </summary>
         * /// <param name="id">The identifier.</param>
         * /// <returns></returns>
         * public static bool InitializePCM(int id)
         * {
         *  PCMData data;
         *  bool retVal = s_pcm.TryGetValue(id, out data);
         *  if (retVal)
         *  {
         *      //Contains key. return false saying we did not initialize a new one.
         *      return false;
         *  }
         *  else
         *  {
         *      //Create a new PCM data and return true.
         *      data = new PCMData();
         *      s_pcm.Add(id, data);
         *      OnPCMAdded?.Invoke(data, null);
         *      return true;
         *  }
         * }
         *
         * /// <summary>
         * /// Gets the PDP.
         * /// </summary>
         * /// <param name="id">The identifier.</param>
         * /// <returns></returns>
         * public static PDPData GetPDP(int id)
         * {
         *  PDPData data;
         *  bool retVal = s_pdp.TryGetValue(id, out data);
         *  if (retVal)
         *  {
         *      //Contains key. Just return it
         *      return data;
         *  }
         *  else
         *  {
         *      data = new PDPData();
         *      s_pdp.Add(id, data);
         *      OnPDPAdded?.Invoke(data, null);
         *      return data;
         *  }
         * }
         *
         * /// <summary>
         * /// Initializes a new PDP.
         * /// </summary>
         * /// <param name="id">The identifier.</param>
         * /// <returns>True if new PDP was created, otherwise false</returns>
         * public static bool InitializePDP(int id)
         * {
         *  PDPData data;
         *  bool retVal = s_pdp.TryGetValue(id, out data);
         *  if (retVal)
         *  {
         *      //Contains key. return false saying we did not initialize a new one.
         *      return false;
         *  }
         *  else
         *  {
         *      //Create a new PCM data and return true.
         *      data = new PDPData();
         *      s_pdp.Add(id, data);
         *      OnPDPAdded?.Invoke(data, null);
         *      return true;
         *  }
         * }
         *
         * /// <summary>
         * /// Occurs on talon SRX added or removed.
         * /// </summary>
         * public static event EventHandler<TalonSRXEventArgs> OnTalonSRXAddedOrRemoved;
         * /// <summary>
         * /// Occurs when a PCM is added.
         * /// </summary>
         * public static event EventHandler OnPCMAdded;
         * /// <summary>
         * /// Occurs when a PDP is added.
         * /// </summary>
         * public static event EventHandler OnPDPAdded;
         *
         */
        static SimData()
        {
            for (int i = 0; i < HAL_GetNumPCMModules(); i++)
            {
                PCM.Add(new HALSimPCMData(i));
            }

            for (int i = 0; i < HAL_GetNumPDPModules(); i++)
            {
                PDP.Add(new HALSimPDPData(i));
            }

            for (int i = 0; i < HAL_GetNumAccumulators(); i++)
            {
                AnalogGyro.Add(new HALSimAnalogGyroData(i));
            }

            for (int i = 0; i < HAL_GetNumAnalogOutputs(); i++)
            {
                AnalogOut.Add(new HALSimAnalogOutData(i));
            }

            for (int i = 0; i < HAL_GetNumAnalogInputs(); i++)
            {
                AnalogIn.Add(new HALSimAnalogInData(i));
            }

            for (int i = 0; i < HAL_GetNumAnalogTriggers(); i++)
            {
                AnalogTrigger.Add(new HALSimAnalogTriggerData(i));
            }

            for (int i = 0; i < HAL_GetNumDigitalChannels(); i++)
            {
                DIO.Add(new HALSimDIOData(i));
            }

            for (int i = 0; i < HAL_GetNumDigitalPWMOutputs(); i++)
            {
                DigitalPWM.Add(new HALSimDigitalPWMData(i));
            }

            for (int i = 0; i < 4; i++)
            {
                //DigitalGlitchFilter.Add(new DigitalGlitchFilterData());
            }

            for (int i = 0; i < HAL_GetNumPWMChannels(); i++)
            {
                PWM.Add(new HALSimPWMData(i));
            }

            for (int i = 0; i < 4; i++)
            {
                Relay.Add(new HALSimRelayData(i));
            }

            for (int i = 0; i < 8; i++)
            {
                //Counter.Add(new CounterData());
            }

            for (int i = 0; i < 8; i++)
            {
                Encoder.Add(new HALSimEncoderData(i));
            }

            for (int i = 0; i < 5; i++)
            {
                SPIAccelerometer.Add(new HALSimSPIAccelerometerData(i));
            }

            for (int i = 0; i < 5; i++)
            {
                //SPIAccumulator.Add(new SPIAccumulatorData());
            }

            //InitializePDP(0);
            //ErrorList.Clear();
        }