"OK", "action" => "decodeFromWords", "words" => $words, "coords" => $coords ]; } else if (!empty($VARS["latitude"]) && !empty($VARS["longitude"])) { // convert coordinates to words $lat = round($VARS["latitude"], 4); $lon = round($VARS["longitude"], 4); $words = FixPhrase::encode($lat, $lon); $output = [ "status" => "OK", "action" => "encodeToWords", "words" => $words, "coords" => [ $lat, $lon ] ]; } else { throw new Exception("Must supply either a string of words or a latitude/longitude pair."); } } catch (Exception $ex) { sendJsonResp($ex->getMessage(), "ERROR"); } exitWithJson($output);