use of com.mapbox.common.TileRegionError in project maps by rnmapbox.
the class RCTMGLOfflineModule method convertRegionsToJSON.
private void convertRegionsToJSON(List<TileRegion> tileRegions, Promise promise) {
CountDownLatch countDownLatch = new CountDownLatch(tileRegions.size());
ArrayList<TileRegionError> errors = new ArrayList<>();
ArrayList<Geometry> geometries = new ArrayList<>();
try {
for (TileRegion region : tileRegions) {
getTileStore().getTileRegionGeometry(region.getId(), new TileRegionGeometryCallback() {
@Override
public void run(@NonNull Expected<TileRegionError, Geometry> result) {
if (result.isValue()) {
geometries.add(result.getValue());
} else {
errors.add(result.getError());
}
countDownLatch.countDown();
}
});
}
} catch (Error error) {
Logger.e("OS", "a");
}
try {
countDownLatch.await();
WritableArray result = Arguments.createArray();
for (Geometry geometry : geometries) {
result.pushMap(fromOfflineRegion(geometry));
}
for (TileRegionError error : errors) {
WritableMap errorMap = Arguments.createMap();
errorMap.putString("type", "error");
errorMap.putString("message", error.getMessage());
errorMap.putString("errorType", error.getType().toString());
result.pushMap(errorMap);
}
promise.resolve(result);
} catch (InterruptedException interruptedException) {
promise.reject(interruptedException);
}
}
Aggregations