windows-phone-8

Performing search in wp8


I have a question in WP8 app development. So that's what I want to do:

I have multiple bus routes like:

Bus 1: starts from street ... ends with street ...

Bus 2.........

I add 2 text boxes where user enter:

  1. From(street name) and 2. Destination(street name)

and I need to perform a search in every bus route and show the results with which bus user can get to destination.

the only thing I need to understand is where to save the bus route and how to preform a search in that file or string? here's a little code:

 int search(string *from, string *to)
    {
    char[200]; int busnumber;
    //first compare if the from matches
    for(busnumber=1; bussnumber<10; bussnumber++)
    {
    if(stricmp(from,busnr[busnumber])==0)
       {
          if(stricmp(to,busnr[busnumber])==0)
           {
               return busnumber;
            }
        }
     }

   }

Solution

  • I didn't understand your question well but here's what I can think of. If you have data ordered in following manner:

    [bus_number][start][destination]

    and your data omit all the middle bus stops, then you have to simply iterate through the list. Although if there is an option that user wants to find path to a place for which there is no direct bus, and he will have to change buses, then you have to use graph and an algorith that efficiently searches the path. You will also have to use weighted graph if your data is as following:

    [bus_number][start][busstop2][busstop3]...[busstop(n-1)][end]

    and find a path with a constraint for example that you cannot have more than three buses changes.This algorithm will be a little bit complicated.