|
| 1 | +" |
| 2 | +A TGeoBoundingBoxTest is a test class for testing the behavior of TGeoBoundingBox |
| 3 | +" |
| 4 | +Class { |
| 5 | + #name : #GeoToolsBoundingBoxTest, |
| 6 | + #superclass : #TestCase, |
| 7 | + #instVars : [ |
| 8 | + 'boundingBox' |
| 9 | + ], |
| 10 | + #category : #'GeoTools-Tests-Coordinates' |
| 11 | +} |
| 12 | + |
| 13 | +{ #category : #running } |
| 14 | +GeoToolsBoundingBoxTest >> setUp [ |
| 15 | + |
| 16 | + super setUp. |
| 17 | + |
| 18 | + boundingBox := GeoToolsBoundingBox new |
| 19 | +] |
| 20 | + |
| 21 | +{ #category : #running } |
| 22 | +GeoToolsBoundingBoxTest >> setUpBottomCenterSmallBox [ |
| 23 | + |
| 24 | + boundingBox |
| 25 | + topLatitudeInDegrees: -1; |
| 26 | + rightLongitudeInDegrees: 1; |
| 27 | + bottomLatitudeInDegrees: -2; |
| 28 | + leftLongitudeInDegrees: -1 |
| 29 | +] |
| 30 | + |
| 31 | +{ #category : #running } |
| 32 | +GeoToolsBoundingBoxTest >> setUpBottomLeftSmallBox [ |
| 33 | + |
| 34 | + boundingBox |
| 35 | + topLatitudeInDegrees: -1; |
| 36 | + rightLongitudeInDegrees: -1; |
| 37 | + bottomLatitudeInDegrees: -2; |
| 38 | + leftLongitudeInDegrees: -2 |
| 39 | +] |
| 40 | + |
| 41 | +{ #category : #running } |
| 42 | +GeoToolsBoundingBoxTest >> setUpSmallBox [ |
| 43 | + |
| 44 | + boundingBox |
| 45 | + topLatitudeInDegrees: 1; |
| 46 | + rightLongitudeInDegrees: 1; |
| 47 | + bottomLatitudeInDegrees: -1; |
| 48 | + leftLongitudeInDegrees: -1 |
| 49 | +] |
| 50 | + |
| 51 | +{ #category : #running } |
| 52 | +GeoToolsBoundingBoxTest >> setUpTopCenterSmallBox [ |
| 53 | + |
| 54 | + boundingBox |
| 55 | + topLatitudeInDegrees: 2; |
| 56 | + rightLongitudeInDegrees: 1; |
| 57 | + bottomLatitudeInDegrees: 1; |
| 58 | + leftLongitudeInDegrees: -1 |
| 59 | +] |
| 60 | + |
| 61 | +{ #category : #running } |
| 62 | +GeoToolsBoundingBoxTest >> setUpTopRightSmallBox [ |
| 63 | + |
| 64 | + boundingBox |
| 65 | + topLatitudeInDegrees: 2; |
| 66 | + rightLongitudeInDegrees: 2; |
| 67 | + bottomLatitudeInDegrees: 1; |
| 68 | + leftLongitudeInDegrees: 1 |
| 69 | +] |
| 70 | + |
| 71 | +{ #category : #running } |
| 72 | +GeoToolsBoundingBoxTest >> setUpZeroBox [ |
| 73 | + |
| 74 | + boundingBox |
| 75 | + topLatitudeInDegrees: 0; |
| 76 | + rightLongitudeInDegrees: 0; |
| 77 | + bottomLatitudeInDegrees: 0; |
| 78 | + leftLongitudeInDegrees: 0 |
| 79 | +] |
| 80 | + |
| 81 | +{ #category : #tests } |
| 82 | +GeoToolsBoundingBoxTest >> testBottomLatitudeInDegrees [ |
| 83 | + |
| 84 | + self assert: boundingBox bottomLatitudeInDegrees isNil. |
| 85 | + |
| 86 | + boundingBox bottomLatitudeInDegrees: -1. |
| 87 | + self assert: boundingBox bottomLatitudeInDegrees equals: -1. |
| 88 | +] |
| 89 | + |
| 90 | +{ #category : #tests } |
| 91 | +GeoToolsBoundingBoxTest >> testBottomLeftAbsoluteCoordinates [ |
| 92 | + |
| 93 | + self assert: boundingBox bottomLeftAbsoluteCoordinates isValid not. |
| 94 | + |
| 95 | + self setUpZeroBox. |
| 96 | + self assert: boundingBox bottomLeftAbsoluteCoordinates isValid. |
| 97 | + |
| 98 | + self setUpSmallBox. |
| 99 | + self assert: boundingBox bottomLeftAbsoluteCoordinates isValid. |
| 100 | + |
| 101 | + boundingBox bottomLeftAbsoluteCoordinates: AbsoluteCoordinates zero. |
| 102 | + self assert: boundingBox bottomLeftAbsoluteCoordinates isValid. |
| 103 | + self assert: boundingBox bottomLeftAbsoluteCoordinates isZero. |
| 104 | +] |
| 105 | + |
| 106 | +{ #category : #tests } |
| 107 | +GeoToolsBoundingBoxTest >> testBottomRightAbsoluteCoordinates [ |
| 108 | + |
| 109 | + self assert: boundingBox bottomRightAbsoluteCoordinates isValid not. |
| 110 | + |
| 111 | + self setUpZeroBox. |
| 112 | + self assert: boundingBox bottomRightAbsoluteCoordinates isValid. |
| 113 | + |
| 114 | + self setUpSmallBox. |
| 115 | + self assert: boundingBox bottomRightAbsoluteCoordinates isValid. |
| 116 | + |
| 117 | + boundingBox bottomRightAbsoluteCoordinates: AbsoluteCoordinates zero. |
| 118 | + self assert: boundingBox bottomRightAbsoluteCoordinates isValid. |
| 119 | + self assert: boundingBox bottomRightAbsoluteCoordinates isZero. |
| 120 | +] |
| 121 | + |
| 122 | +{ #category : #tests } |
| 123 | +GeoToolsBoundingBoxTest >> testCenterAbsoluteCoordinates [ |
| 124 | + |
| 125 | + self assert: boundingBox centerAbsoluteCoordinates isValid not. |
| 126 | + |
| 127 | + self setUpZeroBox. |
| 128 | + self assert: boundingBox centerAbsoluteCoordinates isValid. |
| 129 | + self assert: boundingBox centerAbsoluteCoordinates isZero. |
| 130 | + |
| 131 | + self setUpSmallBox. |
| 132 | + self assert: boundingBox centerAbsoluteCoordinates isValid. |
| 133 | + self assert: boundingBox centerAbsoluteCoordinates isZero. |
| 134 | + |
| 135 | + self setUpTopRightSmallBox. |
| 136 | + self assert: boundingBox centerAbsoluteCoordinates isValid. |
| 137 | + self assert: boundingBox centerAbsoluteCoordinates latitudeInDegrees equals: 1.5. |
| 138 | + self assert: boundingBox centerAbsoluteCoordinates longitudeInDegrees equals: 1.5. |
| 139 | + |
| 140 | + self setUpBottomLeftSmallBox. |
| 141 | + self assert: boundingBox centerAbsoluteCoordinates isValid. |
| 142 | + self assert: boundingBox centerAbsoluteCoordinates latitudeInDegrees equals: -1.5. |
| 143 | + self assert: boundingBox centerAbsoluteCoordinates longitudeInDegrees equals: -1.5. |
| 144 | + |
| 145 | + self setUpTopCenterSmallBox. |
| 146 | + self assert: boundingBox centerAbsoluteCoordinates isValid. |
| 147 | + self assert: boundingBox centerAbsoluteCoordinates latitudeInDegrees equals: 1.5. |
| 148 | + self assert: boundingBox centerAbsoluteCoordinates longitudeInDegrees equals: 0. |
| 149 | + |
| 150 | + self setUpBottomCenterSmallBox. |
| 151 | + self assert: boundingBox centerAbsoluteCoordinates isValid. |
| 152 | + self assert: boundingBox centerAbsoluteCoordinates latitudeInDegrees equals: -1.5. |
| 153 | + self assert: boundingBox centerAbsoluteCoordinates longitudeInDegrees equals: 0. |
| 154 | +] |
| 155 | + |
| 156 | +{ #category : #tests } |
| 157 | +GeoToolsBoundingBoxTest >> testLeftLongitudeInDegrees [ |
| 158 | + |
| 159 | + self assert: boundingBox leftLongitudeInDegrees isNil. |
| 160 | + |
| 161 | + boundingBox leftLongitudeInDegrees: 1. |
| 162 | + self assert: boundingBox leftLongitudeInDegrees equals: 1. |
| 163 | +] |
| 164 | + |
| 165 | +{ #category : #tests } |
| 166 | +GeoToolsBoundingBoxTest >> testMaxLatitudeInDegrees [ |
| 167 | + |
| 168 | + self assert: boundingBox maxLatitudeInDegrees isNil. |
| 169 | + |
| 170 | + self setUpZeroBox. |
| 171 | + self assert: boundingBox maxLatitudeInDegrees equals: 0. |
| 172 | + |
| 173 | + self setUpSmallBox. |
| 174 | + self assert: boundingBox maxLatitudeInDegrees equals: 1. |
| 175 | +] |
| 176 | + |
| 177 | +{ #category : #tests } |
| 178 | +GeoToolsBoundingBoxTest >> testMaxLongitudeInDegrees [ |
| 179 | + |
| 180 | + self assert: boundingBox maxLongitudeInDegrees isNil. |
| 181 | + |
| 182 | + self setUpZeroBox. |
| 183 | + self assert: boundingBox maxLongitudeInDegrees equals: 0. |
| 184 | + |
| 185 | + self setUpSmallBox. |
| 186 | + self assert: boundingBox maxLongitudeInDegrees equals: 1. |
| 187 | +] |
| 188 | + |
| 189 | +{ #category : #tests } |
| 190 | +GeoToolsBoundingBoxTest >> testMinLatitudeInDegrees [ |
| 191 | + |
| 192 | + self assert: boundingBox minLatitudeInDegrees isNil. |
| 193 | + |
| 194 | + self setUpZeroBox. |
| 195 | + self assert: boundingBox minLatitudeInDegrees equals: 0. |
| 196 | + |
| 197 | + self setUpSmallBox. |
| 198 | + self assert: boundingBox minLatitudeInDegrees equals: -1. |
| 199 | +] |
| 200 | + |
| 201 | +{ #category : #tests } |
| 202 | +GeoToolsBoundingBoxTest >> testMinLongitudeInDegrees [ |
| 203 | + |
| 204 | + self assert: boundingBox minLongitudeInDegrees isNil. |
| 205 | + |
| 206 | + self setUpZeroBox. |
| 207 | + self assert: boundingBox minLongitudeInDegrees equals: 0. |
| 208 | + |
| 209 | + self setUpSmallBox. |
| 210 | + self assert: boundingBox minLongitudeInDegrees equals: -1. |
| 211 | +] |
| 212 | + |
| 213 | +{ #category : #tests } |
| 214 | +GeoToolsBoundingBoxTest >> testOriginCorner [ |
| 215 | + |
| 216 | + | box | |
| 217 | + box := GeoToolsBoundingBox origin: AbsoluteCoordinates zero corner: AbsoluteCoordinates frParis. |
| 218 | + self assert: box centerAbsoluteCoordinates isValid. |
| 219 | +] |
| 220 | + |
| 221 | +{ #category : #tests } |
| 222 | +GeoToolsBoundingBoxTest >> testRightLongitudeInDegrees [ |
| 223 | + |
| 224 | + self assert: boundingBox rightLongitudeInDegrees isNil. |
| 225 | + |
| 226 | + boundingBox rightLongitudeInDegrees: 1. |
| 227 | + self assert: boundingBox rightLongitudeInDegrees equals: 1. |
| 228 | +] |
| 229 | + |
| 230 | +{ #category : #tests } |
| 231 | +GeoToolsBoundingBoxTest >> testTopLatitudeInDegrees [ |
| 232 | + |
| 233 | + self assert: boundingBox topLatitudeInDegrees isNil. |
| 234 | + |
| 235 | + boundingBox topLatitudeInDegrees: 1. |
| 236 | + self assert: boundingBox topLatitudeInDegrees equals: 1. |
| 237 | +] |
| 238 | + |
| 239 | +{ #category : #tests } |
| 240 | +GeoToolsBoundingBoxTest >> testTopLeftAbsoluteCoordinates [ |
| 241 | + |
| 242 | + self assert: boundingBox topLeftAbsoluteCoordinates isValid not. |
| 243 | + |
| 244 | + self setUpZeroBox. |
| 245 | + self assert: boundingBox topLeftAbsoluteCoordinates isValid. |
| 246 | + |
| 247 | + self setUpSmallBox. |
| 248 | + self assert: boundingBox topLeftAbsoluteCoordinates isValid. |
| 249 | + |
| 250 | + boundingBox topLeftAbsoluteCoordinates: AbsoluteCoordinates zero. |
| 251 | + self assert: boundingBox topLeftAbsoluteCoordinates isValid. |
| 252 | + self assert: boundingBox topLeftAbsoluteCoordinates isZero. |
| 253 | +] |
| 254 | + |
| 255 | +{ #category : #tests } |
| 256 | +GeoToolsBoundingBoxTest >> testTopLeftBottomRight [ |
| 257 | + |
| 258 | + | box | |
| 259 | + box := GeoToolsBoundingBox topLeft: AbsoluteCoordinates zero bottomRight: AbsoluteCoordinates frParis. |
| 260 | + self assert: box centerAbsoluteCoordinates isValid. |
| 261 | +] |
| 262 | + |
| 263 | +{ #category : #tests } |
| 264 | +GeoToolsBoundingBoxTest >> testTopRightAbsoluteCoordinates [ |
| 265 | + |
| 266 | + self assert: boundingBox topRightAbsoluteCoordinates isValid not. |
| 267 | + |
| 268 | + self setUpZeroBox. |
| 269 | + self assert: boundingBox topRightAbsoluteCoordinates isValid. |
| 270 | + |
| 271 | + self setUpSmallBox. |
| 272 | + self assert: boundingBox topRightAbsoluteCoordinates isValid. |
| 273 | + |
| 274 | + boundingBox topRightAbsoluteCoordinates: AbsoluteCoordinates zero. |
| 275 | + self assert: boundingBox topRightAbsoluteCoordinates isValid. |
| 276 | + self assert: boundingBox topRightAbsoluteCoordinates isZero. |
| 277 | +] |
0 commit comments