File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change 137
137
* @return {boolean }
138
138
*/
139
139
equals : function ( otherGlobeCoordinate ) {
140
- if ( ! ( otherGlobeCoordinate instanceof globeCoordinate . GlobeCoordinate ) ) {
140
+ if ( ! ( otherGlobeCoordinate instanceof SELF )
141
+ || otherGlobeCoordinate . _globe !== this . _globe
142
+ ) {
141
143
return false ;
142
144
}
143
145
144
- var gc1Iso6709 = globeCoordinate . iso6709 ( this . getDecimal ( ) ) ,
145
- gc2Iso6709 = globeCoordinate . iso6709 ( otherGlobeCoordinate . getDecimal ( ) ) ;
146
-
147
- return ( this . _precision === otherGlobeCoordinate . _precision
148
- || Math . abs ( this . _precision - otherGlobeCoordinate . _precision ) < 0.00000001 )
149
- && gc1Iso6709 === gc2Iso6709
150
- && this . _globe === otherGlobeCoordinate . _globe ;
146
+ // 0.00000001° corresponds to approx. 1 mm on Earth and can always be considered equal.
147
+ var oneMillimeter = 0.00000001 ,
148
+ epsilon = Math . max (
149
+ // A change worth 1/2 precision might already become a visible change
150
+ Math . min ( this . _precision , otherGlobeCoordinate . _precision ) / 2 ,
151
+ oneMillimeter
152
+ ) ;
153
+
154
+ return Math . abs ( otherGlobeCoordinate . _precision - this . _precision ) < oneMillimeter
155
+ && Math . abs ( otherGlobeCoordinate . _latitude - this . _latitude ) < epsilon
156
+ && Math . abs ( otherGlobeCoordinate . _longitude - this . _longitude ) < epsilon ;
151
157
}
152
158
} ;
153
159
You can’t perform that action at this time.
0 commit comments