Commit 01796b96 authored by garciay's avatar garciay
Browse files

STF507: Implement missing methods such as f_isContinuousRectangularRegions() &...

STF507: Implement missing methods such as f_isContinuousRectangularRegions() & f_isRectangularRegionsInside()
parent 0589813c
......@@ -1523,7 +1523,7 @@ module LibItsSecurity_Functions {
external function fx_isValidPolygonalRegion(in PolygonalRegion p_region) return boolean;
/**
* @desc Check if a polygonal regin is inside another one
* @desc Check if a polygonal region is inside another one
* @param p_parent The main polygonal region
* @param p_region The polygonal region to be included
* @return true on success, false otherwise
......@@ -1773,14 +1773,34 @@ module LibItsSecurity_Functions {
} // End of function f_isRectangularRegionsIntersected
function f_isContinuousRectangularRegions(
in template (value) RectangularRegions regions
in template (value) RectangularRegions p_region
) return boolean {
// TODO: call external function
var integer v_i, v_j;
var boolean v_found;
for (v_i := 0; v_i < lengthof(p_region); v_i := v_i + 1) {
var PolygonalRegion v_region_base;
f_convertRectangularRegionIntoPolygonalRegion(p_region[v_i], v_region_base);
v_found := false;
for (v_j := 0; v_j < lengthof(p_region); v_j := v_j + 1) {
if (v_j != v_i) {
var PolygonalRegion v_region;
f_convertRectangularRegionIntoPolygonalRegion(p_region[v_j], v_region);
if (f_isPolygonalRegionInside(v_region, v_region_base) == true) {
v_found := true;
}
}
} // End of 'for' statement
if (v_found == false) {
return false;
}
} // End of 'for' statement
return true;
} // End of function f_isRectangularRegionsIntersected
} // End of function f_isContinuousRectangularRegions
/**
* @desc Check if a polygonal regin is inside another one
* @desc Check if a polygonal region is inside another one
* @param p_parent The main polygonal region
* @param p_region The polygonal region to be included
* @return true on success, false otherwise
......@@ -1790,10 +1810,50 @@ module LibItsSecurity_Functions {
in template (value) RectangularRegions p_parent,
in template (value) RectangularRegions p_region
) return boolean {
// TODO: convert rectangular regions to polygons and check polygons
return true;
var integer v_i, v_j;
for (v_i := 0; v_i < lengthof(p_parent); v_i := v_i + 1) {
var PolygonalRegion v_region_parent, v_region;
f_convertRectangularRegionIntoPolygonalRegion(p_parent[v_i], v_region_parent);
for (v_j := 0; v_j < lengthof(p_parent); v_j := v_j + 1) {
f_convertRectangularRegionIntoPolygonalRegion(p_region[v_j], v_region);
if (f_isPolygonalRegionInside(v_region, v_region_parent) == true) {
return true;
}
} // End of 'for' statement
} // End of 'for' statement
return false;
} // End of function f_isRectangularRegionsInside
/**
* @desc Convert a rectangular region into a polygonal region
* @param p_region The rectangular regions to convert
* @return
* @verdict
*/
function f_convertRectangularRegionIntoPolygonalRegion(
in template (value) RectangularRegion p_rectangular_region,
out PolygonalRegion p_region
) return boolean {
var integer v_counter := 0;
// Convert rectangular regions to polygons and check polygons
p_region[0] := p_rectangular_region.northwest;
p_region[1] := {
p_rectangular_region.northwest.latitude + p_rectangular_region.southeast.latitude,
p_rectangular_region.northwest.longitude
};
p_region[2] := p_rectangular_region.southeast;
p_region[3] := {
p_rectangular_region.northwest.latitude,
p_rectangular_region.northwest.longitude + p_rectangular_region.southeast.longitude
};
log("f_convertRectangularRegionIntoPolygonalRegion: DEBUG: Northwest location is invalid in rect ", p_region);
return true;
} // End of function
/**
* @desc Check that given polygon doesn't have neither self-intersections nor holes.
* @param p_region Polygonal Region
......@@ -1812,7 +1872,7 @@ module LibItsSecurity_Functions {
} // End of function f_isValidPolygonalRegion
/**
* @desc Check if a polygonal regin is inside another one
* @desc Check if a polygonal region is inside another one
* @param p_parent The main polygonal region
* @param p_region The polygonal region to be included
* @return true on success, false otherwise
......@@ -2031,3 +2091,4 @@ module LibItsSecurity_Functions {
} // End of group geometryFunctions
} // End of module LibItsSecurity_Functions
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment