- wimowifipositioningservice_code.zip
- WiMoWiFiPositioningService
- J2i.Net.FindMe
- Assets
- Data
- LocationLog.sdf
- Images
- Allowed.bmp
- Disallowed.bmp
- Sound
- Alert.wav
- bin
- Debug
- Common
- Controls
- Interface
- J2i.Net.FindMe.csproj
- J2i.Net.FindMe.csproj.user
- J2i.Net.FindMe.idc
- Program.cs
- Properties
- Utility
- Web References
- VE.Common
- common.disco
- common.wsdl
- CountryRegionInfo.datasource
- DataSource.datasource
- EntityType.datasource
- Reference.cs
- Reference.map
- VersionInfo.datasource
- VE.Geocode
- VE.Imagery
- wpsapi.dll
- WpsProxy.dll
- J2i.Net.LocationSettings
- J2i.Net.MapPoint.RenderMap
- bin
- Debug
- J2i.Net.LocationSettings.dll
- J2i.Net.MapPoint.RenderMap.exe
- J2i.Net.WiFiPositioning.dll
- WpsProxy.cs
- WpsProxy.dll
- Form1.cs
- Form1.Designer.cs
- Form1.resx
- J2i.Net.MapPoint.RenderMap.csproj
- J2i.Net.MapPoint.RenderMap.csproj.user
- Program.cs
- Properties
- Web References
- VirtualEarthCommon
- Address1.datasource
- CountryRegionInfo1.datasource
- DataSource1.datasource
- EntityType1.datasource
- FindResults1.datasource
- LatLong1.datasource
- LineDriveMapImage1.datasource
- Location1.datasource
- MapImage1.datasource
- mappoint.wsdl
- MapViewRepresentations1.datasource
- PixelCoord1.datasource
- Reference.cs
- Reference.map
- Route1.datasource
- VersionInfo1.datasource
- VirtualEarthImaging
- wpsapi.dll
- WpsProxy.dll
- J2i.Net.OpenCellID.Client
- J2i.Net.OpenCellID
- J2i.Net.WiFiPositioning
- MapPoint.SimpleClient
- SetMyKeys
- SimpleClient
- WiMoWiFiPositioning.html
- WiMoWiFiPositioningService.sln
- WpsProxy
|
using System;
using System.IO;
using System.Net;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Xml;
using System.Xml.XPath;
namespace J2i.Net.OpenCellID
{
public class OpenCellClient : IDisposable
{
string _baseUrl = "http://www.opencellid.org/cell";
string _appID = String.Empty;
bool _supressIOErrors;
RILCELLTOWERINFO lastTower = null;
CellTowerLocation lastLocation = null;
public OpenCellClient()
{
}
public OpenCellClient(string appID):this()
{
_appID = appID;
}
public CellTowerLocation GetCellTowerLocation (uint mobileCountryCode, uint mobileNetworkCode, uint localeAreaCode, uint cellID)
{
CellTowerLocation retVal = null;
string requestAddress = String.Format("{0}/get?mnc={1}&mcc={2}&lac={3}&cellid={4}",
_baseUrl,
mobileNetworkCode, mobileCountryCode, localeAreaCode, cellID);
try
{
WebRequest webRequest = HttpWebRequest.Create(requestAddress);
WebResponse response = webRequest.GetResponse();
using (Stream xmlSource = response.GetResponseStream())
{
XmlDocument xd = new XmlDocument();
xd.Load(xmlSource);
if (xd.GetElementsByTagName("rsp")[0].Attributes["stat"].Value.Equals("ok"))
{
XmlNode cellNode = xd.GetElementsByTagName("cell")[0];
retVal = new CellTowerLocation();
retVal.cellid = cellID;
retVal.mcc = mobileCountryCode;
retVal.mnc = mobileNetworkCode;
retVal.lac = localeAreaCode;
retVal.lat = Double.Parse(cellNode.Attributes["lat"].Value);
retVal.lon = Double.Parse(cellNode.Attributes["lon"].Value);
retVal.nbSamples = Int32.Parse(cellNode.Attributes["nbSamples"].Value);
retVal.range = Int32.Parse(cellNode.Attributes["range"].Value);
}
}
}
catch (Exception exc)
{
if (!_supressIOErrors)
throw;
}
return retVal;
}
public CellTowerLocation GetCellTowerLocation()
{
RILCELLTOWERINFO towerInfo = RIL.GetCellTowerInfo();
if ((lastTower != null) && ((lastTower.dwMobileCountryCode == towerInfo.dwMobileCountryCode) && (lastTower.dwLocationAreaCode == towerInfo.dwLocationAreaCode) && (lastTower.dwMobileNetworkCode == towerInfo.dwMobileNetworkCode) && (lastTower.dwCellID == towerInfo.dwCellID)))
{
return lastLocation;
}
return (lastLocation = GetCellTowerLocation(towerInfo.dwMobileCountryCode, towerInfo.dwMobileNetworkCode, towerInfo.dwLocationAreaCode, towerInfo.dwCellID));
}
public int AddMeasure(uint mobileCountryCode, uint mobileNetworkCode, uint localeAreaCode, uint cellID, double latitude, double longitude)
{
TestAppID();
int retVal = 0;
string requestAddress = String.Empty;
requestAddress = string.Format("{0}/measure/add?key={1}?&mnc={2}&mcc={3}&lac={4}&cellid={5}&lat={6}&long={7}",
_baseUrl,
_appID, mobileNetworkCode,
mobileNetworkCode,
mobileCountryCode,
localeAreaCode,
cellID,
latitude,
longitude);
try
{
WebRequest webRequest = HttpWebRequest.Create(requestAddress);
WebResponse response = webRequest.GetResponse();
using (Stream xmlSource = response.GetResponseStream())
{
XmlDocument xd = new XmlDocument();
xd.Load(xmlSource);
if (xd.GetElementsByTagName("rsp")[0].Attributes["stat"].Value.Equals("ok"))
{
retVal = int.Parse(xd.DocumentElement.Attributes["id"].Value);
}
}
}
catch (Exception)
{
if (!_supressIOErrors)
throw;
}
return retVal;
}
public bool DeleteMeasure(int id)
{
TestAppID();
bool retVal = false;
string requestAddress = String.Format("{0}/measure/delete/{1}?key={2}", _baseUrl, id, _appID);
try
{
WebRequest webRequest = HttpWebRequest.Create(requestAddress);
WebResponse response = webRequest.GetResponse();
using (Stream xmlSource = response.GetResponseStream())
{
XmlDocument xd = new XmlDocument();
xd.Load(xmlSource);
if (xd.GetElementsByTagName("rsp")[0].Attributes["stat"].Value.Equals("ok"))
{
retVal = true;
}
}
}
catch (Exception)
{
if (!_supressIOErrors)
throw;
}
return retVal;
}
private void TestAppID()
{
if ((_appID == null) || (_appID.Equals(String.Empty)))
throw new ArgumentException("An Application ID has not been set on the OpenCellClient object. A key can be requested at http://opencellid.org/users/signup", "AppID");
}
#region IDisposable Members
public void Dispose()
{
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.