Sunday, February 24, 2013

Get the latitude and longitude by passing the MCCC,MNC,CELLID


Get the latitude and longitude by passing the MCCC,MNC,CELLID


By passing the cellid ,mnc,mcc to get the latitude and longitude of the cell


i wrote this example in .ashx page



public void ProcessRequest(HttpContext context)
        {
            string mcc = "262";
            string mnc = "1";
            string cellid = "45964";
            string url = "http://www.opencellid.org/cell/get?mcc=" + mcc + "&mnc=" + mnc + "&cellid=" + cellid + "";
            WebRequest request = WebRequest.Create(url);
            request.Timeout = 10000;
            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                using (Stream dataStream = response.GetResponseStream())
                {
                    using (StreamReader reader = new StreamReader(dataStream))
                    {
                        string st = reader.ReadToEnd().Trim();
                        if (st != "")
                        {
                            XmlDocument xdoc = new XmlDocument();
                            xdoc.LoadXml(st);
                            XmlElement name = xdoc.GetElementById("45964");
                            XmlNodeList nodeList = xdoc.GetElementsByTagName("cell");
                            int size = nodeList.Count;
                            for (int x = 0; x < size; x++)
                            {
                                string result =         nodeList.Item(x).Attributes.GetNamedItem("lat").Value;
                                string result1 = nodeList.Item(x).Attributes.GetNamedItem("lon").Value;
                                context.Response.Write("Latitude=" + result + ",Longitude=" + result1);
                            }

                        }
                    }
                }
            }
        }


u can also write this in one function also  




For any clarifications or queries please don’t hesitate to call or Email

Phone :- + 91-9492179390


Email :- lannam@technobrainltd.com (or) lokeshtec@gmail.com 

No comments:

Post a Comment