Commit 97a6d123 authored by garciay's avatar garciay
Browse files

Add support of geographical external functions

parent b76a4180
Loading
Loading
Loading
Loading
+67 −6
Original line number Diff line number Diff line
@@ -829,6 +829,17 @@ module LibItsSecurity_Functions {
             */
            external function fx_isLocationInsideIdentifiedRegion(in IdentifiedRegion p_region, in ThreeDLocation p_location) return boolean;
            
            /**
             * @desc Convert a spacial coordinate from DMS to Dms
             * @param p_degrees The degrees (D)
             * @param p_minutes The minutes (M)
             * @param p_seconds The seconds (S)
             * @param p_latlon  The latitude/longitude: (N|S|E|W)
             * @return The decimal coordinate on success, 0.0, otherwise
             * @verdict Unchanged
             */
            external function fx_dms2dd(in integer p_degrees, in integer p_minutes, in float p_seconds, in charstring p_latlon) return float;
            
        } // End of group geodesic
        
    } // End of group externalFunctions
@@ -913,8 +924,12 @@ module LibItsSecurity_Functions {
        function f_isPolygonalRegionInside(in template (value) PolygonalRegion p_parent,
                                           in template (value) PolygonalRegion p_region
        ) return boolean {
            // TODO: call external function
            return true;
            // Sanity check
            if (not isbound(p_parent) or not isbound(p_region) or (lengthof(p_parent) == 0) or (lengthof(p_region) == 0)) {
                return false;
            }
            
            return fx_isPolygonalRegionInside(valueof(p_parent), valueof(p_region));
        } // End of function f_isPolygonalRegionInside
        
        /**
@@ -923,7 +938,6 @@ module LibItsSecurity_Functions {
        function f_isIdentifiedRegionInside(in template (value) UInt16 p_parent,
                                            in template (value) UInt16 p_region
        ) return boolean {
            // TODO: call external function
            return valueof(p_parent) == valueof(p_region);
        } // End of function f_isIdentifiedRegionInside
        
@@ -995,6 +1009,8 @@ module LibItsSecurity_Functions {
            if (not isbound(p_region) or not isbound(p_location) or (lengthof(p_region) == 0)) {
                return false;
            }
            log("f_isLocationInsideRectangularRegion: p_polygonalArea: ", p_region);
            log("f_isLocationInsideRectangularRegion: p_location: ", p_location);
            
            return fx_isLocationInsideRectangularRegion(valueof(p_region), valueof(p_location));
        } // End of function f_isLocationInsideRectangularRegion
@@ -1013,6 +1029,8 @@ module LibItsSecurity_Functions {
            if (not isbound(p_region) or not isbound(p_location) or (lengthof(p_region) == 0)) {
                return false;
            }
//            log("f_isLocationInsidePolygonalRegion: p_polygonalArea: ", p_region, " - ", valueof(p_region));
//            log("f_isLocationInsidePolygonalRegion: p_location: ", p_location, " - ", valueof(p_location));
            
            return fx_isLocationInsidePolygonalRegion(valueof(p_region), valueof(p_location));
        } // End of function f_isLocationInsidePolygonalRegion
@@ -1049,6 +1067,49 @@ module LibItsSecurity_Functions {
            return false;
        } // End of function f_isLocationInsideOtherRegion
        
        /**
         * @desc Convert a spacial coordinate from DMS to Dms
         * @param p_degrees The degrees (D)
         * @param p_minutes The minutes (M)
         * @param p_seconds The seconds (S)
         * @param p_latlon  The latitude/longitude: (N|S|E|W)
         * @return The decimal coordinate on success, 0.0, otherwise
         * @verdict Unchanged
         */
        function f_dms2dd(in integer p_degrees, in integer p_minutes, in float p_seconds, in charstring p_latlon) 
        return float {
            // Sanity checks
            if (lengthof(p_latlon) != 1) {
                return 0.0;
            } else if ((p_latlon != "N") and (p_latlon != "S") and (p_latlon != "E") and (p_latlon != "W")) {
                return 0.0;
            }
            
            return fx_dms2dd(p_degrees, p_minutes, p_seconds, p_latlon);
        } // End of function f_dms2dd
        
        /**
         * @desc Convert the latitude from float to int
         * @param p_latitude The latitude to be converted. Significand length shall be 7 digits length
         * @return The converted latitude
         * @verdict Unchanged
         */
        function f_ddlat2int(in float p_latitude) 
        return WGSLatitude {
            return float2int(p_latitude * 10000000.0); // Significand length shall be 7 digits length
        }
        
        /**
         * @desc Convert the longitude from float to int
         * @param p_longitude The longitude to be converted. Significand length shall be 6 digits length
         * @return The converted longitude
         * @verdict Unchanged
         */
        function f_ddlon2int(in float p_longitude) 
        return WGSLongitude {
            return float2int(p_longitude * 1000000.0); // Significand length shall be 6 digits length
        }
        
    } // End of group geometryFunctions 
    
} // End of module LibItsSecurity_Functions