validate Longitude and Latitude

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
nandika.kodituwakku
Premium Member
Premium Member
Posts: 5
Joined: Tue Sep 13, 2016 5:19 pm
Location: Australia

validate Longitude and Latitude

Post 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
npk
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Change each OR to AND.
Choose a job you love, and you will never have to work a day in your life. - Confucius
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There's a small echo in here, it would seem. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Ah, yes. I see it now, hidden amongst other ramblings! :lol:
Choose a job you love, and you will never have to work a day in your life. - Confucius
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yes, that's me... the rambler. :D
-craig

"You can never have too many knives" -- Logan Nine Fingers
UCDI
Premium Member
Premium Member
Posts: 383
Joined: Mon Mar 21, 2016 2:00 pm

Post 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.
Post Reply