-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathBasicIsochrone.java
More file actions
74 lines (65 loc) · 2.56 KB
/
Copy pathBasicIsochrone.java
File metadata and controls
74 lines (65 loc) · 2.56 KB
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
package com.mapbox.samples;
import com.mapbox.api.isochrone.IsochroneCriteria;
import com.mapbox.api.isochrone.MapboxIsochrone;
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.FeatureCollection;
import com.mapbox.geojson.Point;
import com.mapbox.sample.BuildConfig;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class BasicIsochrone {
public static void main(String[] args) {
getStandardIsochroneCallBuilder(true).enqueueCall(new Callback<FeatureCollection>() {
@Override
public void onResponse(Call<FeatureCollection> call, Response<FeatureCollection> response) {
System.out.println("Total results: " + response.body().features().size());
for (Feature feature : response.body().features()) {
if (feature.properties().has("color")) {
System.out.println("" + feature.properties().get("color").getAsString());
} else {
System.out.println("Unnamed feature.");
}
}
makeNoPolygonCall();
}
@Override
public void onFailure(Call<FeatureCollection> call, Throwable t) {
System.out.println("Request failed: " + t.getMessage());
t.printStackTrace();
}
});
}
private static void makeNoPolygonCall() {
getStandardIsochroneCallBuilder(false).enqueueCall(new Callback<FeatureCollection>() {
@Override
public void onResponse(Call<FeatureCollection> call, Response<FeatureCollection> response) {
System.out.println("Total results for no polygon isochrone call: " + response.body().features().size());
for (Feature feature : response.body().features()) {
if (feature.properties().has("color")) {
System.out.println("" + feature.properties().get("color").getAsString());
} else {
System.out.println("Unnamed feature.");
}
}
}
@Override
public void onFailure(Call<FeatureCollection> call, Throwable t) {
System.out.println("Request failed: " + t.getMessage());
t.printStackTrace();
}
});
}
private static MapboxIsochrone getStandardIsochroneCallBuilder(boolean includePolygons) {
return MapboxIsochrone.builder()
.accessToken(BuildConfig.MAPBOX_ACCESS_TOKEN)
.profile(IsochroneCriteria.PROFILE_WALKING)
.addContoursMinutes(14, 35, 53)
.polygons(includePolygons)
.generalize(2f)
.denoise(.4f)
.addContoursColors("80f442", "403bd3", "bc404c")
.coordinates(Point.fromLngLat(-122.42901, 37.806332))
.build();
}
}