def __select_nearest_ws(jsondata, latitude, longitude):
log.debug("<STR_LIT>",<EOL>latitude, longitude)<EOL>dist = <NUM_LIT:0><EOL>dist2 = <NUM_LIT:0><EOL>loc_data = None<EOL>try:<EOL><INDENT>ws_json = jsondata[__ACTUAL]<EOL>ws_json = ws_json[__STATIONMEASUREMENTS]<EOL><DEDENT>except (KeyError, TypeError):<EOL><INDENT>log.warning("<STR_LIT>"<EOL>"<STR_LIT>",<EOL>__STATIONMEASUREMENTS)<EOL>return None<EOL><DEDENT>for wstation in ws_json:<EOL><INDENT>dist2 = __get_ws_distance(wstation, latitude, longitude)<EOL>if dist2 is not None:<EOL><INDENT>if ((loc_data is None) or (dist2 < dist)):<EOL><INDENT>dist = dist2<EOL>loc_data = wstation<EOL><DEDENT><DEDENT><DEDENT>if loc_data is None:<EOL><INDENT>log.warning("<STR_LIT>")<EOL>return None<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>log.debug("<STR_LIT>"<EOL>"<STR_LIT>",<EOL>loc_data[__STATIONID],<EOL>loc_data[__STATIONNAME],<EOL>loc_data[__LAT],<EOL>loc_data[__LON])<EOL><DEDENT>except KeyError:<EOL><INDENT>log.debug("<STR_LIT>")<EOL><DEDENT>return loc_data<EOL><DEDENT>
Select the nearest weatherstation.