Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bobgroup-go-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bob Public Utils
bobgroup-go-utils
Commits
d2f49f14
Commit
d2f49f14
authored
1 year ago
by
Johan de Klerk
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' of gitlab.bob.co.za:bob-public-utils/bobgroup-go-utils
parents
876acf1a
38c71241
Loading
Loading
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
address_utils/address_utils.go
+4
-1
4 additions, 1 deletion
address_utils/address_utils.go
bob_box_utils/bob_box_utils.go
+39
-0
39 additions, 0 deletions
bob_box_utils/bob_box_utils.go
with
43 additions
and
1 deletion
address_utils/address_utils.go
+
4
−
1
View file @
d2f49f14
...
...
@@ -74,6 +74,7 @@ var Provinces = map[string]Province{
Names
:
[]
string
{
"NT"
,
"NL"
,
"ZN"
,
"KwaZulu-Natal"
,
"KwaZulu Natal"
,
"iKwaZulu-Natal"
,
...
...
@@ -240,9 +241,11 @@ func CleanZone(countryToClean, zoneToClean *string) (newCountry, newZone *string
for
provinceCode
,
province
:=
range
Provinces
{
for
_
,
name
:=
range
province
.
Names
{
if
zone
==
name
{
zone
=
string_utils
.
ReplaceCaseInsensitive
(
zone
,
name
,
provinceCode
)
}
}
}
newZone
=
&
zone
}
...
...
This diff is collapsed.
Click to expand it.
bob_box_utils/bob_box_utils.go
0 → 100644
+
39
−
0
View file @
d2f49f14
package
bob_box_utils
import
"sort"
type
ParcelDimensions
struct
{
Height
float64
`json:"height"`
Width
float64
`json:"width"`
Length
float64
`json:"length"`
}
// GetStackedParcelDimensions sorts the parcels so and stacks them
func
GetStackedParcelDimensions
(
parcels
[]
ParcelDimensions
)
ParcelDimensions
{
var
totalParcelHeight
,
maxParcelWidth
,
maxParcelLength
float64
// Stack the parcels
for
_
,
parcel
:=
range
parcels
{
parcelHeight
,
parcelWidth
,
parcelLength
:=
SortDimensionsInIncreasingOrder
(
parcel
.
Height
,
parcel
.
Width
,
parcel
.
Length
)
// To stack, sum all the heights
totalParcelHeight
+=
parcelHeight
// Get the max width
if
parcelWidth
>
maxParcelWidth
{
maxParcelWidth
=
parcelWidth
}
//Get the max length
if
parcelLength
>
maxParcelLength
{
maxParcelLength
=
parcelLength
}
}
return
ParcelDimensions
{
totalParcelHeight
,
maxParcelWidth
,
maxParcelLength
}
}
// SortDimensionsInIncreasingOrder sorts the given dimensions in increasing order
func
SortDimensionsInIncreasingOrder
(
dim1
,
dim2
,
dim3
float64
)
(
float64
,
float64
,
float64
)
{
dims
:=
[]
float64
{
dim1
,
dim2
,
dim3
}
sort
.
Float64s
(
dims
)
return
dims
[
0
],
dims
[
1
],
dims
[
2
]
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment