I'm making a call to the Mapbox Isochrone API to obtain a FeatureCollection with this code:
string getIso = lng.ToString() + ","
+ lat.ToString()
+ "?contours_minutes=" + minutes.ToString()
+ "&polygons=true"
+ "&denoise=" + denoiseValue.ToString()
+ "&generalize=" + generalizeValue.ToString()
+ "&access_token=" + _appSettings.MapboxAccessToken;
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(drivetimeURL);
HttpResponseMessage response = client.GetAsync(getIso).Result;
FeatureCollection dtPolygon = await response.Content.ReadFromJsonAsync<FeatureCollection>();
I'm trying to get the data as a FeatureCollection type using the GeoJson.Net library, but when I run the code, all I get is basically an empty object:
{
"type": 8,
"features": [],
"boundingBoxes": null,
"crs": null
}
If I run this:
https://api.mapbox.com/isochrone/v1/mapbox/driving/-118.22258,33.99038?contours_minutes=10&polygons=true&denoise=1&generalize=1&access_token=XXXXXXXXXXXXXX
here's what I get and this is what I need in an object (coordinates mostly removed):
{
"features": [
{
"properties": {
"fill": "#bf4040",
"fillOpacity": 0.33,
"fill-opacity": 0.33,
"fillColor": "#bf4040",
"color": "#bf4040",
"contour": 10,
"opacity": 0.33,
"metric": "time"
},
"geometry": {
"coordinates": [
[
[
-118.21958,
34.026152
],
[
-118.220031,
34.025831
],
[
-118.22058,
34.025474
]
]
],
"type": "Polygon"
},
"type": "Feature"
}
],
"type": "FeatureCollection"
}
I suspect that I'm not completely understanding how GEOJson works and that I may have to manipulate the response from Mapbox to get it into a type that has the details. Or do I need to create a custom class/model that mimics the Mapbox response?