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


Python IonObject.longitude方法代码示例

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


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

示例1: calc_geospatial_point_center

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import longitude [as 别名]
    def calc_geospatial_point_center(cls, geospatial_bounds=None, distance=None, return_location=False):
        if not geospatial_bounds:
            raise BadRequest("Geospatial bounds data is not set correctly")
        if (geospatial_bounds.geospatial_latitude_limit_north < -90 or geospatial_bounds.geospatial_latitude_limit_north > 90 or
            geospatial_bounds.geospatial_latitude_limit_south < -90 or geospatial_bounds.geospatial_latitude_limit_south > 90 or
            geospatial_bounds.geospatial_longitude_limit_east < -180 or geospatial_bounds.geospatial_longitude_limit_east > 180 or
            geospatial_bounds.geospatial_longitude_limit_west < -180 or geospatial_bounds.geospatial_longitude_limit_west > 180):
            raise BadRequest("Geospatial bounds data out of range")
        geo_index_obj = IonObject(OT.GeospatialIndex)

        west_lon = geospatial_bounds.geospatial_longitude_limit_west
        east_lon = geospatial_bounds.geospatial_longitude_limit_east
        north_lat = geospatial_bounds.geospatial_latitude_limit_north
        south_lat = geospatial_bounds.geospatial_latitude_limit_south

        if not distance:
            if (west_lon >= 0 and east_lon >= 0) or (west_lon <= 0 and east_lon <= 0):  # Same hemisphere
                if west_lon <= east_lon:  # West is "to the left" of East
                    distance = GeoUtils.DISTANCE_SHORTEST
                else:  # West is "to the right" of East
                    distance = GeoUtils.DISTANCE_LONGEST
            elif west_lon >= 0 and east_lon <= 0:
                if west_lon + abs(east_lon) < 180:
                    distance = GeoUtils.DISTANCE_LONGEST
                else:
                    distance = GeoUtils.DISTANCE_SHORTEST
            elif west_lon <= 0 and east_lon >= 0:
                if abs(west_lon) + east_lon > 180:
                    distance = GeoUtils.DISTANCE_LONGEST
                else:
                    distance = GeoUtils.DISTANCE_SHORTEST
            else:
                distance = GeoUtils.DISTANCE_SHORTEST
        if distance == GeoUtils.DISTANCE_SHORTEST:
            geo_index_obj.lat, geo_index_obj.lon = GeoUtils.midpoint_shortest(north_lat=north_lat, west_lon=west_lon, south_lat=south_lat, east_lon=east_lon)
        elif distance == GeoUtils.DISTANCE_LONGEST:
            geo_index_obj.lat, geo_index_obj.lon = GeoUtils.midpoint_longest(north_lat=north_lat, west_lon=west_lon, south_lat=south_lat, east_lon=east_lon)
        else:
            raise BadRequest("Distance type not specified")

        if return_location:
            geo_loc_obj = IonObject(OT.GeospatialLocation)
            geo_loc_obj.latitude = geo_index_obj.lat
            geo_loc_obj.longitude = geo_index_obj.lon
            return geo_loc_obj

        return geo_index_obj
开发者ID:edwardhunter,项目名称:scioncc,代码行数:49,代码来源:geo_utils.py


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