<?php

$contentType= isset($_SERVER["CONTENT_TYPE"]) ?  trim($_SERVER["CONTENT_TYPE"]): '';
if($contentType ==="application/json"){
    $content = trim(file_get_contents("php://input"));
    $decodeData =json_decode($content, true);
    if(is_array($decodeData)){
    $obj= new getLatLong();      
    $obj->getLatLongOfsiteDetails($decodeData);  
    }
}

    class getLatLong{
        function __construct()
        {
         require_once dirname(__DIR__)."../../php/DB_Connect.php";
         $dbclassObj= new DB_conncect();
         $this->db=$dbclassObj->connectToDB();
        }
        function getLatLongOfsiteDetails($data){
            $reslt_arrry=array();
            $query=$this->db->prepare("SELECT `LATITUDE`,`LONGITUDE` FROM `sitesinfo` WHERE  `SITE_ID`=?");
            $query->bind_param("s",$data["siteId"]);
            $query->execute();
            $query->bind_result($latitude,$longitude);
            $query->store_result();
            if ($query->num_rows() > 0) {
                while ($query->fetch()) {

                    $reslt_arrry['latitude']=$latitude;
                    $reslt_arrry['longitude']=$longitude;
               // array_push($mainArray,$reslt_arrry);

        }
        echo json_encode($reslt_arrry);

    }else{
        $reslt_arrry['error']=true;
        $reslt_arrry['message']="site-id incorrect";
        echo json_encode($reslt_arrry);
    }
}
    }
?>