Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/GeoTools-Tests/AbsoluteCoordinatesTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -271,21 +271,29 @@ AbsoluteCoordinatesTest >> testFromStringLatitudeLongitude [
]

{ #category : #tests }
AbsoluteCoordinatesTest >> testZero [
AbsoluteCoordinatesTest >> testIsLatLonZero [

| coord |
coord := AbsoluteCoordinates zero.
coord := AbsoluteCoordinates zeroLatLon.
self assert: coord latitudeInDegrees equals: 0.
self assert: coord longitudeInDegrees equals: 0.
self assert: coord altitudeInMeters equals: 0
self assert: coord altitudeInMeters isNil.
self assert: coord isLatLonZero.
self assert: coord isZero.

coord altitudeInMeters: 20.
self assert: coord isLatLonZero.
self deny: coord isZero.
]

{ #category : #tests }
AbsoluteCoordinatesTest >> testZeroLatLon [
AbsoluteCoordinatesTest >> testIsZero [

| coord |
coord := AbsoluteCoordinates zeroLatLon.
coord := AbsoluteCoordinates zero.
self assert: coord latitudeInDegrees equals: 0.
self assert: coord longitudeInDegrees equals: 0.
self assert: coord altitudeInMeters isNil
self assert: coord altitudeInMeters equals: 0.
self assert: coord isLatLonZero.
self assert: coord isZero.
]
277 changes: 277 additions & 0 deletions src/GeoTools-Tests/GeoToolsBoundingBoxTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
"
A TGeoBoundingBoxTest is a test class for testing the behavior of TGeoBoundingBox
"
Class {
#name : #GeoToolsBoundingBoxTest,
#superclass : #TestCase,
#instVars : [
'boundingBox'
],
#category : #'GeoTools-Tests-Coordinates'
}

{ #category : #running }
GeoToolsBoundingBoxTest >> setUp [

super setUp.

boundingBox := GeoToolsBoundingBox new
]

{ #category : #running }
GeoToolsBoundingBoxTest >> setUpBottomCenterSmallBox [

boundingBox
topLatitudeInDegrees: -1;
rightLongitudeInDegrees: 1;
bottomLatitudeInDegrees: -2;
leftLongitudeInDegrees: -1
]

{ #category : #running }
GeoToolsBoundingBoxTest >> setUpBottomLeftSmallBox [

boundingBox
topLatitudeInDegrees: -1;
rightLongitudeInDegrees: -1;
bottomLatitudeInDegrees: -2;
leftLongitudeInDegrees: -2
]

{ #category : #running }
GeoToolsBoundingBoxTest >> setUpSmallBox [

boundingBox
topLatitudeInDegrees: 1;
rightLongitudeInDegrees: 1;
bottomLatitudeInDegrees: -1;
leftLongitudeInDegrees: -1
]

{ #category : #running }
GeoToolsBoundingBoxTest >> setUpTopCenterSmallBox [

boundingBox
topLatitudeInDegrees: 2;
rightLongitudeInDegrees: 1;
bottomLatitudeInDegrees: 1;
leftLongitudeInDegrees: -1
]

{ #category : #running }
GeoToolsBoundingBoxTest >> setUpTopRightSmallBox [

boundingBox
topLatitudeInDegrees: 2;
rightLongitudeInDegrees: 2;
bottomLatitudeInDegrees: 1;
leftLongitudeInDegrees: 1
]

{ #category : #running }
GeoToolsBoundingBoxTest >> setUpZeroBox [

boundingBox
topLatitudeInDegrees: 0;
rightLongitudeInDegrees: 0;
bottomLatitudeInDegrees: 0;
leftLongitudeInDegrees: 0
]

{ #category : #tests }
GeoToolsBoundingBoxTest >> testBottomLatitudeInDegrees [

self assert: boundingBox bottomLatitudeInDegrees isNil.

boundingBox bottomLatitudeInDegrees: -1.
self assert: boundingBox bottomLatitudeInDegrees equals: -1.
]

{ #category : #tests }
GeoToolsBoundingBoxTest >> testBottomLeftAbsoluteCoordinates [

self assert: boundingBox bottomLeftAbsoluteCoordinates isValid not.

self setUpZeroBox.
self assert: boundingBox bottomLeftAbsoluteCoordinates isValid.

self setUpSmallBox.
self assert: boundingBox bottomLeftAbsoluteCoordinates isValid.

boundingBox bottomLeftAbsoluteCoordinates: AbsoluteCoordinates zero.
self assert: boundingBox bottomLeftAbsoluteCoordinates isValid.
self assert: boundingBox bottomLeftAbsoluteCoordinates isZero.
]

{ #category : #tests }
GeoToolsBoundingBoxTest >> testBottomRightAbsoluteCoordinates [

self assert: boundingBox bottomRightAbsoluteCoordinates isValid not.

self setUpZeroBox.
self assert: boundingBox bottomRightAbsoluteCoordinates isValid.

self setUpSmallBox.
self assert: boundingBox bottomRightAbsoluteCoordinates isValid.

boundingBox bottomRightAbsoluteCoordinates: AbsoluteCoordinates zero.
self assert: boundingBox bottomRightAbsoluteCoordinates isValid.
self assert: boundingBox bottomRightAbsoluteCoordinates isZero.
]

{ #category : #tests }
GeoToolsBoundingBoxTest >> testCenterAbsoluteCoordinates [

self assert: boundingBox centerAbsoluteCoordinates isValid not.

self setUpZeroBox.
self assert: boundingBox centerAbsoluteCoordinates isValid.
self assert: boundingBox centerAbsoluteCoordinates isZero.

self setUpSmallBox.
self assert: boundingBox centerAbsoluteCoordinates isValid.
self assert: boundingBox centerAbsoluteCoordinates isZero.

self setUpTopRightSmallBox.
self assert: boundingBox centerAbsoluteCoordinates isValid.
self assert: boundingBox centerAbsoluteCoordinates latitudeInDegrees equals: 1.5.
self assert: boundingBox centerAbsoluteCoordinates longitudeInDegrees equals: 1.5.

self setUpBottomLeftSmallBox.
self assert: boundingBox centerAbsoluteCoordinates isValid.
self assert: boundingBox centerAbsoluteCoordinates latitudeInDegrees equals: -1.5.
self assert: boundingBox centerAbsoluteCoordinates longitudeInDegrees equals: -1.5.

self setUpTopCenterSmallBox.
self assert: boundingBox centerAbsoluteCoordinates isValid.
self assert: boundingBox centerAbsoluteCoordinates latitudeInDegrees equals: 1.5.
self assert: boundingBox centerAbsoluteCoordinates longitudeInDegrees equals: 0.

self setUpBottomCenterSmallBox.
self assert: boundingBox centerAbsoluteCoordinates isValid.
self assert: boundingBox centerAbsoluteCoordinates latitudeInDegrees equals: -1.5.
self assert: boundingBox centerAbsoluteCoordinates longitudeInDegrees equals: 0.
]

{ #category : #tests }
GeoToolsBoundingBoxTest >> testLeftLongitudeInDegrees [

self assert: boundingBox leftLongitudeInDegrees isNil.

boundingBox leftLongitudeInDegrees: 1.
self assert: boundingBox leftLongitudeInDegrees equals: 1.
]

{ #category : #tests }
GeoToolsBoundingBoxTest >> testMaxLatitudeInDegrees [

self assert: boundingBox maxLatitudeInDegrees isNil.

self setUpZeroBox.
self assert: boundingBox maxLatitudeInDegrees equals: 0.

self setUpSmallBox.
self assert: boundingBox maxLatitudeInDegrees equals: 1.
]

{ #category : #tests }
GeoToolsBoundingBoxTest >> testMaxLongitudeInDegrees [

self assert: boundingBox maxLongitudeInDegrees isNil.

self setUpZeroBox.
self assert: boundingBox maxLongitudeInDegrees equals: 0.

self setUpSmallBox.
self assert: boundingBox maxLongitudeInDegrees equals: 1.
]

{ #category : #tests }
GeoToolsBoundingBoxTest >> testMinLatitudeInDegrees [

self assert: boundingBox minLatitudeInDegrees isNil.

self setUpZeroBox.
self assert: boundingBox minLatitudeInDegrees equals: 0.

self setUpSmallBox.
self assert: boundingBox minLatitudeInDegrees equals: -1.
]

{ #category : #tests }
GeoToolsBoundingBoxTest >> testMinLongitudeInDegrees [

self assert: boundingBox minLongitudeInDegrees isNil.

self setUpZeroBox.
self assert: boundingBox minLongitudeInDegrees equals: 0.

self setUpSmallBox.
self assert: boundingBox minLongitudeInDegrees equals: -1.
]

{ #category : #tests }
GeoToolsBoundingBoxTest >> testOriginCorner [

| box |
box := GeoToolsBoundingBox origin: AbsoluteCoordinates zero corner: AbsoluteCoordinates frParis.
self assert: box centerAbsoluteCoordinates isValid.
]

{ #category : #tests }
GeoToolsBoundingBoxTest >> testRightLongitudeInDegrees [

self assert: boundingBox rightLongitudeInDegrees isNil.

boundingBox rightLongitudeInDegrees: 1.
self assert: boundingBox rightLongitudeInDegrees equals: 1.
]

{ #category : #tests }
GeoToolsBoundingBoxTest >> testTopLatitudeInDegrees [

self assert: boundingBox topLatitudeInDegrees isNil.

boundingBox topLatitudeInDegrees: 1.
self assert: boundingBox topLatitudeInDegrees equals: 1.
]

{ #category : #tests }
GeoToolsBoundingBoxTest >> testTopLeftAbsoluteCoordinates [

self assert: boundingBox topLeftAbsoluteCoordinates isValid not.

self setUpZeroBox.
self assert: boundingBox topLeftAbsoluteCoordinates isValid.

self setUpSmallBox.
self assert: boundingBox topLeftAbsoluteCoordinates isValid.

boundingBox topLeftAbsoluteCoordinates: AbsoluteCoordinates zero.
self assert: boundingBox topLeftAbsoluteCoordinates isValid.
self assert: boundingBox topLeftAbsoluteCoordinates isZero.
]

{ #category : #tests }
GeoToolsBoundingBoxTest >> testTopLeftBottomRight [

| box |
box := GeoToolsBoundingBox topLeft: AbsoluteCoordinates zero bottomRight: AbsoluteCoordinates frParis.
self assert: box centerAbsoluteCoordinates isValid.
]

{ #category : #tests }
GeoToolsBoundingBoxTest >> testTopRightAbsoluteCoordinates [

self assert: boundingBox topRightAbsoluteCoordinates isValid not.

self setUpZeroBox.
self assert: boundingBox topRightAbsoluteCoordinates isValid.

self setUpSmallBox.
self assert: boundingBox topRightAbsoluteCoordinates isValid.

boundingBox topRightAbsoluteCoordinates: AbsoluteCoordinates zero.
self assert: boundingBox topRightAbsoluteCoordinates isValid.
self assert: boundingBox topRightAbsoluteCoordinates isZero.
]
13 changes: 13 additions & 0 deletions src/GeoTools/AbsoluteCoordinates.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -590,12 +590,25 @@ AbsoluteCoordinates >> isEmpty [
^ self latitudeInDegrees isNil and: [ self longitudeInDegrees isNil and: [ self altitudeInMeters isNil ] ]
]

{ #category : #testing }
AbsoluteCoordinates >> isLatLonZero [

^ self latitudeInDegrees = 0 and: [ self longitudeInDegrees = 0 ]
]

{ #category : #accessing }
AbsoluteCoordinates >> isValid [

^ self latitudeInDegrees notNil and: [ self longitudeInDegrees notNil ]
]

{ #category : #testing }
AbsoluteCoordinates >> isZero [

^ self isLatLonZero and: [
self altitudeInMeters = 0 or: [ self altitudeInMeters isNil ] ]
]

{ #category : #accessing }
AbsoluteCoordinates >> latitude [

Expand Down
7 changes: 7 additions & 0 deletions src/GeoTools/GeoToolsBoundingBox.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Class {
#name : #GeoToolsBoundingBox,
#superclass : #Object,
#traits : 'TGeoToolsBoundingBox',
#classTraits : 'TGeoToolsBoundingBox classTrait',
#category : #'GeoTools-Coordinates'
}
Loading