Пример #1
0
        public static Waypoint[] FilterData(Waypoint[] points, WaypointFilterArgs args)
        {
            if(args == null) return points;

            var gp = points.GroupBy(wp => wp.Extensions.MacAddress);

            //string currentMac;

            foreach (IGrouping<string, Waypoint> waypoint in gp)
            {
                //Console.WriteLine(waypoint.Key);
                //currentMac = waypoint.Key;
                foreach (Waypoint wp in waypoint)
                {
                    //If the point is already ignored, skip it
                    if(wp.Ignore) continue;
                    //Ignore the point of the GPS seemed to have been locked up
                    if (args.GpsLockedUp)
                    {
                        if (wp != null)
                        {
                            Waypoint[] ps = waypoint.Where(wpt => wpt != wp && !wp.Ignore && wpt.Time.Equals(wp.Time)).ToArray();
                            if (ps.Count() > 0)
                            {
                                //I'm just using this to set ignore on all bad points
                                ps.All(tr => tr.Ignore = true);
                            }
                        }
                    }

                    //GPS fix filter
                    if(args.GpsFixLost)
                    {
                        if(wp.Fix != "2d" || wp.Fix != "3d" || wp.Fix != "dgps")
                        {
                            wp.Ignore = true;
                        }
                    }

                    //Minimum number of satellites
                    if(args.MinimumSatsVisible > -1)
                    {
                        if(wp.SatCount < args.MinimumSatsVisible)
                            wp.Ignore = true;
                    }

                    //Maximum speed filter
                    //Perhaps they're guilty about exceeding the speed limit, or perhaps the signal strength measurement losses accuracy?
                    if(args.MaximumSpeedKmh > -1)
                    {
                        //If the speed isn't avalible, ignore this point?
                        if(string.IsNullOrEmpty(wp.Cmt)) wp.Ignore = true;
                        else
                        {
                            try
                            {
                                double speed = double.Parse(wp.Cmt, CultureInfo.InvariantCulture.NumberFormat);
                                if (speed > args.MaximumSpeedKmh) wp.Ignore = true;
                            }
                            catch(Exception)
                            {
                                //If something went wrong, ignore the point.
                                wp.Ignore = true;
                            }
                        }
                    }

                    //Ignore high signal strengths
                    if(args.MaxSignal > -101)
                    {
                        if(wp.Extensions.Rssi > args.MaxSignal)
                            wp.Ignore = true;
                    }
                }
            }

            //return points;
            return points.Where(wp => !wp.Ignore).ToArray();
        }
Пример #2
0
        private void ExportButtonClick(object sender, EventArgs e)
        {
            if(txtInFiles.Text.Trim() == string.Empty)
            {
                MessageBox.Show(Localizer.GetString("ErrorNoLogFileSelected"), Localizer.GetString("Error"),
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (txtOutDir.Text.Trim() == string.Empty)
            {
                MessageBox.Show(Localizer.GetString("ErrorKmlDirectoryMissing"), Localizer.GetString("Error"),
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if(!txtOutDir.Text.EndsWith("\\")) txtOutDir.AppendText("\\");
            _outPath = txtOutDir.Text;

            //Append the log filename to the directory path
            int lastS = _inFiles[0].LastIndexOf('\\');
            int lastP = _inFiles[0].Substring(lastS).LastIndexOf('.');
            _outPath += _inFiles[0].Substring(lastS).Remove(lastP) + "\\";

            //Create the output directory
            System.IO.Directory.CreateDirectory(_outPath);

            //All is well, let's go
            Waypoint[] allPoints;
            try
            {
                //Load all files. An array is required because all KML classes accept arrays
                allPoints = GpxIO.ReadGpxFiles(_inFiles).ToArray();
            }
            catch(IOException)
            {
                //This happens when the file is locked by another process or inSSIDer is still logging to it.
                MessageBox.Show(
                    Localizer.GetString("GpxFileOpenError"),
                    Localizer.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Filter data
            WaypointFilterArgs farg = new WaypointFilterArgs
                                          {
                                              GpsFixLost = chGPSFixLost.Checked,
                                              GpsLockedUp = chGPSLockup.Checked,
                                              MaximumSpeedKmh = chMaxSpeed.Checked ? (int) numMaxSpeed.Value : -1,
                                              MaxSignal = chMaxSignal.Checked ? (int) numMaxSignal.Value : -1,
                                              MinimumSatsVisible = chGPSsatCount.Checked ? (int) numSatCount.Value : -1
                                          };
            allPoints = KmlWriter.FilterData(allPoints, farg);

            ApOrganization group = (ApOrganization)cmbOrganize.SelectedIndex;

            if(chExportSummary.Checked) //Export a summary file
            {
                if (!System.IO.File.Exists(_outPath + "Summary.kml") ||
                    MessageBox.Show(Localizer.GetString("WarningSummaryKmlExists"),
                                    Localizer.GetString("FileExists"), MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                {
                    KmlWriter.WriteSummaryKml(allPoints, _outPath + "Summary.kml", group, chShowRssiMarkers.Checked);
                }
            }

            if(chExportComp.Checked) //Comprehensive
            {
                if (!System.IO.File.Exists(_outPath + "Comprehensive.kml") ||
                    MessageBox.Show(Localizer.GetString("WarningComprehensiveKmlExists"),
                                    Localizer.GetString("FileExists"), MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                {
                    KmlWriter.WriteComprehensiveKml(allPoints, _outPath + "Comprehensive.kml", group, chShowRssiMarkers.Checked);
                }
            }

            if(chExportEachAp.Checked) //Export each AP to ./APs/{SSID}.kml
            {
                KmlWriter.WriteAccessPointKml(allPoints,_outPath,chShowRssiMarkers.Checked);
            }

            MessageBox.Show(Localizer.GetString("ExportComplete"), Localizer.GetString("Finished"), MessageBoxButtons.OK);
        }
Пример #3
0
        public static Waypoint[] FilterData(Waypoint[] points, WaypointFilterArgs args)
        {
            if (args == null)
            {
                return(points);
            }

            var gp = points.GroupBy(wp => wp.Extensions.MacAddress);

            //string currentMac;

            foreach (IGrouping <string, Waypoint> waypoint in gp)
            {
                //Console.WriteLine(waypoint.Key);
                //currentMac = waypoint.Key;
                foreach (Waypoint wp in waypoint)
                {
                    //If the point is already ignored, skip it
                    if (wp.Ignore)
                    {
                        continue;
                    }
                    //Ignore the point of the GPS seemed to have been locked up
                    if (args.GpsLockedUp)
                    {
                        if (wp != null)
                        {
                            Waypoint[] ps = waypoint.Where(wpt => wpt != wp && !wp.Ignore && wpt.Time.Equals(wp.Time)).ToArray();
                            if (ps.Count() > 0)
                            {
                                //I'm just using this to set ignore on all bad points
                                ps.All(tr => tr.Ignore = true);
                            }
                        }
                    }

                    //GPS fix filter
                    if (args.GpsFixLost)
                    {
                        if (wp.Fix != "2d" || wp.Fix != "3d" || wp.Fix != "dgps")
                        {
                            wp.Ignore = true;
                        }
                    }

                    //Minimum number of satellites
                    if (args.MinimumSatsVisible > -1)
                    {
                        if (wp.SatCount < args.MinimumSatsVisible)
                        {
                            wp.Ignore = true;
                        }
                    }

                    //Maximum speed filter
                    //Perhaps they're guilty about exceeding the speed limit, or perhaps the signal strength measurement losses accuracy?
                    if (args.MaximumSpeedKmh > -1)
                    {
                        //If the speed isn't avalible, ignore this point?
                        if (string.IsNullOrEmpty(wp.Cmt))
                        {
                            wp.Ignore = true;
                        }
                        else
                        {
                            try
                            {
                                double speed = double.Parse(wp.Cmt, CultureInfo.InvariantCulture.NumberFormat);
                                if (speed > args.MaximumSpeedKmh)
                                {
                                    wp.Ignore = true;
                                }
                            }
                            catch (Exception)
                            {
                                //If something went wrong, ignore the point.
                                wp.Ignore = true;
                            }
                        }
                    }

                    //Ignore high signal strengths
                    if (args.MaxSignal > -101)
                    {
                        if (wp.Extensions.Rssi > args.MaxSignal)
                        {
                            wp.Ignore = true;
                        }
                    }
                }
            }

            //return points;
            return(points.Where(wp => !wp.Ignore).ToArray());
        }