tags:

views:

199

answers:

2

Hi all,

i am searching for latitude and and longitude validation.

can any one suggest that validation.

i am using

if (Regex.IsMatch(textBox1.Text, "\b(?(?:90|(?:[0-8]?\\d))([ -/])[0-5]?\\d\\1[0-5]?\\d(\\.\\d{1,4})?\\1[NS])\b") == true)

Thanks to all.

A: 

Check if the latitude is between +/- 90 degrees (or +/- pi/2 radians) and the longitude is between +/- 180 degrees (or +/- pi radians).

Can't really give you much more than that without more detail on exactly what validation you're talking about.

Amber
yes with in range of latitude and longitude,what u mentioned above.
rajeshpv.ece
Can u say how to validate those ranges?
rajeshpv.ece
+1  A: 

It doesn't make sense to validate a string, these are numbers. Convert to a number first:

  bool ValidateLongtitude(string txt) {
    double value;
    if (!double.TryParse(txt, out value)) return false;
    return value >= -180 && value <= 180;
  }
Hans Passant
Yes this is answer.Thanking u.
rajeshpv.ece