// otherwise this will not work $rightofway->addProblem($desc, $type, $cleaned["reporter_name"], $cleaned["reporter_email"], (double) $attrs["x"], (double) $attrs["y"]); } } } } } else { header("HTTP/1.1 400 Bad Request"); echo "Unexpected format"; } break; case "getProblems": if (isset($cleaned["id"])) { $rightsofway = array(new RightOfWay($cleaned["id"])); } elseif (isset($cleaned["parish"]) && isset($cleaned["routeno"])) { $rightsofway = RightOfWay::findFromRouteNo($cleaned["parish"], $cleaned["routeno"]); } if (count($rightsofway) > 0) { header("Content-type: application/json"); $json = array(); foreach ($rightsofway as $rightofway) { if ($rightofway->isValid()) { $data = $rightofway->getProblems(); if (count($data) > 0) { $json[] = $data; } } } echo json_encode($json); } else { header("HTTP/1.1 404 Not Found");