Created
December 20, 2017 18:01
-
-
Save rfprod/b18782c72d0a8f347d37ab3e40951712 to your computer and use it in GitHub Desktop.
DD geo coordinates regex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const lat1 = '-89.99151651'; | |
const lon1 = '42.015332'; | |
const lat2 = '-189.99151651'; | |
const lon2 = '142.015332'; | |
const lat3 = '189.99151651'; | |
const lon3 = '242.015332'; | |
const latRegX = /^(-)?(90(\.[0]+)?|[0-8]{0,1}[0-9](\.\d+)?)$/; | |
const lonRegX = /^(-)?(180(\.[0]+)?|[1]{0,1}[0-7]{0,1}[0-9](\.\d+)?)$/; | |
const lat1test = latRegX.test(lat1); | |
const lon1test = lonRegX.test(lon1); | |
const lat2test = latRegX.test(lat2); | |
const lon2test = lonRegX.test(lon2); | |
const lat3test = latRegX.test(lat2); | |
const lon3test = lonRegX.test(lon2); | |
console.log('lat1test, ' + lat1, lat1test); | |
console.log('lon1test, ' + lon1, lon1test); | |
console.log('lat2test, ' + lat2, lat2test); | |
console.log('lon2test, ' + lon2, lon2test); | |
console.log('lat3test, ' + lat3, lat3test); | |
console.log('lon3test, ' + lon3, lon3test); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment