Documentation
¶
Overview ¶
Package location provides value objects related to location information.
Index ¶
- type Coordinate
- func (v Coordinate) DistanceTo(other Coordinate) float64
- func (v Coordinate) Equals(other Coordinate) bool
- func (v Coordinate) Format(format string) string
- func (v Coordinate) IsEastOf(other Coordinate) bool
- func (v Coordinate) IsEmpty() bool
- func (v Coordinate) IsNorthOf(other Coordinate) bool
- func (v Coordinate) IsSouthOf(other Coordinate) bool
- func (v Coordinate) IsWestOf(other Coordinate) bool
- func (v Coordinate) Latitude() float64
- func (v Coordinate) Longitude() float64
- func (v Coordinate) MarshalJSON() ([]byte, error)
- func (v Coordinate) String() string
- func (v Coordinate) ToMap() map[string]interface{}
- func (v Coordinate) Validate() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Coordinate ¶
type Coordinate struct {
base.BaseStructValueObject
// contains filtered or unexported fields
}
Coordinate represents a geographic coordinate (latitude and longitude)
func NewCoordinate ¶
func NewCoordinate(latitude float64, longitude float64) (Coordinate, error)
NewCoordinate creates a new Coordinate with validation
func ParseCoordinate ¶
func ParseCoordinate(s string) (Coordinate, error)
ParseCoordinate creates a new Coordinate from a string in format "lat,lng"
func (Coordinate) DistanceTo ¶
func (v Coordinate) DistanceTo(other Coordinate) float64
DistanceTo calculates the distance to another coordinate in kilometers using the Haversine formula
func (Coordinate) Equals ¶
func (v Coordinate) Equals(other Coordinate) bool
Equals checks if two Coordinates are equal
func (Coordinate) Format ¶
func (v Coordinate) Format(format string) string
Format returns the coordinate in the specified format Format options: - "dms": Degrees, minutes, seconds (e.g., "41°24'12.2"N, 2°10'26.5"E") - "dm": Degrees and decimal minutes (e.g., "41°24.2033'N, 2°10.4417'E") - "dd": Decimal degrees (e.g., "41.40339, 2.17403")
func (Coordinate) IsEastOf ¶
func (v Coordinate) IsEastOf(other Coordinate) bool
IsEastOf checks if this coordinate is east of another coordinate
func (Coordinate) IsEmpty ¶
func (v Coordinate) IsEmpty() bool
IsEmpty checks if the Coordinate is empty (zero value)
func (Coordinate) IsNorthOf ¶
func (v Coordinate) IsNorthOf(other Coordinate) bool
IsNorthOf checks if this coordinate is north of another coordinate
func (Coordinate) IsSouthOf ¶
func (v Coordinate) IsSouthOf(other Coordinate) bool
IsSouthOf checks if this coordinate is south of another coordinate
func (Coordinate) IsWestOf ¶
func (v Coordinate) IsWestOf(other Coordinate) bool
IsWestOf checks if this coordinate is west of another coordinate
func (Coordinate) Latitude ¶
func (v Coordinate) Latitude() float64
Latitude returns the latitude value
func (Coordinate) Longitude ¶
func (v Coordinate) Longitude() float64
Longitude returns the longitude value
func (Coordinate) MarshalJSON ¶
func (v Coordinate) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface
func (Coordinate) String ¶
func (v Coordinate) String() string
String returns the string representation of the Coordinate
func (Coordinate) ToMap ¶
func (v Coordinate) ToMap() map[string]interface{}
ToMap converts the Coordinate to a map[string]interface{}
func (Coordinate) Validate ¶
func (v Coordinate) Validate() error
Validate checks if the Coordinate is valid