本文整理汇总了Python中pyon.public.IonObject.lat方法的典型用法代码示例。如果您正苦于以下问题:Python IonObject.lat方法的具体用法?Python IonObject.lat怎么用?Python IonObject.lat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.public.IonObject
的用法示例。
在下文中一共展示了IonObject.lat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: calc_geospatial_point_center
# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import lat [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
示例2: calc_geospatial_point_center
# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import lat [as 别名]
def calc_geospatial_point_center(cls, geospatial_bounds=None):
geo_index_obj = IonObject(OT.GeospatialIndex)
if geospatial_bounds :
geo_index_obj.lat = (geospatial_bounds.geospatial_latitude_limit_north + geospatial_bounds.geospatial_latitude_limit_south) / 2
geo_index_obj.lon = (geospatial_bounds.geospatial_longitude_limit_east + geospatial_bounds.geospatial_longitude_limit_west) / 2
return geo_index_obj