Need help in visual studio 2005 to compare string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kilavo
    New Member
    • Jul 2013
    • 3

    Need help in visual studio 2005 to compare string

    I'm developing a system which I want to locate different places. Have the database which contain some Latitude and longitude and want to compare with the one received from the GPS through GSM modem which are string. Example Latitude 3.23909S, Longitude 36.47961E. Assume I have in the database Latitude 3.24907S, Longitude 37.57899E as Location X and Latitude 2.98765S, Longitude 35.46769E as location Y. How can I compare and say that the string received from the GPS through GSM modem is greater than location Y or less than location X that in the database?
    current I'm using
    execproc.Parame ters["@SearchVal ue1"].Value = Latitude.ToStri ng();
    execproc.Parame ters["@SearchVal ue2"].Value = longitude.ToStr ing();
    drac = execproc.Execut eReader();
    if (drac.HasRows)
    but this is only when they are equal.
    Last edited by Kilavo; Jul 5 '13, 04:38 PM. Reason: adding content
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Define 'less than'. It sounds like you mean where both long and lat is less than the long and lat of the input. And it sounds like 'more than' would be the opposite of that. But then you're missing other possibilities. What if the long is less but the lat is greater? What do you do then? Or what about the opposite of that? And what if one or more are equal? With your current definition of less and more, you have excluded multiple other possibilities.

    If you want to return the other points so you can do a comparison, then don't restrict your query.

    Comment

    • Kilavo
      New Member
      • Jul 2013
      • 3

      #3
      Thanks, Yes I agree with you that I'm missing some other possibilities. It become more complex, the other possibilities is when either long is less or greater and lat is equal and opposite.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        I'm not sure if you expected a response to that but just so you are aware, you haven't added anything to which I can respond. You've only reiterated my points.

        If you're looking for additional help, then you need to respond to my points, not mirror them. Specifically, you need to now tell us how you want to handle those other situations and also you need to respond to my point regarding the restriction of the query.

        Comment

        • Kilavo
          New Member
          • Jul 2013
          • 3

          #5
          The main thing I want to know is how to check/compare if the lat and long received from the GPS through GSM modem are located before, after or at point X or Y.

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            You've already said that. And like I said before, you need to define before and after.

            Comment

            • Frinavale
              Recognized Expert Expert
              • Oct 2006
              • 9749

              #7
              It sounds like you probably want to get the last character off of the strings.

              This will tell you if the lat. or long. is North, South, East or West.

              The first thing I would do is check these values. If one is north and one is south, obviously the south one is "under" (less than?) the north one. Likewise if one is east and one is west, obviously they don't equal.

              You need to determine, using your own business rules, which is "greater".
              For example, is:
              • North>South?
              • North<South?
              • West>East?
              • West<East?


              If the characters match (meaning they are both marking North, South, East or West) then you need to compare the numbers.

              I would use the one of the Double.TryParse Methods. That will give you back a number and you can just compare whether or not it's larger.

              -Frinny

              Comment

              Working...