-
Notifications
You must be signed in to change notification settings - Fork 13
/
geocoding.go
41 lines (31 loc) · 998 Bytes
/
geocoding.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package mocks
import (
"context"
"fmt"
"strconv"
"strings"
"github.com/latolukasz/beeorm"
"github.com/stretchr/testify/mock"
"github.com/coretrix/hitrix/service/component/geocoding"
)
type FakeGeocoding struct {
mock.Mock
}
func (f *FakeGeocoding) Geocode(_ context.Context, _ *beeorm.Engine, address string, language geocoding.Language) (*geocoding.Address, error) {
args := f.Called(address, language)
return args.Get(0).(*geocoding.Address), args.Error(1)
}
func (f *FakeGeocoding) ReverseGeocode(
_ context.Context,
_ *beeorm.Engine,
latLng *geocoding.LatLng,
language geocoding.Language,
) (*geocoding.Address, error) {
args := f.Called(latLng, language)
return args.Get(0).(*geocoding.Address), args.Error(1)
}
func (f *FakeGeocoding) CutCoordinates(float float64, precision int) (float64, error) {
asString := fmt.Sprintf("%.8f", float)
asStringParts := strings.Split(asString, ".")
return strconv.ParseFloat(asString[0:len(asStringParts[0])+1+precision], 64)
}