Example #1
0
        private Geography ResolveLocation(string json)
        {
            if (string.IsNullOrWhiteSpace(json))
            {
                return(null);
            }
            string[] ary = json.Trim().Split(',');
            float    tmp1, tmp2;

            if ((ary.Length == 2 || ary.Length == 3) && float.TryParse(ary[0], out tmp1) && float.TryParse(ary[1], out tmp2))
            {
                if (ary.Length == 3 && ary[2] != null)
                {
                    var d = ary[2].Trim().ToLower();
                    if (d == "weixin")
                    {
                        return(LocationResolver.ConvertLocation((decimal)tmp2, (decimal)tmp1, GeographyType.QQ_Google_AmapMap, GeographyType.GPS));
                    }
                    else if (d == "baidu")
                    {
                        return(LocationResolver.ConvertLocation((decimal)tmp2, (decimal)tmp1, GeographyType.BaiduMap, GeographyType.GPS));
                    }
                }
                return(new Geography {
                    Longitude = tmp1, Latitude = tmp2
                });                                                         // GPS
            }
            return(null);
        }