package geo

import (
	
)

type Route []*Point

func ( Route) () float64 {
	 := 0.
	for  := 0;  < len()-1; ++ {
		 += EuclideanDistance(
			[].X, [].Y,
			[+1].X, [+1].Y,
		)
	}
	return 
}

// return the point at _distance_ along the route, and the index of the segment it's on
func ( Route) ( float64) (*Point, int) {
	 := 
	var ,  *Point
	var  float64
	for  := 0;  < len()-1; ++ {
		,  = [], [+1]
		 = EuclideanDistance(.X, .Y, .X, .Y)

		if  <=  {
			 :=  / 
			// point t% of the way between curr and next
			return .Interpolate(, ), 
		}
		 -= 
	}

	// distance > length, so continue with last segment
	// Note: distance < 0 handled above with first segment
	return .Interpolate(, 1+/), len() - 2
}

func ( Route) () (,  *Point) {
	 := math.Inf(1)
	 := math.Inf(1)
	 := math.Inf(-1)
	 := math.Inf(-1)

	for ,  := range  {
		if .X <  {
			 = .X
		}
		if .X >  {
			 = .X
		}
		if .Y <  {
			 = .Y
		}
		if .Y >  {
			 = .Y
		}
	}
	return NewPoint(, ), NewPoint(, )
}