11using Newtonsoft . Json ;
2- using System ;
32
4- namespace Geocoding
3+ namespace Geocoding ;
4+
5+ /// <summary>
6+ /// Represents a rectangular viewport defined by southwest and northeast coordinates.
7+ /// </summary>
8+ public class Bounds
59{
10+ readonly Location southWest ;
11+ readonly Location northEast ;
12+
613 /// <summary>
7- /// Represents a rectangular viewport defined by southwest and northeast coordinates .
14+ /// Gets the southwest corner .
815 /// </summary>
9- public class Bounds
16+ public Location SouthWest
1017 {
11- readonly Location southWest ;
12- readonly Location northEast ;
13-
14- /// <summary>
15- /// Gets the southwest corner.
16- /// </summary>
17- public Location SouthWest
18- {
19- get { return southWest ; }
20- }
18+ get { return southWest ; }
19+ }
2120
22- /// <summary>
23- /// Gets the northeast corner.
24- /// </summary>
25- public Location NorthEast
26- {
27- get { return northEast ; }
28- }
21+ /// <summary>
22+ /// Gets the northeast corner.
23+ /// </summary>
24+ public Location NorthEast
25+ {
26+ get { return northEast ; }
27+ }
2928
30- /// <summary>
31- /// Initializes bounds from raw latitude and longitude values.
32- /// </summary>
33- /// <param name="southWestLatitude">The southwest latitude.</param>
34- /// <param name="southWestLongitude">The southwest longitude.</param>
35- /// <param name="northEastLatitude">The northeast latitude.</param>
36- /// <param name="northEastLongitude">The northeast longitude.</param>
37- public Bounds ( double southWestLatitude , double southWestLongitude , double northEastLatitude , double northEastLongitude )
38- : this ( new Location ( southWestLatitude , southWestLongitude ) , new Location ( northEastLatitude , northEastLongitude ) ) { }
29+ /// <summary>
30+ /// Initializes bounds from raw latitude and longitude values.
31+ /// </summary>
32+ /// <param name="southWestLatitude">The southwest latitude.</param>
33+ /// <param name="southWestLongitude">The southwest longitude.</param>
34+ /// <param name="northEastLatitude">The northeast latitude.</param>
35+ /// <param name="northEastLongitude">The northeast longitude.</param>
36+ public Bounds ( double southWestLatitude , double southWestLongitude , double northEastLatitude , double northEastLongitude )
37+ : this ( new Location ( southWestLatitude , southWestLongitude ) , new Location ( northEastLatitude , northEastLongitude ) ) { }
3938
40- /// <summary>
41- /// Initializes bounds from two corner locations.
42- /// </summary>
43- /// <param name="southWest">The southwest corner.</param>
44- /// <param name="northEast">The northeast corner.</param>
45- [ JsonConstructor ]
46- public Bounds ( Location southWest , Location northEast )
47- {
48- if ( southWest == null )
49- throw new ArgumentNullException ( "southWest" ) ;
39+ /// <summary>
40+ /// Initializes bounds from two corner locations.
41+ /// </summary>
42+ /// <param name="southWest">The southwest corner.</param>
43+ /// <param name="northEast">The northeast corner.</param>
44+ [ JsonConstructor ]
45+ public Bounds ( Location southWest , Location northEast )
46+ {
47+ if ( southWest == null )
48+ throw new ArgumentNullException ( "southWest" ) ;
5049
51- if ( northEast == null )
52- throw new ArgumentNullException ( "northEast" ) ;
50+ if ( northEast == null )
51+ throw new ArgumentNullException ( "northEast" ) ;
5352
54- if ( southWest . Latitude > northEast . Latitude )
55- throw new ArgumentException ( "southWest latitude cannot be greater than northEast latitude" ) ;
53+ if ( southWest . Latitude > northEast . Latitude )
54+ throw new ArgumentException ( "southWest latitude cannot be greater than northEast latitude" ) ;
5655
57- this . southWest = southWest ;
58- this . northEast = northEast ;
59- }
56+ this . southWest = southWest ;
57+ this . northEast = northEast ;
58+ }
6059
61- /// <summary>
62- /// Determines whether the specified object is equal to the current bounds.
63- /// </summary>
64- /// <param name="obj">The object to compare.</param>
65- /// <returns><c>true</c> when equal; otherwise <c>false</c>.</returns>
66- public override bool Equals ( object obj )
67- {
68- return Equals ( obj as Bounds ) ;
69- }
60+ /// <summary>
61+ /// Determines whether the specified object is equal to the current bounds.
62+ /// </summary>
63+ /// <param name="obj">The object to compare.</param>
64+ /// <returns><c>true</c> when equal; otherwise <c>false</c>.</returns>
65+ public override bool Equals ( object obj )
66+ {
67+ return Equals ( obj as Bounds ) ;
68+ }
7069
71- /// <summary>
72- /// Determines whether another bounds instance is equal to the current one.
73- /// </summary>
74- /// <param name="bounds">The other bounds instance.</param>
75- /// <returns><c>true</c> when equal; otherwise <c>false</c>.</returns>
76- public bool Equals ( Bounds bounds )
77- {
78- if ( bounds == null )
79- return false ;
70+ /// <summary>
71+ /// Determines whether another bounds instance is equal to the current one.
72+ /// </summary>
73+ /// <param name="bounds">The other bounds instance.</param>
74+ /// <returns><c>true</c> when equal; otherwise <c>false</c>.</returns>
75+ public bool Equals ( Bounds bounds )
76+ {
77+ if ( bounds == null )
78+ return false ;
8079
81- return ( this . SouthWest . Equals ( bounds . SouthWest ) && this . NorthEast . Equals ( bounds . NorthEast ) ) ;
82- }
80+ return ( this . SouthWest . Equals ( bounds . SouthWest ) && this . NorthEast . Equals ( bounds . NorthEast ) ) ;
81+ }
8382
84- /// <summary>
85- /// Returns a hash code for the current bounds.
86- /// </summary>
87- /// <returns>A hash code for the current bounds.</returns>
88- public override int GetHashCode ( )
89- {
90- return SouthWest . GetHashCode ( ) ^ NorthEast . GetHashCode ( ) ;
91- }
83+ /// <summary>
84+ /// Returns a hash code for the current bounds.
85+ /// </summary>
86+ /// <returns>A hash code for the current bounds.</returns>
87+ public override int GetHashCode ( )
88+ {
89+ return SouthWest . GetHashCode ( ) ^ NorthEast . GetHashCode ( ) ;
90+ }
9291
93- /// <summary>
94- /// Returns a string representation of the bounds.
95- /// </summary>
96- /// <returns>A string representation of the bounds.</returns>
97- public override string ToString ( )
98- {
99- return string . Format ( "{0} | {1}" , southWest , northEast ) ;
100- }
92+ /// <summary>
93+ /// Returns a string representation of the bounds.
94+ /// </summary>
95+ /// <returns>A string representation of the bounds.</returns>
96+ public override string ToString ( )
97+ {
98+ return string . Format ( "{0} | {1}" , southWest , northEast ) ;
10199 }
102- }
100+ }
0 commit comments