func TimeInRegion(locations Locations, filter config.Filter) []TimeEnterExit {
	var time_enter_exit []TimeEnterExit

	inregion := false
	fmt.Println(filter)
	var count int
	// Time goes backward in this struct
	for _, location := range locations.Locations {
		if InRegion(location, filter) {
			if inregion == false {
				time_enter_exit = append(time_enter_exit, TimeEnterExit{Exit: comparedates.ParseTimeNs(location.TimestampMs)})
				fmt.Printf("Exit %v \n", comparedates.ParseTimeNs(location.TimestampMs))
				fmt.Println(location)
			}
			count++
			inregion = true
		} else {
			if inregion == true {
				time_enter_exit[len(time_enter_exit)-1].Enter = comparedates.ParseTimeNs(location.TimestampMs)
				fmt.Printf("Enter %v \n", comparedates.ParseTimeNs(location.TimestampMs))
				fmt.Println(location)
				//time_enter_exit[len(time_enter_exit)-1].TimeDiff = comparedates.ParseTimeNs(location.TimestampMs) - time_enter_exit[len(time_enter_exit)-1].Enter
				count = 0
			}
			inregion = false
		}
	}
	fmt.Print(time_enter_exit)
	return time_enter_exit
}
func InRegion(location Location, filter config.Filter) bool {
	var beginTime = comparedates.ParseTimeStr(filter.Time.Min)
	var endTime = comparedates.ParseTimeStr(filter.Time.Max)

	/*fmt.Printf("BEGIN: %v", beginTime)
	fmt.Printf("END:   %v", endTime)
	*/

	var compareTime = false
	if filter.Time.Min != "" && filter.Time.Max != "" {
		compareTime = true
	}
	var timeStamp time.Time

	if location.LatitudeE7 < filter.Latitude.Min {
		return false
	}
	if location.LatitudeE7 > filter.Latitude.Max {
		return false
	}
	if location.LongitudeE7 < filter.Longitude.Min {
		return false
	}
	if location.LongitudeE7 > filter.Longitude.Max {
		return false
	}
	if compareTime {
		timeStamp = comparedates.ParseTimeNs(location.TimestampMs)
		if !comparedates.InTimespan(beginTime, endTime, timeStamp) {
			return false
		}
	}
	return true

}