<?php 


require_once("../../includes/functions_internal_user_dryout.inc.php");
$obj = new data();
// $url = "https://apipro.seametrix.net/api/GetRoutes?AccessKey=7oc3y5h2w2f";
$url = "https://newapipro2.seametrix.net/api/GetRoutes?AccessKey=7oc3y5h2w2f";
    $obj 		= new data();
    $allowedarea = explode(',',$_REQUEST['AllowedAreas']);
	$allowedarea1 = array();
	for($i=0;$i<count($allowedarea);$i++)
	{
	    $allowedarea1[] = (int)$allowedarea[$i];
	}

	$curl = curl_init($url);
	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_POST, true);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	
	$headers = array("Content-Type: application/json");
	curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
	
	$data_arr = array("StartLon" => (int)$_REQUEST['StartLon'],
	"StartLat" => (int)$_REQUEST['StartLat'],     
	"StartPortCode" => $obj->getPortCodeBasedOnID($_REQUEST['StartPortID']),
	"EndLon" => (int)$_REQUEST['EndLon'],
	"EndLat" => (int)$_REQUEST['EndLat'],
	"EndPortCode" => $obj->getPortCodeBasedOnID($_REQUEST['EndPortID']),
	"GreatCircleInterval" => (int)$_REQUEST['GreatCircleInterval'],               
	"AllowedAreas" => $allowedarea1,
	"SecaAvoidance" => (int)$_REQUEST['SecaAvoidance'],          
	"AslCompliance" => (int)$_REQUEST['AslCompliance']);
	
	
	$data = "[".json_encode($data_arr)."]";
	
	curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
	curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
	
	$resp = curl_exec($curl);
	curl_close($curl);
	echo $resp;
?>