function _api_getGeometry_name($name) {
	$geometry = _api_getGeometry();
	if (!get_http_var('future')) {
	    $name = normalise_constituency_name($name);
	}
	$out = array();
	foreach ($geometry['data'] as $n => $data) {
		if ($n == $name)
			return $data;
	}
	return null;
}
Exemple #2
0
function _api_getGeometry_name($name)
{
    $geometry = _api_getGeometry();
    $name = html_entity_decode(normalise_constituency_name($name));
    # XXX
    $out = array();
    foreach ($geometry['data'] as $n => $data) {
        if ($n == $name) {
            return $data;
        }
    }
    return null;
}
function _api_getConstituencies_latitude($lat, $lon, $d)
{
    $geometry = _api_getGeometry();
    $out = array();
    foreach ($geometry['data'] as $name => $data) {
        if (!isset($data['centre_lat']) || !isset($data['centre_lon'])) {
            continue;
        }
        $distance = R_e * acos(sin(deg2rad($lat)) * sin(deg2rad($data['centre_lat'])) + cos(deg2rad($lat)) * cos(deg2rad($data['centre_lat'])) * cos(deg2rad($lon - $data['centre_lon'])));
        if (deg2rad($data['centre_lat']) > deg2rad($lat) - $d / R_e && deg2rad($data['centre_lat']) < deg2rad($lat) + $d / R_e && (abs(deg2rad($lat)) + $d / R_e > M_PI_2 || _api_angle_between(deg2rad($data['centre_lon']), deg2rad($lon)) < $d / (R_e * cos(deg2rad($lat + $d / R_e)))) && $distance < $d) {
            $out[] = array_merge($data, array('distance' => $distance, 'name' => $name));
        }
    }
    usort($out, create_function('$a,$b', "\n\t\tif (\$a['distance'] > \$b['distance']) return 1;\n\t\tif (\$a['distance'] < \$b['distance']) return -1;\n\t\treturn 0;"));
    return $out;
}