public static geo Getgeo( string location) { string geo = ""; geo mygeo = new geo(); string results = String.Empty; HttpWebRequest searchRequest = (HttpWebRequest)WebRequest.Create(@"http://maps.google.com/maps?f=q&geocode=&q=" + location + "&output=js"); WebResponse myresponse = searchRequest.GetResponse(); Stream responseStream = myresponse.GetResponseStream(); byte[] buffer = new byte[9999]; responseStream.Read(buffer, 0, (int)9999); results = System.Text.Encoding.ASCII.GetString(buffer); System.Text.RegularExpressions.Regex myregex = new Regex(@"center..lat\:[^,]+,lng\:.{0,1}[0-9]+.[0-9]+"); MatchCollection mc = myregex.Matches(results); foreach (Match mymatch in mc) { geo = mymatch.Value; string latitude = geo.Substring(geo.IndexOf("lat:") + 4, 5); string Longitude = geo.Substring(geo.IndexOf("lng:") + 4, 5); mygeo.Latitude = latitude; mygeo.Longitude = Longitude; } myresponse.Close(); responseStream.Close(); return mygeo; }
public async System.Threading.Tasks.Task armarAsync(int uno, int dos, string tres, string cuatro, string MacAddress1, string macRouter) { geo _geo = new geo(); Position _position = await _geo.GetPosition(); MiPing iping = manejador.getPing(); Datos datos = new Datos() { lat = (Double)_position.Latitude, lng = (Double)_position.Longitude, RTT = iping.RTTdeMiPing, status = iping.status, address = iping.Address, jitter = calculate.getJitter(iping.RTTdeMiPing), lantency = calculate.getLatency(iping.RTTdeMiPing), LinkSpeed = uno, SignLevel = dos, ssid = tres, DefaultGate = cuatro, MacAddress = MacAddress1, mail = Settings.email, pass = Settings.pass, MacDelRouter = macRouter, }; string x = envia.sendJson(datos); changer changer = new changer(); changer.changerStatus(x); }
private async void ejecutarhilo() { RunOnUiThread(async() => { geo _geo = new geo(); Position _position = await _geo.GetPosition(); Toast.MakeText(ApplicationContext, _position.Latitude.ToString() + "," + _position.Longitude, ToastLength.Long).Show(); }); }
public byte[] Serialize(geo geo) { List <byte> DataStream = new List <byte>(); DataStream.AddRange(BitConverter.GetBytes(geo.dimX)); DataStream.AddRange(BitConverter.GetBytes(geo.dimY)); DataStream.AddRange(BitConverter.GetBytes(geo.dimZ)); DataStream.AddRange(BitConverter.GetBytes(geo.offX)); DataStream.AddRange(BitConverter.GetBytes(geo.offY)); DataStream.AddRange(BitConverter.GetBytes(geo.offZ)); return(DataStream.ToArray()); }
public state_o(UInt32 id, byte category, byte type, UInt16 visMask, char[] name, geo geo, coord pos, UInt32 parent, UInt16 cfgFlags, UInt16 cfgModelId) { this.id = id; this.category = category; this.type = type; this.visMask = visMask; this.name = name; this.geo = geo; this.pos = pos; this.parent = parent; this.cfgFlags = cfgFlags; this.cfgModelId = cfgModelId; }
public state_o(byte[] DataStream) { this.id = BitConverter.ToUInt32(DataStream, 0); this.category = DataStream[4]; this.type = DataStream[5]; this.visMask = BitConverter.ToUInt16(DataStream, 6); Buffer.BlockCopy(DataStream, 8, name_b, 0, 32); Buffer.BlockCopy(DataStream, 40, geo_b, 0, 24); Buffer.BlockCopy(DataStream, 64, coord_b, 0, 40); this.name = Encoding.ASCII.GetString(name_b).ToCharArray(); this.geo = new geo(geo_b); this.pos = new coord(coord_b); this.parent = BitConverter.ToUInt32(DataStream, 104); this.cfgFlags = BitConverter.ToUInt16(DataStream, 108); this.cfgModelId = BitConverter.ToUInt16(DataStream, 110); }
public static byte[] CatchPacket(double simTime, UInt32 id, geo geo, coord pos, coord speed, coord accel, UInt32 counter, wheel_o[] wheel_O) { Packet pkt = new Packet(); header_m[] header_M = new header_m[4]; header_c header_C; state_o state_O = new state_o(id, 1, 1, 0x6, hp.myname, geo, pos, 0, 0, 0); state_e state_E = new state_e(speed, accel, 498.55f, hp.spare); state state = new state(state_O, state_E); header_M[3] = new header_m(0, 0, 2, 0x0000); header_M[2] = new header_m(176, 44, 14, 0x0000); header_M[1] = new header_m(208, 208, 9, 0x1); header_M[0] = new header_m(0, 0, 1, 0x0000); header_C = new header_c(448, counter, simTime); byte[] stream = pkt.FormPacketArray(header_C, header_M[0], header_M[1], state, header_M[2], wheel_O, header_M[3]); return(stream); }
public static byte[] CatchPacket(geo geo, coord pos, coord speed, coord accel, UInt32 counter) { Packet pkt = new Packet(); header_m[] header_M = new header_m[3]; state_o state_O = new state_o(3, 255, 255, 3, hp.myname, geo, pos, 3, 3, 8); state_e state_E = new state_e(speed, accel, 498.55f, hp.spare); state state = new state(state_O, state_E); header_M[2] = new header_m(0, 0, 2, 99); header_M[1] = new header_m(208 + header_M[2].headerSize, 208 + header_M[2].headerSize, 9, 99); header_M[0] = new header_m(header_M[1].headerSize + header_M[1].dataSize, header_M[1].headerSize + header_M[1].dataSize, 1, 99); header_c header_C = new header_c(header_M[0].headerSize + header_M[0].dataSize, counter); int[] lens = { (int)header_C.headerSize, (int)header_M[0].headerSize, (int)header_M[1].headerSize, (int)header_M[1].dataSize - (int)header_M[2].headerSize, (int)header_M[2].headerSize }; byte[] stream = pkt.FormPacketArray(header_C, header_M[0], header_M[1], state, header_M[2]); return(stream); }
protected void Button1_Click(object sender, EventArgs e) { if (FileUpload1.PostedFile != null) { int counter = 1; Dictionary <int, Dictionary <string, string> > PageDictionary = new Dictionary <int, Dictionary <string, string> >(); Dictionary <string, string> LineDictionary; string line; System.IO.StreamReader file = new System.IO.StreamReader(FileUpload1.PostedFile.FileName); string filler = ""; while ((line = file.ReadLine()) != null) { LineDictionary = new Dictionary <string, string>(); LineDictionary["borough"] = line.Substring(0, 1); LineDictionary["hn1"] = line.Substring(1, 11); LineDictionary["hn2"] = line.Substring(13, 11); LineDictionary["street"] = line.Substring(25, 31); LineDictionary["district"] = line.Substring(57, 2); LineDictionary["subsection"] = line.Substring(60, 2); LineDictionary["filler"] = filler.PadRight(212, ' '); PageDictionary[counter] = LineDictionary; counter++; } counter = 1; Wa1 mywa1; geo mygeo; //Wa2F5 mywa2f5; Wa2F1ax mywa2f1ax; string ElevenSpaces = " "; foreach (KeyValuePair <int, Dictionary <string, string> > entry in PageDictionary) { mywa1 = new Wa1(); mygeo = new geo(); mywa2f1ax = new Wa2F1ax(); mywa1.in_boro1 = PageDictionary[counter]["borough"]; mywa1.in_hnd = PageDictionary[counter]["hn1"]; mywa1.in_low_hnd = PageDictionary[counter]["hn2"]; mywa1.in_stname1 = PageDictionary[counter]["street"]; mywa1.in_func_code = "1A"; mywa1.in_platform_ind = "C"; mywa1.in_mode_switch = "X"; mygeo.GeoCall(ref mywa1, ref mywa2f1ax); string strPath = Environment.GetFolderPath( System.Environment.SpecialFolder.DesktopDirectory); if (mywa1.out_grc == "00" || mywa1.out_grc == "01") { string newLine = mywa2f1ax.gridkey1.ToString() + ElevenSpaces + PageDictionary[counter]["district"] + PageDictionary[counter]["subsection"] + PageDictionary[counter]["filler"]; string text = Environment.NewLine + newLine; System.IO.File.AppendAllText(strPath + "\\results.txt", text); counter++; } else { string text = Environment.NewLine + PageDictionary[counter]["borough"] + " " + PageDictionary[counter]["hn1"] + PageDictionary[counter]["street"] + mywa1.out_error_message; System.IO.File.AppendAllText(strPath + "\\errors.txt", text); } } file.Close(); } }
public void setPoints(ref geo[] points) { this.points = points; }
public Point getXYfromLatLng(geo coordinates) { return getXYfromLatLng(coordinates.lat, coordinates.lng); }
public geo ReturnGeo(geo mygeo) { return(mygeo); }
private void button1_Click(object sender, EventArgs e) { geo myGeo = new geo(myGeoConns); string filename = null; if (addresses.Count == 0) { //Load the address input file OpenFileDialog dlg = new OpenFileDialog(); dlg.DefaultExt = ".csv"; dlg.Filter = "CSV Files (.csv)|*.csv"; if (dlg.ShowDialog() == DialogResult.OK) { filename = dlg.FileName; string file_text = File.ReadAllText(filename); char[] sep = { '\n' }; string[] rows = file_text.Split(sep); int i = 0; foreach (string x in rows) { char[] line_sep = { ',' }; string[] next_row = x.Split(line_sep); if (i != 0) //skip headers { addresses.Add(next_row); } i++; } Console.WriteLine("Number of addresses loaded: " + addresses.Count + "\n"); } } else { MessageBox.Show("Addresses have already been loaded"); } if (addresses.Count > 2) { mywa1.Clear(); mywa1.in_func_code = "1E"; mywa1.in_mode_switch = "X"; mywa1.in_platform_ind = "C"; csv = new StringBuilder(); var headerLine = string.Format("{0},{1},{2},{3},{4},{5},{6}{7}", "Address", "Borocode", "Latitude", "Longitude", "BIN", "BBL", "Zipcode", Environment.NewLine); csv.Append(headerLine); //Console.WriteLine(String.Join(",", header_array)); int missed = 0; int hit = 0; foreach (string[] address in addresses) { //Console.WriteLine(String.Join(" | ",address)); //Console.WriteLine(address.Length); //string borough_string = null; if (address.Length > 1) { mywa1.in_b10sc1.boro = address[1]; mywa1.in_hnd = address[0].Split()[0]; //mywa1.in_hnd = address[0]; List <string> address_string_list = new List <string>(address[0].Split().Skip(1)); //List<string> address_string_list = new List<string>(address[0].Split()); string address_string = String.Join(" ", address_string_list); mywa1.in_stname1 = address_string; myGeo.GeoCall(ref mywa1, ref mywa2); if (mywa1.out_grc == "00") { hit++; Console.WriteLine(hit); var newLine = string.Format("{0},{1},{2},{3},{4},{5},{6}{7}", address[0], address[1].Trim(), mywa2.latitude, mywa2.longitude, mywa1.out_bin.BINToString(), mywa1.out_bbl.BBLToString(), mywa2.zip_code, Environment.NewLine); csv.Append(newLine); Console.WriteLine("Missed: " + missed + "\tHit:" + hit); } else if (mywa1.out_grc == "01") { hit++; Console.WriteLine(hit); var newLine = string.Format("{0},{1},{2},{3},{4},{5},{6}{7}", address[0], address[1].Trim(), mywa2.latitude, mywa2.longitude, mywa1.out_bin.BINToString(), mywa1.out_bbl.BBLToString(), mywa2.zip_code, Environment.NewLine); csv.Append(newLine); Console.WriteLine("Missed: " + missed + "\tHit:" + hit); } else { //Console.WriteLine(address[0]); missed++; Console.WriteLine("Missed: " + missed + "\tHit:" + hit); //Console.WriteLine(missed); Console.WriteLine(String.Join(" | ", address)); Console.WriteLine("\n"); //Console.WriteLine(address[5]+" "+address[6]); //Console.WriteLine(); /*Console.WriteLine("Unsuccessful"); * Console.WriteLine(String.Join(" | ", address).Trim()); * Console.WriteLine(mywa1.out_grc); * Console.WriteLine(mywa1.out_error_message);*/ //var newLine = String.Join(",", address).Trim()+Environment.NewLine; var newLine = string.Format("{0},{1},{2},{3},{4},{5},{6}{7}", address[0], address[1].Trim(), "NOT FOUND", "NOT FOUND", "NOT FOUND", "NOT FOUND", "NOT FOUND", Environment.NewLine); csv.Append(newLine); } } } MessageBox.Show("Great! Now choose where the output error file must be saved.\nDo not add the file extension, we took care of that."); saveFileDialog1.ShowDialog(); } }
public static geo CatchGeo(Vector3 geo) { geo mygeo = new geo(geo.x, geo.y, geo.z, 0, 0, 0); return(mygeo); }