Пример #1
0
def find_nearby_sites(s_lat, s_lon):
    """ return RWIS site list order by distance (from nearest)

    :type s_lat: float
    :type s_lon: float
    :return: RWIS site list
    :rtype: list[RWISSiteInfo]
    """
    sites = []
    for gr in cfg.RWIS_SITE_INFO:
        for st in gr['sites']:
            d = distance.distance_in_mile_with_coordinate(
                s_lat, s_lon, st['lat'], st['lon'])
            sites.append(
                RWISSiteInfo({
                    'group_id': gr['id'],
                    'group_name': gr['name'],
                    'site_id': st['id'],
                    'site_name': st['name'],
                    'lat': st['lat'],
                    'lon': st['lon'],
                    'distance_to_target': d
                }))

    return sorted(sites, key=lambda s: s.distance_to_target)
Пример #2
0
def get_all_rwis_sites():
    """ return site information

    :rtype: list[RWISSiteInfo]
    """
    sites = []
    for gr in cfg.RWIS_SITE_INFO:
        for st in gr['sites']:
            sites.append(
                RWISSiteInfo({
                    'group_id': gr['id'],
                    'group_name': gr['name'],
                    'site_id': st['id'],
                    'site_name': st['name'],
                    'lat': st['lat'],
                    'lon': st['lon']
                }))
    return sites
Пример #3
0
def get_site_by_id(site_id):
    """ return site information

    :type site_id: str
    :rtype: RWISSiteInfo
    """
    for gr in cfg.RWIS_SITE_INFO:
        for st in gr['sites']:
            if st['id'] == site_id:
                return RWISSiteInfo({
                    'group_id': gr['id'],
                    'group_name': gr['name'],
                    'site_id': st['id'],
                    'site_name': st['name'],
                    'lat': st['lat'],
                    'lon': st['lon']
                })
    return None