Beispiel #1
0
    public static bool IsLogEntry(string line, ref Hashtable dataEntry)
    {
        string pattern = @"(\-?\d{1,3}\.\d+),(\-?\d{1,3}\.\d+),(0|1),"
                         + @"(\-?\d+),(\d+\.\d+),(\d{2}\-\D{3}\-\d{2}),"
                         + @"(\d{2}:\d{2}:\d{2}),?(\d{1,2})?,?(\d\.\d)?,?([23]{1}D)?";

        Match lineMatch = Regex.Match(line, pattern, RegexOptions.IgnoreCase);

        if (!lineMatch.Success)
        {
            return(false);
        }

        dataEntry["Latitude"]  = lineMatch.Groups[1].ToString();
        dataEntry["Longitude"] = lineMatch.Groups[2].ToString();
        dataEntry["Code"]      = lineMatch.Groups[3].ToString();
        dataEntry["Altitude"]  = lineMatch.Groups[4].ToString();
        dataEntry["Date"]      = lineMatch.Groups[5].ToString();
        dataEntry["DateStr"]   = lineMatch.Groups[6].ToString();
        dataEntry["TimeStr"]   = lineMatch.Groups[7].ToString();

        NumberFormatInfo numberFormat = new NumberFormatInfo();

        numberFormat.NumberDecimalSeparator = ".";

        dataEntry["GenLogFormat"] = LogFormat.OziExplorer;
        dataEntry["GenDateTime"]  = LogOziExplorer.GetEntryDateTime(
            Double.Parse(dataEntry["Date"].ToString(), numberFormat));

        return(true);
    }
Beispiel #2
0
    public static LogBase CreateLogInstance(LogFormat format)
    {
        LogBase logInstance = null;

        switch (format)
        {
        case LogFormat.GPRMC:
            logInstance = new LogGPRMC();
            break;

        case LogFormat.OziExplorer:
            logInstance = new LogOziExplorer();
            break;
        }

        return(logInstance);
    }
Beispiel #3
0
    public override void ParseStringData(string dataString)
    {
        string[] lines = dataString.Split('\n');
        foreach (string line in lines)
        {
            Hashtable dataEntry = new Hashtable();
            if (!LogOziExplorer.IsLogEntry(line, ref dataEntry))
            {
                continue;
            }

            this.dataArray.Add(dataEntry);

            if (dataArray.Count == 1)
            {
                this.start = (DateTime)dataEntry["GenDateTime"];
                this.end   = (DateTime)dataEntry["GenDateTime"];
            }
            this.UpdateLogStartEnd((DateTime)dataEntry["GenDateTime"]);
        }
    }
Beispiel #4
0
    public static LogFormat DetectLogFormatFromString(ref string dataString)
    {
        Hashtable dummyEntry = new Hashtable();
        LogFormat format     = LogFormat.Unknown;

        string[] lines = dataString.Split('\n');

        foreach (string line in lines)
        {
            if (LogGPRMC.IsLogEntry(line, ref dummyEntry))
            {
                format = LogFormat.GPRMC;
                break;
            }

            if (LogOziExplorer.IsLogEntry(line, ref dummyEntry))
            {
                format = LogFormat.OziExplorer;
                break;
            }
        }

        return(format);
    }
Beispiel #5
0
    public static LogBase CreateLogInstance(LogFormat format)
    {
        LogBase logInstance = null;
        switch (format)
        {
            case LogFormat.GPRMC:
                logInstance = new LogGPRMC();
                break;

            case LogFormat.OziExplorer:
                logInstance = new LogOziExplorer();
                break;
        }

        return logInstance;
    }