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 127
127
* @return {boolean }
128
128
*/
129
129
equals : function ( otherGlobeCoordinate ) {
130
- if ( ! ( otherGlobeCoordinate instanceof globeCoordinate . GlobeCoordinate ) ) {
130
+ if ( ! ( otherGlobeCoordinate instanceof SELF )
131
+ || otherGlobeCoordinate . _globe !== this . _globe
132
+ ) {
131
133
return false ;
132
134
}
133
135
134
- var gc1Iso6709 = globeCoordinate . iso6709 ( this . getDecimal ( ) ) ,
135
- gc2Iso6709 = globeCoordinate . iso6709 ( otherGlobeCoordinate . getDecimal ( ) ) ;
136
-
137
- return ( this . _precision === otherGlobeCoordinate . _precision
138
- || Math . abs ( this . _precision - otherGlobeCoordinate . _precision ) < 0.00000001 )
139
- && gc1Iso6709 === gc2Iso6709
140
- && this . _globe === otherGlobeCoordinate . _globe ;
136
+ // 0.00000001° corresponds to approx. 1 mm on Earth and can always be considered equal.
137
+ var oneMillimeter = 0.00000001 ,
138
+ epsilon = Math . max (
139
+ // A change worth 1/2 precision might already become a visible change
140
+ Math . min ( this . _precision , otherGlobeCoordinate . _precision ) / 2 ,
141
+ oneMillimeter
142
+ ) ;
143
+
144
+ return Math . abs ( otherGlobeCoordinate . _precision - this . _precision ) < oneMillimeter
145
+ && Math . abs ( otherGlobeCoordinate . _latitude - this . _latitude ) < epsilon
146
+ && Math . abs ( otherGlobeCoordinate . _longitude - this . _longitude ) < epsilon ;
141
147
}
142
148
} ;
143
149
You can’t perform that action at this time.
0 commit comments