1 package com.android.healthconnect.testapps.toolbox.data
2 
3 import android.health.connect.datatypes.ExerciseRoute
4 import android.health.connect.datatypes.ExerciseRoute.Location
5 import java.time.Instant
6 
7 class ExerciseRoutesTestData {
8 
9     data class ExerciseRouteLocationData(
10         val secondsToAdd: Int,
11         val latitude: Double,
12         val longitude: Double,
13     )
14 
15     companion object {
16 
17         // https://screenshot.googleplex.com/9MRH639gSzFpgzY
18         val WARSAW_ROUTE =
19             listOf(
20                 ExerciseRouteLocationData(12, 52.26019, 21.02268),
21                 ExerciseRouteLocationData(40, 52.26000, 21.02360),
22                 ExerciseRouteLocationData(48, 52.25973, 21.02356),
23                 ExerciseRouteLocationData(60, 52.25966, 21.02313),
24                 ExerciseRouteLocationData(78, 52.25993, 21.02309),
25                 ExerciseRouteLocationData(79, 52.25972, 21.02271),
26                 ExerciseRouteLocationData(90, 52.25948, 21.02276),
27                 ExerciseRouteLocationData(93, 52.25945, 21.02335),
28                 ExerciseRouteLocationData(94, 52.25960, 21.02338),
29                 ExerciseRouteLocationData(100, 52.25961, 21.02382),
30                 ExerciseRouteLocationData(102, 52.25954, 21.02370),
31                 ExerciseRouteLocationData(105, 52.25945, 21.02362),
32                 ExerciseRouteLocationData(109, 52.25954, 21.02354),
33             )
34 
35         // https://screenshot.googleplex.com/7yVxQfJaETZcFPS
36         private val LONDON_ROUTE =
37             listOf(
38                 ExerciseRouteLocationData(0, 51.53312, -0.15512),
39                 ExerciseRouteLocationData(12, 51.53301, -0.15566),
40                 ExerciseRouteLocationData(40, 51.53269, -0.15578),
41                 ExerciseRouteLocationData(48, 51.53279, -0.15529),
42                 ExerciseRouteLocationData(60, 51.53246, -0.15577),
43                 ExerciseRouteLocationData(78, 51.53236, -0.15500),
44                 ExerciseRouteLocationData(79, 51.53268, -0.15457),
45                 ExerciseRouteLocationData(93, 51.53244, -0.15410),
46                 ExerciseRouteLocationData(94, 51.53277, -0.15391),
47                 ExerciseRouteLocationData(100, 51.53297, -0.15242),
48                 ExerciseRouteLocationData(102, 51.53299, -0.15472),
49                 ExerciseRouteLocationData(105, 51.53319, -0.15467),
50                 ExerciseRouteLocationData(109, 51.53308, -0.15508),
51             )
52 
53         // https://screenshot.googleplex.com/ARzR6WNvkNct4Pt
54         private val KOSCIUSZKO_ROUTE =
55             listOf(
56                 ExerciseRouteLocationData(0, -36.46687, 148.25588),
57                 ExerciseRouteLocationData(12, -36.46699, 148.25730),
58                 ExerciseRouteLocationData(40, -36.46643, 148.25841),
59                 ExerciseRouteLocationData(48, -36.46558, 148.25732),
60                 ExerciseRouteLocationData(60, -36.46552, 148.25474),
61                 ExerciseRouteLocationData(78, -36.46681, 148.25378),
62                 ExerciseRouteLocationData(79, -36.46670, 148.25221),
63                 ExerciseRouteLocationData(93, -36.46834, 148.25089),
64                 ExerciseRouteLocationData(94, -36.46964, 148.25051),
65                 ExerciseRouteLocationData(100, -36.47003, 148.25401),
66                 ExerciseRouteLocationData(102, -36.46979, 148.25579),
67                 ExerciseRouteLocationData(105, -36.46852, 148.25638),
68                 ExerciseRouteLocationData(109, -36.46864, 148.25299),
69                 ExerciseRouteLocationData(111, -36.46799, 148.25247),
70                 ExerciseRouteLocationData(112, -36.46708, 148.25461),
71             )
72 
73         // https://screenshot.googleplex.com/9WLjATYv4z4YteD
74         private val CHUKOTKA_ROUTE =
75             listOf(
76                 ExerciseRouteLocationData(0, 67.13740, -179.9200),
77                 ExerciseRouteLocationData(12, 67.13695, -179.95765),
78                 ExerciseRouteLocationData(40, 67.15066, -179.94647),
79                 ExerciseRouteLocationData(48, 67.15236, 179.96876),
80                 ExerciseRouteLocationData(60, 67.13841, 179.95380),
81                 ExerciseRouteLocationData(78, 67.11923, -179.97705),
82                 ExerciseRouteLocationData(79, 67.11876, -179.87888),
83                 ExerciseRouteLocationData(93, 67.12671, -179.80387),
84             )
85 
86         // https://screenshot.googleplex.com/7cNkdqkF2arM926
87         private val ANTARCTICA_ROUTE =
88             listOf(
89                 ExerciseRouteLocationData(0, -81.45264, 57.52812),
90                 ExerciseRouteLocationData(12, -81.46467, 57.65451),
91                 ExerciseRouteLocationData(40, -81.47302, 57.56526),
92                 ExerciseRouteLocationData(48, -81.48638, 57.61308),
93                 ExerciseRouteLocationData(60, -81.49360, 57.28638),
94                 ExerciseRouteLocationData(78, -81.51240, 57.11263),
95                 ExerciseRouteLocationData(79, -81.51401, 56.88966),
96                 ExerciseRouteLocationData(93, -81.50867, 56.70117),
97                 ExerciseRouteLocationData(94, -81.53209, 56.56434),
98                 ExerciseRouteLocationData(100, -81.54088, 56.80689),
99                 ExerciseRouteLocationData(102, -81.54123, 56.80921),
100                 ExerciseRouteLocationData(105, -81.56274, 56.90045),
101                 ExerciseRouteLocationData(109, -81.57542, 56.83663),
102                 ExerciseRouteLocationData(111, -81.61755, 55.72278),
103                 ExerciseRouteLocationData(112, -81.61605, 55.50406),
104             )
105 
106         private val NOT_RECTANGLE_ROUTE =
107             listOf(
108                 ExerciseRouteLocationData(0, 80.0, 0.0),
109                 ExerciseRouteLocationData(12, 88.0, 1.0),
110                 ExerciseRouteLocationData(40, 89.0, 1.0),
111                 ExerciseRouteLocationData(48, 89.0, 0.0),
112             )
113 
114         val routeDataMap: Map<String, List<ExerciseRouteLocationData>> =
115             hashMapOf(
116                 "Warsaw" to WARSAW_ROUTE,
117                 "London" to LONDON_ROUTE,
118                 "Kosciuszko" to KOSCIUSZKO_ROUTE,
119                 "Chukota" to CHUKOTKA_ROUTE,
120                 "Antarctica" to ANTARCTICA_ROUTE,
121                 "Not rectangle" to NOT_RECTANGLE_ROUTE)
122 
generateExerciseRouteFromLocationsnull123         fun generateExerciseRouteFromLocations(
124             locationsData: List<ExerciseRouteLocationData>,
125             start: Long,
126         ): ExerciseRoute {
127             val locations: ArrayList<Location> = ArrayList()
128             for (locationsDatum in locationsData) {
129                 locations.add(
130                     Location.Builder(
131                             Instant.ofEpochMilli(start + locationsDatum.secondsToAdd),
132                             locationsDatum.latitude,
133                             locationsDatum.longitude)
134                         .build())
135             }
136             return ExerciseRoute(locations)
137         }
138     }
139 }
140