Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] don't fail on invalid inline GeoJSON data
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaefer committed Dec 12, 2015
1 parent b0bec13 commit c4a01d5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/mbgl/style/style_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,16 @@ bool StyleParser::parseGeoJSONSource(Source& source, const JSVal& sourceVal) {
} else if (dataVal.IsObject()) {
// We need to parse dataVal as a GeoJSON object
using namespace mapbox::geojsonvt;
source.info.geojsonvt = std::make_unique<GeoJSONVT>(Convert::convert(dataVal, 0));
try {
source.info.geojsonvt = std::make_unique<GeoJSONVT>(Convert::convert(dataVal, 0));
} catch (const std::exception& ex) {
Log::Error(Event::ParseStyle, "Failed to parse GeoJSON data: %s", ex.what());
// Create an empty GeoJSON VT object to make sure we're not infinitely waiting for
// tiles to load.
source.info.geojsonvt = std::make_unique<GeoJSONVT>(std::vector<ProjectedFeature>{});
}
} else {
Log::Warning(Event::ParseStyle, "GeoJSON data must be a URL or an object");
Log::Error(Event::ParseStyle, "GeoJSON data must be a URL or an object");
return false;
}

Expand Down

0 comments on commit c4a01d5

Please sign in to comment.