void ISectionParser.Populate(AreaToken token, Operation operation)
 {
     if (token.Identifier == "Einsatznummer")
     {
         operation.OperationNumber = token.Value;
     }
 }
 void ISectionParser.Populate(AreaToken token, Operation operation)
 {
     string msg = token.Value;
     if (token.Identifier == KeywordKeyword)
     {
         operation.Keywords.Keyword = msg;
     }
     else if (token.Identifier == KeywordB)
     {
         operation.Keywords.B = msg;
     }
     else if (token.Identifier == KeywordR)
     {
         operation.Keywords.R = msg;
     }
     else if (token.Identifier == KeywordS)
     {
         operation.Keywords.S = msg;
     }
     else if (token.Identifier == KeywordT)
     {
         operation.Keywords.T = msg;
     }
 }
 void ISectionParser.Populate(AreaToken token, Operation operation)
 {
     // Just append...
     operation.Comment += token.OriginalValue + "\n";
 }
        void ISectionParser.Populate(AreaToken token, Operation operation)
        {
            // Determine which location to populate
            PropertyLocation location = null;
            switch (AffectedLocation)
            {
                case "Zielort":
                    location = operation.Zielort;
                    break;
                default:
                case "Einsatzort":
                    location = operation.Einsatzort;
                    break;
            }

            string msg = token.Value;
            if (token.Identifier == KeywordStreet)
            {
                location.Street = msg;
            }
            else if (token.Identifier == KeywordStreetNumber)
            {
                location.StreetNumber = msg;
            }
            else if (token.Identifier == KeywordCity)
            {
                location.ZipCode = ReadZipCodeFromCity(msg);
                if (string.IsNullOrWhiteSpace(location.ZipCode))
                {
                    Logger.Instance.LogFormat(LogType.Warning, this, "Could not find a zip code for city '{0}'. Route planning may fail or yield wrong results!", location.City);
                }

                location.City = msg.Remove(0, location.ZipCode.Length).Trim();

                // The City-text often contains a dash after which the administrative city appears multiple times (like "City A - City A City A").
                // However we can (at least with google maps) omit this information without problems!
                int dashIndex = location.City.IndexOf('-');
                if (dashIndex != -1)
                {
                    // Ignore everything after the dash
                    location.City = location.City.Substring(0, dashIndex);
                }
            }
            else if (token.Identifier == KeywordIntersection)
            {
                location.Intersection = msg;
            }
            else if (token.Identifier == KeywordProperty)
            {
                location.Property = msg;
            }
        }
Exemplo n.º 5
0
            private static IEnumerable<AreaToken> GetTokensInLine(IList<string> validTokens, string line)
            {
                List<AreaToken> tokens = new List<AreaToken>();

                foreach (string tokenInQuestion in validTokens)
                {
                    int index = line.IndexOf(tokenInQuestion, StringComparison.CurrentCultureIgnoreCase);
                    if (index == -1)
                    {
                        continue;
                    }

                    AreaToken at = new AreaToken(line);
                    at.Identifier = tokenInQuestion;
                    at.Occurrence = index;

                    tokens.Add(at);
                }

                // Second step: Parse the values, knowing successors
                LinkedList<AreaToken> linkedList = new LinkedList<AreaToken>(tokens);

                LinkedListNode<AreaToken> currentToken = linkedList.First;
                while (currentToken != null)
                {
                    int from = currentToken.Value.Occurrence;
                    int to = currentToken.Next != null ? currentToken.Next.Value.Occurrence : 0;

                    currentToken.Value.Value = GetMessageText(line, currentToken.Value.Identifier, from, to);

                    if (currentToken.Next == null)
                    {
                        break;
                    }
                    currentToken = currentToken.Next;
                }

                return linkedList;
            }
Exemplo n.º 6
0
            internal void TokenizeLines()
            {
                IList<string> validTokens = GetValidTokens();

                // Merge all lines to check for tokens
                string mergedText = string.Join("", Lines);

                Tokens = new List<AreaToken>();
                foreach (string line in Lines)
                {
                    IList<AreaToken> tokensInThisLine = GetTokensInLine(validTokens, line).ToList();
                    if (tokensInThisLine.Count == 0)
                    {
                        // No token(s) --> take whole line as one token with nothing else
                        AreaToken areaToken = new AreaToken(line);
                        Tokens.Add(areaToken);
                    }

                    Tokens.AddRange(tokensInThisLine);
                }
            }
 void ISectionParser.Populate(AreaToken token, Operation operation)
 {
 }