forked from googlemaps/google-maps-services-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathElevationApiIntegrationTest.java
106 lines (89 loc) · 4.75 KB
/
ElevationApiIntegrationTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.google.maps;
import static com.google.maps.model.LatLngAssert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.google.maps.model.ElevationResult;
import com.google.maps.model.EncodedPolyline;
import com.google.maps.model.LatLng;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Category(LargeTests.class)
public class ElevationApiIntegrationTest extends AuthenticatedTest {
public static final double SYDNEY_ELEVATION = 19.11174774169922;
public static final double SYDNEY_POINT_ELEVATION = 19.10829925537109;
public static final double MELBOURNE_ELEVATION = 9.253130912780762;
private static final double EPSILON = .00001;
private static final LatLng SYDNEY = new LatLng(-33.867487, 151.206990);
private static final LatLng MELBOURNE = new LatLng(-37.814107, 144.963280);
private static final EncodedPolyline SYD_MELB_ROUTE = new EncodedPolyline(
"rvumEis{y[`NsfA~tAbF`bEj^h{@{KlfA~eA~`AbmEghAt~D|e@jlRpO~yH_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`H`wOtjGzeX"
+ "hhBlxErfCf{BtsCjpEjtD|}Aja@xnAbdDt|ErMrdFh{CzgAnlCnr@`wEM~mE`bA`uD|MlwKxmBvuFlhB|sN`_@fvB"
+ "p`CxhCt_@loDsS|eDlmChgFlqCbjCxk@vbGxmCjbMba@rpBaoClcCk_DhgEzYdzBl\\vsA_JfGztAbShkGtEhlDzh"
+ "C~w@hnB{e@yF}`D`_Ayx@~vGqn@l}CafC");
private GeoApiContext context;
public ElevationApiIntegrationTest(GeoApiContext context) {
this.context = context
.setQueryRateLimit(3)
.setConnectTimeout(1, TimeUnit.SECONDS)
.setReadTimeout(1, TimeUnit.SECONDS)
.setWriteTimeout(1, TimeUnit.SECONDS);
}
@Test
public void testGetPoint() throws Exception {
ElevationResult result = ElevationApi.getByPoint(context, SYDNEY).await();
assertNotNull(result);
assertEquals(SYDNEY_POINT_ELEVATION, result.elevation, EPSILON);
}
@Test
public void testGetPoints() throws Exception {
ElevationResult[] results = ElevationApi.getByPoints(context, SYDNEY, MELBOURNE).await();
assertNotNull(results);
assertEquals(2, results.length);
assertEquals(SYDNEY_ELEVATION, results[0].elevation, EPSILON);
assertEquals(MELBOURNE_ELEVATION, results[1].elevation, EPSILON);
}
@Test
public void testGetPath() throws Exception {
ElevationResult[] results = ElevationApi.getByPath(context, 10, SYDNEY, MELBOURNE).await();
assertNotNull(results);
assertEquals(10, results.length);
assertEquals(SYDNEY_ELEVATION, results[0].elevation, EPSILON);
assertEquals(MELBOURNE_ELEVATION, results[9].elevation, EPSILON);
}
@Test
public void testDirectionsAlongPath() throws Exception {
ElevationResult[] elevation = ElevationApi.getByPath(context, 100, SYD_MELB_ROUTE).await();
assertEquals(100, elevation.length);
List<LatLng> overviewPolylinePath = SYD_MELB_ROUTE.decodePath();
LatLng lastDirectionsPoint = overviewPolylinePath.get(overviewPolylinePath.size() - 1);
LatLng lastElevationPoint = elevation[elevation.length - 1].location;
assertEquals(lastDirectionsPoint, lastElevationPoint, EPSILON);
}
}