public override string ToString()
 {
     return(CellId.ToString());
 }
예제 #2
0
        private WorldPoint PollGsmNetwork()
        {
            WorldPoint point = new WorldPoint();

            if (CountryCode == 0 || NetworkCode == 0 || CellId == 0)
            {
                return(point);
            }
            if (cellCache == null)
            {
                cellCache = new List <CellInfo>();
            }

            CellInfo info = new CellInfo()
            {
                MCC = CountryCode, MNC = NetworkCode, LAC = AreaCode, CID = CellId
            };

            Debug.WriteLine("ID: " + CellId.ToString());
            int index = cellCache.IndexOf(info);

            if (index > -1)
            {
                info = cellCache[index];
            }
            else
            {
                Exception ex = null;
                bool      ok = false;

                if (!ok)
                {
                    try
                    {
                        ok = TranslateCellIdWithGoogle(info, false);
                        if (ok)
                        {
                            info.Service = FixService.Google;
                        }
                    }
                    catch (Exception ext) { ex = ext; }
                }

                if (!ok)
                {
                    ok = TranslateCellIdWithOpenCellId(info);
                    if (ok)
                    {
                        info.Service = FixService.OpenCellOrg;
                    }
                }

                if (!ok)
                {
                    try
                    {
                        ok = TranslateCellIdWithCellDb(info);
                        if (ok)
                        {
                            info.Service = FixService.CellDbOrg;
                        }
                    }
                    catch (Exception ext) { ex = ext; }
                }

                if (ok)
                {
                    cellCache.Add(info);
                }
                else if (ex != null)
                {
                    throw ex;
                }
                else
                {
                    info = null;
                }
            }
            if (info != null &&
                info.Lat.HasValue &&
                info.Lng.HasValue &&
                info.Lat.Value != 0 &&
                info.Lng.Value != 0)
            {
                point.Latitude  = info.Lat.Value;
                point.Longitude = info.Lng.Value;
                point.FixTime   = DateTime.UtcNow;
                FixService      = info.Service;
            }

            return(point);
        }