Page 1 of 1

validate Longitude and Latitude

Posted: Thu Sep 21, 2017 6:25 pm
by nandika.kodituwakku
Hi All,

I want to validate Longitude and Latitude and was tired with below , but seems like it didn't work properly

IF Trim(NullToEmpty(DSLink108.LONGITUDE)) >= -180.00000000 OR Trim(NullToEmpty(DSLink108.LONGITUDE)) <= +180.00000000 THEN 0
ELSE 1

IF Trim(NullToEmpty(DSLink108.LATITUDE)) >= 90.00000000 OR Trim(NullToEmpty(DSLink108.LATITUDE)) <= +90.00000000 THEN 0
ELSE 1

Please let me know if you have much better idea to validate the same.

much appreciated

Posted: Thu Sep 21, 2017 8:13 pm
by chulett
That's a pretty basic "validation", it would typically include validation of both values together. However... 0 is false and that 1 (actually any non-zero value) is true but is not necessarily intuitively obvious. You really should be using @FALSE and @TRUE, that or ditch the whole if-then-else construct and just let the expression naturally derive itself to true or false. For example, a stage variable named svIsValidLong could have your derivation of:

Code: Select all

Trim(NullToEmpty(DSLink108.LONGITUDE)) >= -180.00000000 OR Trim(NullToEmpty(DSLink108.LONGITUDE)) <= +180.00000000
Then tested via a simple "If svIsValidLong then X else Y". Same for the LAT check. Much more self-documenting IMHO.

Bottom line is I think your test may be backwards, zero versus one... plus it needs an AND in the middle, not an OR. Depending on exactly how you intend to use the validations, something I'm guessing at right now.

Posted: Fri Sep 22, 2017 5:28 am
by qt_ky
Change each OR to AND.

Posted: Fri Sep 22, 2017 6:55 am
by chulett
There's a small echo in here, it would seem. :wink:

Posted: Fri Sep 22, 2017 8:55 am
by qt_ky
Ah, yes. I see it now, hidden amongst other ramblings! :lol:

Posted: Fri Sep 22, 2017 9:16 am
by chulett
Yes, that's me... the rambler. :D

Posted: Fri Sep 22, 2017 1:30 pm
by UCDI
its your data, but be sure the entry is not valid if you cap it back to the desired range. That is, 250 degrees is a valid location on the earth, and you can convert it to a negative degree value to get it in the 'normal' gps range. Occasionally one runs into a device or code that gives the right answer in math terms but incorrect in gps formatting, is what I mean. Just a thought.