Documentation
¶
Index ¶
- Constants
- func AddressSchema() schema.Element
- type Address
- func (address Address) GeoJSON() mapof.Any
- func (address Address) GeoPoint() Point
- func (address Address) GetFloat(name string) (float64, bool)
- func (address Address) GetString(name string) string
- func (address Address) GetStringOK(name string) (string, bool)
- func (address Address) HasAddress() bool
- func (address Address) HasGeocode() bool
- func (address Address) IsZero() bool
- func (address Address) JSONLD() mapof.Any
- func (address Address) LatLon() string
- func (address Address) LonLat() string
- func (address *Address) MarshalMap() mapof.Any
- func (address Address) NotZero() bool
- func (address *Address) Reset()
- func (address *Address) SetFloat(name string, value float64) bool
- func (address *Address) SetPoint(point Point)
- func (address *Address) SetString(name string, value string) bool
- func (address *Address) UnmarshalMap(value mapof.Any) error
- type GeoJSONPoint
- type GeoJSONPolygon
- type Point
- func (point Point) GeoJSON() map[string]any
- func (point Point) LatLon() string
- func (point Point) LonLat() string
- func (point Point) MarshalBSON() ([]byte, error)
- func (point Point) MarshalJSON() ([]byte, error)
- func (point Point) MarshalStruct() GeoJSONPoint
- func (point *Point) UnmarshalBSON(data []byte) error
- func (point *Point) UnmarshalJSON(data []byte) error
- func (point *Point) UnmarshalMap(data mapof.Any) error
- type Polygon
- func (polygon Polygon) GeoJSON() map[string]any
- func (polygon Polygon) IsZero() bool
- func (polygon Polygon) MarshalBSON() ([]byte, error)
- func (polygon Polygon) MarshalJSON() ([]byte, error)
- func (polygon Polygon) MarshalSlice() [][]float64
- func (polygon Polygon) MarshalStruct() GeoJSONPolygon
- func (polygon Polygon) NotZero() bool
- func (polygon Polygon) String() string
- func (polygon *Polygon) UnmarshalBSON(data []byte) error
- func (polygon *Polygon) UnmarshalJSON(data []byte) error
- func (polygon *Polygon) UnmarshalStruct(data GeoJSONPolygon) error
- type Position
- func (position Position) IsZero() bool
- func (position Position) MarshalBSON() ([]byte, error)
- func (position Position) MarshalJSON() ([]byte, error)
- func (position Position) MarshalSlice() []float64
- func (position Position) NotZero() bool
- func (position Position) String() string
- func (position *Position) UnmarshalBSON(data []byte) error
- func (position *Position) UnmarshalJSON(data []byte) error
- func (position *Position) UnmarshalSlice(coordinates sliceof.Float) error
Constants ¶
const AddressPropertyCountry = "country"
const AddressPropertyFormatted = "formatted"
const AddressPropertyLatitude = "latitude"
const AddressPropertyLocality = "locality"
const AddressPropertyLongitude = "longitude"
const AddressPropertyName = "name"
const AddressPropertyPlusCode = "pluscode"
const AddressPropertyPostalCode = "postalCode"
const AddressPropertyRegion = "region"
const AddressPropertyStreet1 = "street1"
const AddressPropertyStreet2 = "street2"
const AddressPropertyTimezone = "timezone"
const PropertyCoordinates = "coordinates"
const PropertyType = "type"
const PropertyTypePoint = "Point"
const PropertyTypePolygon = "Polygon"
Variables ¶
This section is empty.
Functions ¶
func AddressSchema ¶ added in v0.0.2
Types ¶
type Address ¶ added in v0.0.2
type Address struct {
Name string `json:"name" bson:"name,omitempty"` // Human-readable name of the address
Formatted string `json:"formatted" bson:"formatted,omitempty"` // Full, unparsed value of the address
Street1 string `json:"street1" bson:"street1,omitempty"` // Parsed street address line 1 of the address
Street2 string `json:"street2" bson:"street2,omitempty"` // Parsed street address line 2 of the address
Locality string `json:"locality" bson:"locality,omitempty"` // Parsed city or town of the address
Region string `json:"region" bson:"region,omitempty"` // Parsed state or province of the address
PostalCode string `json:"postalCode" bson:"postalCode,omitempty"` // Parsed postal code of the address
Country string `json:"country" bson:"country,omitempty"` // Parsed country of the address
PlusCode string `json:"plusCode" bson:"plusCode,omitempty"` // PlusCode for this location https://maps.google.com/pluscodes/
Timezone string `json:"timezone" bson:"timezone,omitempty"` // Time zone in tzdatabase format (https://en.wikipedia.org/wiki/Tz_database)
Latitude float64 `json:"latitude" bson:"latitude,omitempty"` // Latitude of the address
Longitude float64 `json:"longitude" bson:"longitude,omitempty"` // Longitude of the address
}
Address represents a physical address on the planet It maps to https://www.w3.org/TR/activitystreams-vocabulary/#dfn-address and uses https://schema.org/PostalAddress to match Mobilizion
func NewAddress ¶ added in v0.0.2
func NewAddress() Address
func (Address) GeoJSON ¶ added in v0.0.2
GeoJSON returns a GeoJSON object that matches the geo.GeoJSONer interface https://www.mongodb.com/docs/manual/reference/geojson/
func (Address) GetStringOK ¶ added in v0.0.2
func (Address) HasAddress ¶ added in v0.0.2
HasAddress returns TRUE if this Address has ANY street adsress information
func (Address) HasGeocode ¶ added in v0.0.2
HasGeocode returns TRUE if this Address has ANY Lat/Long information
func (*Address) MarshalMap ¶ added in v0.0.2
func (*Address) Reset ¶ added in v0.0.2
func (address *Address) Reset()
Reset clears all geocoding information from this Address
type GeoJSONPoint ¶
type GeoJSONPoint struct {
Type string `json:"type" bson:"type"` // This should always be "Point"
Coordinates []float64 `json:"coordinates" bson:"coordinates"` // Whatevs
}
GeoJSONPoint represents the "strict" format for a Point in GeoJSON
type GeoJSONPolygon ¶
type GeoJSONPolygon struct {
Type string `json:"type" bson:"type"` // this should always be "Polygon"
Coordinates [][][]float64 `json:"coordinates" bson:"coordinates"` // ick. Thanks IETF.
}
GeoJSONPolygon represents the "strict" format for a Polygon in GeoJSON. is is used here to simplify conversion to/from serialization formats
type Point ¶
type Point struct {
Position
}
Point represents a GeoJSON "Point" object https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.2
func NewPointWithAltitude ¶
func (Point) MarshalBSON ¶
MarshalBSON is a custom BSON marshaller that serializes this Position into a GeoJSON coordinate pair
func (Point) MarshalJSON ¶
MarshalJSON is a custom json.Marshaller that returns this Point as a GeoJSON object. This marshaller works with `omitzero` but not `omitempty`
func (Point) MarshalStruct ¶
func (point Point) MarshalStruct() GeoJSONPoint
func (*Point) UnmarshalBSON ¶
UnmarshalBSON is a custom BSON unmarshaller that deserializes a BSON / GeoJSON coordinate pair into this Position structure.
func (*Point) UnmarshalJSON ¶
UnmarshalJSON is a custom json.Unmarshaller that parses a GeoJSON object into this Point object.
type Polygon ¶
Polygon represents a GeoJSON "Polygon" object https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.2
func NewPolygon ¶
func NewPolygonFromString ¶
func (Polygon) MarshalBSON ¶
MarshalBSON is a custom BSON marshaller that serializes this Position into a GeoJSON coordinate pair
func (Polygon) MarshalJSON ¶
MarshalJSON is a custom json.Marshaller that returns this Polygon as a GeoJSON object.
func (Polygon) MarshalSlice ¶
MarshalSlice returns (a slice of (a slice of floats)), which is the standard way of representing a GeoJSON polygon
func (Polygon) MarshalStruct ¶
func (polygon Polygon) MarshalStruct() GeoJSONPolygon
MarshalMap copies this Polygon into a mapof.Any
func (*Polygon) UnmarshalBSON ¶
UnmarshalBSON is a custom BSON unmarshaller that deserializes a BSON / GeoJSON coordinate pair into this Position structure.
func (*Polygon) UnmarshalJSON ¶
UnmarshalJSON is a custom json.Unmarshaller that parses a GeoJSON object into this Polygon object.
func (*Polygon) UnmarshalStruct ¶
func (polygon *Polygon) UnmarshalStruct(data GeoJSONPolygon) error
type Position ¶
Position represents a Longitude/Latitude pair https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.1
func NewPosition ¶
func (Position) MarshalBSON ¶
MarshalBSON is a custom BSON marshaller that serializes this Position into a GeoJSON coordinate pair
func (Position) MarshalJSON ¶
MarshalJSON is a custom JBSON marshaller that serializes this Position into a GeoJSON coordinate pair
func (Position) MarshalSlice ¶
MarshalSlice returns a longitude/latitude coordinate pair
func (*Position) UnmarshalBSON ¶
UnmarshalBSON is a custom BSON unmarshaller that deserializes a BSON / GeoJSON coordinate pair into this Position structure.
func (*Position) UnmarshalJSON ¶
UnmarshalBSON is a custom BSON unmarshaller that deserializes a BSON / GeoJSON coordinate pair into this Position structure.