Index: branches/Maps0.8/includes/ext.maps.coord.js |
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | */ |
67 | 67 | this.float = function( lat, lon ) { |
68 | 68 | return lat.toString() + this.SEPARATOR + ' ' + lon.toString(); |
69 | | - } |
| 69 | + }; |
70 | 70 | |
71 | 71 | this.parse = function( coord ) { |
72 | 72 | coord = coord.split( this.SEPARATOR ); |
— | — | @@ -82,24 +82,34 @@ |
83 | 83 | if ( parsed !== false ) return parsed; |
84 | 84 | |
85 | 85 | return false; |
86 | | - } |
| 86 | + }; |
87 | 87 | |
88 | 88 | this.parseDMS = function( lat, lon ) { |
89 | | - if ( true ) { |
| 89 | + if ( this.isDMS( lat, lon ) ) { |
90 | 90 | // TODO |
91 | 91 | } |
92 | 92 | else { |
93 | 93 | return false; |
94 | 94 | } |
95 | | - } |
| 95 | + }; |
96 | 96 | |
97 | 97 | this.parseFloat = function( lat, lon ) { |
98 | | - if ( true ) { |
99 | | - // TODO |
| 98 | + if ( this.isFloat( lat, lon ) ) { |
| 99 | + return { lat: parseFloat( lat ), lon: parseFloat( lon ) }; |
100 | 100 | } |
101 | 101 | else { |
102 | 102 | return false; |
103 | 103 | } |
104 | | - } |
| 104 | + }; |
105 | 105 | |
| 106 | + this.isFloat = function( lat, lon ) { |
| 107 | + var regex = /(-)?\d{1,3}(\.\d{1,20})?$/; |
| 108 | + return regex.test( lat ) && regex.test( lon ); |
| 109 | + }; |
| 110 | + |
| 111 | + this.isDMS = function( lat, lon ) { |
| 112 | + var regex = ''; // TODO |
| 113 | + return regex.test( lat ) && regex.test( lon ); |
| 114 | + }; |
| 115 | + |
106 | 116 | } )( jQuery ); |
\ No newline at end of file |