@@ -30,7 +30,7 @@ namespace GeoAPI.Geometries
30
30
#endif
31
31
[ Obsolete ( "Use concrete classes like CoordinateXY, CoordinateXYM, CoordinateXYZ or CoordinateXYZM" ) ]
32
32
#pragma warning disable 612 , 618
33
- public class Coordinate : ICoordinate , IComparable < Coordinate >
33
+ public class Coordinate : IComparable < Coordinate >
34
34
{
35
35
36
36
///<summary>
@@ -82,14 +82,6 @@ public Coordinate(double x, double y, double z)
82
82
/// </summary>
83
83
public Coordinate ( ) : this ( 0.0 , 0.0 , NullOrdinate ) { }
84
84
85
- /// <summary>
86
- /// Constructs a <c>Coordinate</c> having the same (x,y,z) values as
87
- /// <c>other</c>.
88
- /// </summary>
89
- /// <param name="c"><c>Coordinate</c> to copy.</param>
90
- [ Obsolete ]
91
- public Coordinate ( ICoordinate c ) : this ( c . X , c . Y , c . Z ) { }
92
-
93
85
/// <summary>
94
86
/// Constructs a <c>Coordinate</c> having the same (x,y,z) values as
95
87
/// <c>other</c>.
@@ -201,18 +193,14 @@ private static bool EqualsWithTolerance(double v1, double v2, double tolerance)
201
193
/// </summary>
202
194
/// <param name="other"><c>Coordinate</c> with which to do the comparison.</param>
203
195
/// <returns><c>true</c> if <c>other</c> is a <c>Coordinate</c> with the same values for the x and y ordinates.</returns>
204
- public override bool Equals ( object other )
196
+ public override bool Equals ( object o )
205
197
{
206
- if ( other == null )
207
- return false ;
208
- var otherC = other as Coordinate ;
209
- if ( otherC != null )
210
- return Equals ( otherC ) ;
211
- #pragma warning disable 612 , 618
212
- if ( ! ( other is ICoordinate ) )
213
- return false ;
214
- return ( ( ICoordinate ) this ) . Equals ( ( ICoordinate ) other ) ;
215
- #pragma warning restore 612 , 618
198
+ if ( o is Coordinate other )
199
+ return Equals ( other ) ;
200
+ if ( o is CoordinateXY otherXY )
201
+ return ( ( CoordinateXY ) this ) . Equals ( otherXY ) ;
202
+
203
+ return false ;
216
204
}
217
205
218
206
/// <summary>
@@ -337,16 +325,6 @@ public virtual Coordinate Copy()
337
325
return new Coordinate ( X , Y , Z ) ;
338
326
}
339
327
340
- /// <summary>
341
- /// Create a new object as copy of this instance.
342
- /// </summary>
343
- /// <returns></returns>
344
- [ Obsolete ( "Use Copy" ) ]
345
- public object Clone ( )
346
- {
347
- return MemberwiseClone ( ) ;
348
- }
349
-
350
328
/// <summary>
351
329
/// Computes the 2-dimensional Euclidean distance to another location.
352
330
/// </summary>
@@ -403,188 +381,6 @@ public static int GetHashCode(double value)
403
381
*/
404
382
}
405
383
406
- #region ICoordinate
407
-
408
- /// <summary>
409
- /// X coordinate.
410
- /// </summary>
411
- [ Obsolete ]
412
- double ICoordinate . X
413
- {
414
- get { return X ; }
415
- set { X = value ; }
416
- }
417
-
418
- /// <summary>
419
- /// Y coordinate.
420
- /// </summary>
421
- [ Obsolete ]
422
- double ICoordinate . Y
423
- {
424
- get { return Y ; }
425
- set { Y = value ; }
426
- }
427
-
428
- /// <summary>
429
- /// Z coordinate.
430
- /// </summary>
431
- [ Obsolete ]
432
- double ICoordinate . Z
433
- {
434
- get { return Z ; }
435
- set { Z = value ; }
436
- }
437
-
438
- /// <summary>
439
- /// The measure value
440
- /// </summary>
441
- [ Obsolete ]
442
- double ICoordinate . M
443
- {
444
- get { return NullOrdinate ; }
445
- set { }
446
- }
447
-
448
- /// <summary>
449
- /// Gets/Sets <c>Coordinate</c>s (x,y,z) values.
450
- /// </summary>
451
- [ Obsolete ]
452
- ICoordinate ICoordinate . CoordinateValue
453
- {
454
- get { return this ; }
455
- set
456
- {
457
- X = value . X ;
458
- Y = value . Y ;
459
- Z = value . Z ;
460
- }
461
- }
462
-
463
- /// <summary>
464
- /// Gets/Sets the ordinate value for a given index
465
- /// </summary>
466
- /// <param name="index">The index of the ordinate</param>
467
- /// <returns>The ordinate value</returns>
468
- [ Obsolete ]
469
- Double ICoordinate . this [ Ordinate index ]
470
- {
471
- get
472
- {
473
- switch ( index )
474
- {
475
- case Ordinate . X :
476
- return X ;
477
- case Ordinate . Y :
478
- return Y ;
479
- case Ordinate . Z :
480
- return Z ;
481
- default :
482
- return NullOrdinate ;
483
- }
484
- }
485
- set
486
- {
487
- switch ( index )
488
- {
489
- case Ordinate . X :
490
- X = value ;
491
- break ;
492
- case Ordinate . Y :
493
- Y = value ;
494
- break ;
495
- case Ordinate . Z :
496
- Z = value ;
497
- break ;
498
- }
499
- }
500
- }
501
-
502
- /// <summary>
503
- /// Returns whether the planar projections of the two <c>Coordinate</c>s are equal.
504
- ///</summary>
505
- /// <param name="other"><c>Coordinate</c> with which to do the 2D comparison.</param>
506
- /// <returns>
507
- /// <c>true</c> if the x- and y-coordinates are equal;
508
- /// the Z coordinates do not have to be equal.
509
- /// </returns>
510
- [ Obsolete ]
511
- bool ICoordinate . Equals2D ( ICoordinate other )
512
- {
513
- return X == other . X && Y == other . Y ;
514
- }
515
-
516
- /// <summary>
517
- /// Compares this object with the specified object for order.
518
- /// Since Coordinates are 2.5D, this routine ignores the z value when making the comparison.
519
- /// Returns
520
- /// -1 : this.x lowerthan other.x || ((this.x == other.x) AND (this.y lowerthan other.y))
521
- /// 0 : this.x == other.x AND this.y = other.y
522
- /// 1 : this.x greaterthan other.x || ((this.x == other.x) AND (this.y greaterthan other.y))
523
- /// </summary>
524
- /// <param name="other"><c>Coordinate</c> with which this <c>Coordinate</c> is being compared.</param>
525
- /// <returns>
526
- /// A negative integer, zero, or a positive integer as this <c>Coordinate</c>
527
- /// is less than, equal to, or greater than the specified <c>Coordinate</c>.
528
- /// </returns>
529
- [ Obsolete ]
530
- int IComparable < ICoordinate > . CompareTo ( ICoordinate other )
531
- {
532
- if ( X < other . X )
533
- return - 1 ;
534
- if ( X > other . X )
535
- return 1 ;
536
- if ( Y < other . Y )
537
- return - 1 ;
538
- return Y > other . Y ? 1 : 0 ;
539
- }
540
-
541
- /// <summary>
542
- /// Compares this object with the specified object for order.
543
- /// Since Coordinates are 2.5D, this routine ignores the z value when making the comparison.
544
- /// Returns
545
- /// -1 : this.x lowerthan other.x || ((this.x == other.x) AND (this.y lowerthan other.y))
546
- /// 0 : this.x == other.x AND this.y = other.y
547
- /// 1 : this.x greaterthan other.x || ((this.x == other.x) AND (this.y greaterthan other.y))
548
- /// </summary>
549
- /// <param name="o"><c>Coordinate</c> with which this <c>Coordinate</c> is being compared.</param>
550
- /// <returns>
551
- /// A negative integer, zero, or a positive integer as this <c>Coordinate</c>
552
- /// is less than, equal to, or greater than the specified <c>Coordinate</c>.
553
- /// </returns>
554
- int IComparable . CompareTo ( object o )
555
- {
556
- var other = ( Coordinate ) o ;
557
- return CompareTo ( other ) ;
558
- }
559
-
560
- /// <summary>
561
- /// Returns <c>true</c> if <c>other</c> has the same values for x, y and z.
562
- /// </summary>
563
- /// <param name="other"><c>Coordinate</c> with which to do the 3D comparison.</param>
564
- /// <returns><c>true</c> if <c>other</c> is a <c>Coordinate</c> with the same values for x, y and z.</returns>
565
- [ Obsolete ]
566
- bool ICoordinate . Equals3D ( ICoordinate other )
567
- {
568
- return ( X == other . X ) && ( Y == other . Y ) &&
569
- ( ( Z == other . Z ) || ( Double . IsNaN ( Z ) && Double . IsNaN ( other . Z ) ) ) ;
570
- }
571
-
572
- /// <summary>
573
- /// Computes the 2-dimensional Euclidean distance to another location.
574
- /// The Z-ordinate is ignored.
575
- /// </summary>
576
- /// <param name="p"><c>Coordinate</c> with which to do the distance comparison.</param>
577
- /// <returns>the 2-dimensional Euclidean distance between the locations</returns>
578
- [ Obsolete ]
579
- double ICoordinate . Distance ( ICoordinate p )
580
- {
581
- var dx = X - p . X ;
582
- var dy = Y - p . Y ;
583
- return Math . Sqrt ( dx * dx + dy * dy ) ;
584
- }
585
-
586
- #endregion ICoordinate
587
-
588
384
/// <summary>
589
385
/// Implicit conversion operator to get a <see cref="CoordinateXY"/> from a <see cref="Coordinate"/>.
590
386
/// </summary>
0 commit comments