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


Python Utility.validate_geojson方法代码示例

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


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

示例1: build_alert

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import validate_geojson [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


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