I have a map which is implemented using Openlayers 4. It loads a GeoJSON vector which defines the boundaries of a particular country. The user is allowed to draw and edit polygons to define subregions of this countries which will be saved to DB as GeoJSON data. I need to check if the polygon drawn by the user is completly within the boundaries of the country. How can i achieve this. I am adding the code snippet where i capture the subregion layer polygon drawn by the user here.
feature.on('change', function(event) {
var format = new ol.format.GeoJSON({featureProjection: 'EPSG:3857'});
var subregion_features = format.writeFeatures(vector.getSource().getFeatures());
//code to check if the newly drawn polygon is inside the master layer (whole country layer)
});