Documentation
¶
Index ¶
- Constants
- func Generate(length int) string
- type Coordinate
- func (c *Coordinate) CalGeoHash() string
- func (c *Coordinate) DistanceFrom(vo *Coordinate) float64
- func (c *Coordinate) Latitude() decimal.Decimal
- func (c *Coordinate) Longitude() decimal.Decimal
- func (c *Coordinate) MarshalJSON() ([]byte, error)
- func (c *Coordinate) UnmarshalJSON(bytes []byte) error
- type Password
Constants ¶
const EarthRadius float64 = 6378.137 * 1000
EarthRadius radius of Earth in meters (6378.137 km converted to meters)
const PI float64 = 3.141592653589793
PI mathematical constant for calculations
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Coordinate ¶
type Coordinate struct {
// contains filtered or unexported fields
}
Coordinate represents a geographic coordinate with latitude and longitude using decimal.Decimal for precise numeric representation
func NewCoordinate ¶
func NewCoordinate(latitude decimal.Decimal, longitude decimal.Decimal) *Coordinate
NewCoordinate creates a new Coordinate instance with given latitude and longitude
func NewCoordinateFromFloat64 ¶
func NewCoordinateFromFloat64(lat, lng float64) *Coordinate
NewCoordinateFromFloat64 creates a new Coordinate from latitude and longitude float64 values
func NewCoordinateFromGeoHash ¶
func NewCoordinateFromGeoHash(geoHash string) *Coordinate
NewCoordinateFromGeoHash creates a new Coordinate from a geohash string
func NewCoordinateFromString ¶
func NewCoordinateFromString(latitude string, longitude string) (*Coordinate, error)
NewCoordinateFromString creates a new Coordinate from latitude and longitude strings
func (*Coordinate) CalGeoHash ¶
func (c *Coordinate) CalGeoHash() string
CalGeoHash calculates and returns the geohash string for this coordinate
func (*Coordinate) DistanceFrom ¶
func (c *Coordinate) DistanceFrom(vo *Coordinate) float64
DistanceFrom calculates the distance between this coordinate and another coordinate using the Haversine formula, returns distance in meters
func (*Coordinate) Latitude ¶
func (c *Coordinate) Latitude() decimal.Decimal
Latitude returns the latitude of the coordinate
func (*Coordinate) Longitude ¶
func (c *Coordinate) Longitude() decimal.Decimal
Longitude returns the longitude of the coordinate
func (*Coordinate) MarshalJSON ¶
func (c *Coordinate) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for Coordinate
func (*Coordinate) UnmarshalJSON ¶
func (c *Coordinate) UnmarshalJSON(bytes []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for Coordinate
type Password ¶
type Password struct {
// contains filtered or unexported fields
}
func NewPassword ¶
func (Password) MarshalText ¶
MarshalText implement TextMarshaler
func (*Password) Scan ¶
Scan implement Scanner https://gorm.io/docs/data_types.html