Ejemplo n.º 1
0
        private string BuildNodeQuery(Tuple <string, string, int>[] nodesToLoad, double latitude, double longitude)
        {
            string result = "";

            Dictionary <int, string> calculatedFences = new Dictionary <int, string>();
            PointLatLng centerPoint = new PointLatLng(latitude, longitude);

            foreach (Tuple <string, string, int> tagToLoad in nodesToLoad.Where(x => !string.IsNullOrWhiteSpace(x.Item1)))
            {
                string fence;
                if (!calculatedFences.TryGetValue(tagToLoad.Item3, out fence))
                {
                    PointLatLng botLeft  = WSG84Math.GetDestinationPoint(centerPoint, 225, tagToLoad.Item3);
                    PointLatLng topRight = WSG84Math.GetDestinationPoint(centerPoint, 45, tagToLoad.Item3);
                    fence = $"{ParsingHelper.DoubleToString(botLeft.Latitude)},{ParsingHelper.DoubleToString(botLeft.Longitude)},{ParsingHelper.DoubleToString(topRight.Latitude)},{ParsingHelper.DoubleToString(topRight.Longitude)}";
                    calculatedFences.Add(tagToLoad.Item3, fence);
                }

                if (string.IsNullOrEmpty(tagToLoad.Item2) || tagToLoad.Item2 == "*")
                {
                    result += $"node[{tagToLoad.Item1}]({fence});";
                }
                else
                {
                    result += $"node[{tagToLoad.Item1}={tagToLoad.Item2}]({fence});";
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
 public void DoubleToStringTest()
 {
     Assert.AreEqual("51.12345", ParsingHelper.DoubleToString(51.12345));
     Assert.AreEqual("51.12346", ParsingHelper.DoubleToString(51.123456));
     Assert.AreEqual("51.12346", ParsingHelper.DoubleToString(51.1234567));
 }