Documentation
¶
Index ¶
- Constants
- Variables
- func DecimalToFixed(num float64, precision int) float64
- func DecodeB64ToJPGBytes(b64 string) ([]byte, error)
- func DialRPC(network, address string) (*rpc.Client, error)
- func Interrupted() <-chan os.Signal
- func ReflectFunctionName(i interface{}) string
- func Round(num float64) int
- func SegmentsIntersect(segA, segB orb.LineString) (intersect bool, x, y *float64)
- func SlogResetLevel(level slog.Level) (reset func())
- type RPCArgNone
- type RingBuffer
- func (rb *RingBuffer[T]) Add(value T)
- func (rb *RingBuffer[T]) First() T
- func (rb *RingBuffer[T]) Get() []T
- func (rb *RingBuffer[T]) Head(n int) []T
- func (rb *RingBuffer[T]) Last() T
- func (rb *RingBuffer[T]) Len() int
- func (rb *RingBuffer[T]) Scan(fn func(T) bool)
- func (rb *RingBuffer[T]) Tail(n int) []T
- type SlippyZoomLevelT
- type SortingRingBuffer
- func (rb *SortingRingBuffer[T]) Add(value T)
- func (rb *SortingRingBuffer[T]) First() T
- func (rb *SortingRingBuffer[T]) Get() []T
- func (rb *SortingRingBuffer[T]) IsSorted() bool
- func (rb *SortingRingBuffer[T]) Last() T
- func (rb *SortingRingBuffer[T]) Len() int
- func (rb *SortingRingBuffer[T]) Scan(fn func(T) bool)
- func (rb *SortingRingBuffer[T]) Sort()
Constants ¶
const ( // GPSPrecision0 is the precision for country or large region GPSPrecision0 = 0 // GPSPrecision1 is the precision for large city or district GPSPrecision1 = 1 // GPSPrecision2 is the precision for town or village GPSPrecision2 = 2 // GPSPrecision3 is the precision for neighborhood, street GPSPrecision3 = 3 // GPSPrecision4 is the precision for individual street, large buildings GPSPrecision4 = 4 // GPSPrecision5 is the precision for individual trees, houses GPSPrecision5 = 5 // GPSPrecision6 is the precision for individual cats GPSPrecision6 = 6 // GPSPrecision7 is the precision for practical limit of commercial surveying GPSPrecision7 = 7 // GPSPrecision8 is the precision for specialized surveying GPSPrecision8 = 8 )
const ElevationCommercialFlightCruising = 10668.0
const ElevationOfDeadSea = -430.0
const ElevationOfEverest = 8848.0
const ElevationOfTroposphere = 11000.0
const SpeedOfCommercialFlight = 250.0 // or 900 km/h
const SpeedOfCyclingMax = 11.76 // or 42 km/h or 26 mph
const SpeedOfCyclingMin = SpeedOfRunningMin
const SpeedOfDrivingAutobahn = 67.06 // or 241 km/h or 150 mph
const SpeedOfDrivingCityUSMean = 13.9 // or 50 km/h or 31 mph
const SpeedOfDrivingFreeway = 33.33 // or 120 km/h or 75 mph
const SpeedOfDrivingHighway = 25.29 // or 91 km/h or 56 mph
const SpeedOfDrivingHighwayMin = 20.11 // or 72 km/h or 45 mph
const SpeedOfDrivingMin = 4.47 // or 16 km/h or 10 mph
const SpeedOfDrivingPrettyDamnFast = 44.7 // or 161 km/h or 100 mph
const SpeedOfFlyingSlow = 55.56 // or 200 km/h or 124 mph
const SpeedOfRunningMax = 5.56 // or 20 km/h or 12 mph
const SpeedOfRunningMin = 2.23 // or 8 km/h or 5 mph
const SpeedOfSound = 343.0
const SpeedOfWalkingMax = 1.78 // or 6.4 km/h or 4 mph
const SpeedOfWalkingMean = 1.2 // or 4.3 km/h or 2.7 mph
const SpeedOfWalkingMin = 0.23 // or 0.8 km/h or 0.5 mph
const SpeedOfWalkingSlow = 0.5 // or 1.8 km/h or 1.1 mph
Variables ¶
var ArgNone = &argNone
var SpeedOfCyclingMean = 5.36 // or 19.3 km/h or 12 mph
var SpeedOfRunningMean = 3.35 // or 12 km/h or 7.5 mph or 8min/mile
Functions ¶
func DecimalToFixed ¶
func DecodeB64ToJPGBytes ¶
func Interrupted ¶
func ReflectFunctionName ¶
func ReflectFunctionName(i interface{}) string
ReflectFunctionName returns the fully-qualifed name of a function. eg. "github.com/rotblauer/geom.(*Polygon).Area" eg. "github.com/rotblauer/geom.(*Polygon).Length" eg. "github.com/sams96/rgeo.Countries110
func SegmentsIntersect ¶
func SegmentsIntersect(segA, segB orb.LineString) (intersect bool, x, y *float64)
SegmentsIntersect returns true if the two line segments intersect and the intersection point, otherwise false and nils. The intersection point is considered exclusive of the endpoints of the segments; continuous segments are not considered to intersect.
https://stackoverflow.com/a/1968345 // Returns 1 if the lines intersect, otherwise 0. In addition, if the lines // intersect the intersection point may be stored in the floats i_x and i_y. char get_line_intersection(float p0_x, float p0_y, float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, float *i_x, float *i_y) { float s1_x, s1_y, s2_x, s2_y; s1_x = p1_x - p0_x; s1_y = p1_y - p0_y; s2_x = p3_x - p2_x; s2_y = p3_y - p2_y; float s, t; s = (-s1_y * (p0_x - p2_x) + s1_x * (p0_y - p2_y)) / (-s2_x * s1_y + s1_x * s2_y); t = ( s2_x * (p0_y - p2_y) - s2_y * (p0_x - p2_x)) / (-s2_x * s1_y + s1_x * s2_y); if (s >= 0 && s <= 1 && t >= 0 && t <= 1) { // Collision detected if (i_x != NULL) *i_x = p0_x + (t * s1_x); if (i_y != NULL) *i_y = p0_y + (t * s1_y); return 1; } return 0; // No collision }
func SlogResetLevel ¶
SlogTempLevel returns a function that resets the slog level to the previous level, pairs well with defer. Use like:
func Test123(t *testing.T) { defer common.SlogTempLevel(slog.Level(slog.LevelWarn + 1))()
Types ¶
type RPCArgNone ¶
type RPCArgNone *int
type RingBuffer ¶
type RingBuffer[T any] struct { // contains filtered or unexported fields }
RingBuffer from https://medium.com/@nathanbcrocker/a-practical-guide-to-implementing-a-generic-ring-buffer-in-go-866d27ec1a05. Have added a few things. I'm to blame for SortingRingBuffer.
func NewRingBuffer ¶
func NewRingBuffer[T any](size int) *RingBuffer[T]
NewRingBuffer creates a new ring buffer with a fixed size.
func (*RingBuffer[T]) Add ¶
func (rb *RingBuffer[T]) Add(value T)
Add inserts a new element into the buffer, overwriting the oldest if full.
func (*RingBuffer[T]) First ¶
func (rb *RingBuffer[T]) First() T
func (*RingBuffer[T]) Get ¶
func (rb *RingBuffer[T]) Get() []T
Get returns the contents of the buffer in FIFO order.
func (*RingBuffer[T]) Head ¶
func (rb *RingBuffer[T]) Head(n int) []T
Head returns the first (first in) n elements in the buffer.
func (*RingBuffer[T]) Last ¶
func (rb *RingBuffer[T]) Last() T
func (*RingBuffer[T]) Len ¶
func (rb *RingBuffer[T]) Len() int
Len returns the current number of elements in the buffer.
func (*RingBuffer[T]) Scan ¶
func (rb *RingBuffer[T]) Scan(fn func(T) bool)
func (*RingBuffer[T]) Tail ¶
func (rb *RingBuffer[T]) Tail(n int) []T
Tail returns the last (last in) n elements in the buffer.
type SlippyZoomLevelT ¶
type SlippyZoomLevelT int
var ( // SlippyZoomLevel0 represents, eg. the whole world SlippyZoomLevel0 SlippyZoomLevelT = 0 SlippyZoomLevel1 SlippyZoomLevelT = 1 // SlippyZoomLevel2 represents, eg. a subcontinental area SlippyZoomLevel2 SlippyZoomLevelT = 2 // SlippyZoomLevel3 represents, eg. the largest country SlippyZoomLevel3 SlippyZoomLevelT = 3 SlippyZoomLevel4 SlippyZoomLevelT = 4 // SlippyZoomLevel5 represents, eg. a large African country SlippyZoomLevel5 SlippyZoomLevelT = 5 // SlippyZoomLevel6 represents, eg. a large European country SlippyZoomLevel6 SlippyZoomLevelT = 6 // SlippyZoomLevel7 represents, eg. a small country, US state SlippyZoomLevel7 SlippyZoomLevelT = 7 SlippyZoomLevel8 SlippyZoomLevelT = 8 // SlippyZoomLevel9 represents, eg. a wide area, large metropolitan area SlippyZoomLevel9 SlippyZoomLevelT = 9 // SlippyZoomLevel10 represents, eg. a metropolitan area SlippyZoomLevel10 SlippyZoomLevelT = 10 // SlippyZoomLevel11 represents, eg. a city SlippyZoomLevel11 SlippyZoomLevelT = 11 // SlippyZoomLevel12 represents, eg. a town, or city district SlippyZoomLevel12 SlippyZoomLevelT = 12 // SlippyZoomLevel13 represents, eg. a village, or suburb SlippyZoomLevel13 SlippyZoomLevelT = 13 // SlippyZoomLevel14 is where houses start showing up on default maps SlippyZoomLevel14 SlippyZoomLevelT = 14 // SlippyZoomLevel15 represents, eg. a small road SlippyZoomLevel15 SlippyZoomLevelT = 15 // SlippyZoomLevel16 represents, eg. a street SlippyZoomLevel16 SlippyZoomLevelT = 16 // SlippyZoomLevel17 represents, eg. a block, park, addresses SlippyZoomLevel17 SlippyZoomLevelT = 17 // SlippyZoomLevel18 represents, eg. some buildings, trees SlippyZoomLevel18 SlippyZoomLevelT = 18 // SlippyZoomLevel19 represents, eg. local highway and crossing details SlippyZoomLevel19 SlippyZoomLevelT = 19 // SlippyZoomLevel20 represents, eg. a mid-sized building SlippyZoomLevel20 SlippyZoomLevelT = 20 )
type SortingRingBuffer ¶
type SortingRingBuffer[T any] struct { *RingBuffer[T] // contains filtered or unexported fields }
func NewSortingRingBuffer ¶
func NewSortingRingBuffer[T any](size int, less func(T, T) bool) *SortingRingBuffer[T]
func (*SortingRingBuffer[T]) Add ¶
func (rb *SortingRingBuffer[T]) Add(value T)
func (*SortingRingBuffer[T]) First ¶
func (rb *SortingRingBuffer[T]) First() T
func (*SortingRingBuffer[T]) Get ¶
func (rb *SortingRingBuffer[T]) Get() []T
func (*SortingRingBuffer[T]) IsSorted ¶
func (rb *SortingRingBuffer[T]) IsSorted() bool
func (*SortingRingBuffer[T]) Last ¶
func (rb *SortingRingBuffer[T]) Last() T
func (*SortingRingBuffer[T]) Len ¶
func (rb *SortingRingBuffer[T]) Len() int
func (*SortingRingBuffer[T]) Scan ¶
func (rb *SortingRingBuffer[T]) Scan(fn func(T) bool)
func (*SortingRingBuffer[T]) Sort ¶
func (rb *SortingRingBuffer[T]) Sort()