当前位置: 首页>>代码示例>>Python>>正文


Python Utility.create_gmaps_link方法代码示例

本文整理汇总了Python中utility.Utility.create_gmaps_link方法的典型用法代码示例。如果您正苦于以下问题:Python Utility.create_gmaps_link方法的具体用法?Python Utility.create_gmaps_link怎么用?Python Utility.create_gmaps_link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utility.Utility的用法示例。


在下文中一共展示了Utility.create_gmaps_link方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build_alert

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import create_gmaps_link [as 别名]
    def build_alert(self, alert_id, alert_message, location=None):
        """Build the actual alert and returns it, formatted.

        DEPRECATION NOTICE:  The 'alert_id' field has been introduced for
        better readability.  It's currently set to be the same as 'id'.
        At some point in the future, the 'id' field will be removed.

        Args:
            alert_id (int): The ID of the alert you want to build
            alert_message (str): The message to be embedded in the alert.

        Returns:
            tuple: Position 0 contains the string 'sitch_alert'.  Position 1
                contains the alert and metadata.
        """
        if location is None:
            print("AlertManager: No geo for alarm: %s" % str(alert_message))
            location = {"type": "Point", "coordinates": [0, 0]}
        elif Utility.validate_geojson(location) is False:
            print("AlertManager: Invalid geojson %s for: %s" % (location,
                                                                alert_message))
            location = {"type": "Point", "coordinates": [0, 0]}
        lat = location["coordinates"][1]
        lon = location["coordinates"][0]
        gmaps_url = Utility.create_gmaps_link(lat, lon)
        message = Utility.generate_base_event()
        message["alert_id"] = alert_id
        message["id"] = alert_id
        message["alert_type"] = self.get_alert_type(alert_id)
        message["event_type"] = "sitch_alert"
        message["details"] = ("%s  %s" % (alert_message, gmaps_url))
        message["location"] = location
        retval = ("sitch_alert", message)
        return retval
开发者ID:sitch-io,项目名称:sensor,代码行数:36,代码来源:alert_manager.py

示例2: geo_drift_check

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import create_gmaps_link [as 别名]
    def geo_drift_check(cls, geo_anchor, gps_scan, threshold, device_id):
        """Fire alarm if distance between points exceeds threshold.

        Args:
            geo_anchor (dict): Geographic anchor point, usually stored in an
                instance variable and passed in via the `correlate()` method.
            gps_scan (dict): Same format as geo_anchor, expects the same format
                as `geo_anchor`.
            threshold (int): Alerting threshold in km.

        Returns:
            list: list of alerts (usually just one) or an empty list of there
                are no alerts.
        """
        lat_1 = geo_anchor["location"]["coordinates"][1]
        lon_1 = geo_anchor["location"]["coordinates"][0]
        lat_2 = gps_scan["location"]["coordinates"][1]
        lon_2 = gps_scan["location"]["coordinates"][0]
        current_distance = Utility.calculate_distance(lon_1, lat_1,
                                                      lon_2, lat_2)
        if current_distance < threshold:
            return []
        else:
            message = "Possible GPS spoofing attack! %d delta from anchor at %s / %s %s !" % (current_distance, gps_scan["site_name"], gps_scan["sensor_name"], Utility.create_gmaps_link(lat_1, lon_1))  # NOQA
            alert = AlertManager(device_id).build_alert(300, message,
                                                        gps_scan["location"])
            return[alert]
开发者ID:sitch-io,项目名称:sensor,代码行数:29,代码来源:geo_correlator.py


注:本文中的utility.Utility.create_gmaps_link方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。