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
validate Longitude and Latitude
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 5
- Joined: Tue Sep 13, 2016 5:19 pm
- Location: Australia
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:
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.
Code: Select all
Trim(NullToEmpty(DSLink108.LONGITUDE)) >= -180.00000000 OR Trim(NullToEmpty(DSLink108.LONGITUDE)) <= +180.00000000
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.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
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.