$uri = $_SERVER['REQUEST_URI']; //echo $uri; $ua = $_SERVER['HTTP_USER_AGENT']; //echo $ua; $chartCounter=0; function DECtoDMS($dec) { // Converts decimal longitude / latitude to DMS // ( Degrees / minutes / seconds ) // This is the piece of code which may appear to // be inefficient, but to avoid issues with floating // point math we extract the integer part and the float // part by using a string function. $vars = explode(".",$dec); $deg = $vars[0]; $tempma = "0.".$vars[1]; $tempma = $tempma * 3600; $min = floor($tempma / 60); if (strlen($min) < 2){ $min='0'.$min; } $sec = $tempma - ($min*60); return array("deg"=>$deg,"min"=>$min,"sec"=>$sec); } if (isset($_GET['lat'])){ $lat=$_GET['lat']; $long=$_GET['long']; $DMSLat=DECtoDMS($lat); $DMSLong=DECtoDMS($long); //echo $DMSLat['deg'].$DMSLat['min'].$DMSLat['sec']; // echo strlen($DMSLat['min']); //if (strlen($DMSLat['min'] == '1')){ // echo 'hi'; // $DMSLat['min']='0'.$DMSLat['min']; // } // echo $DMSLat['min']; $lat=$DMSLat['deg'].$DMSLat['min'].$DMSLat['sec']; //echo strlen($lat); while (strlen($lat) <8){ $lat=$lat.'0'; } $long=$DMSLong['deg'].$DMSLong['min'].$DMSLong['sec']; if ($DMSLong['deg'] > -100){ $long=(str_replace("-","0",$long)); } else { $long=(str_replace("-","",$long)); } echo '->'.$DMSLong['deg'].'<-'; while (strlen($long) < 9){ $long=$long.'0'; } //$lat=(str_replace(".","",$lat)).'0000'; //$long=(str_replace("-","0",$long)).'0000'; //$long=str_replace(".","",$long); //echo "^".$lat1."^".$long1."^"; echo "^".$lat."^".$long; //$url = 'http://ocs-vs-webd1:10104/m/geo/getChartsWPoint.php?lat='.$lat.'&lng='.$long; //$url = 'http://nauticalcharts.noaa.gov/m/geo/getChartsWPoint.php?lat='.$lat.'&lng='.$long; //$url= "getChartsWPoint.php?lat=38.99&lng=-77.03"; //$content = file_get_contents($url); //if (file_get_contents($url) === false){ // echo "Can't get file"; //} //$json = json_decode($content, true); $myFile = "/chapp/Chapp.csv"; $fh = fopen($myFile, 'r'); //$theData = fread($fh, filesize($myFile)); $headerjunk=fgets($fh,4096); $explodedHeader=explode(',',$headerjunk); $counter=0; foreach ($explodedHeader as $value){ //echo $counter.'. '.$value.''; $counter++; } $theData=fgets($fh,4096); while ($theData){ $lineArray=explode(',', $theData); //echo $theData.''; $gpCounter=0; for ($i =32;$i<64;$i++){ if ($lineArray[$i] != ""){ //echo $lineArray[$i]; $temp=explode('W',$lineArray[$i]); $currentLongs[$gpCounter]=$temp[1]; $currentLats[$gpCounter]=substr($temp[0],1); $gpCounter++; //echo ' lat:'.$currentLats; //echo ' long:'.$currentLongs; //echo ''; } } if ($lat min($currentLats)){ if ($longmin($currentLongs)){ //echo 'INSIDE '; //echo max($currentLats).''; //echo ' lat:'.$lat." "; //echo min($currentLats).""; echo $lineArray[4].'*'; $charts[$chartCounter] = $lineArray[4]; $title[$chartCounter]= $lineArray[10]; //echo sizeof($charts); $chartCounter++; //echo ' long:'.$long; } else { //echo "$$$$$$$$$"; } } //echo max($currentLats); //echo min($currentLats); //echo min($currentLongs); unset($currentLats); unset($currentLongs); $theData=fgets($fh,4096); } fclose($fh); } ?> Coast Survey Mobile Charts $titlecounter=0; foreach ($charts as $chartItem){ echo ''. $chartItem." ".$title[$titlecounter].''; $titlecounter++; } ?> Home About Contact Note: Some information that is linked to on this website may belong to other offices at NOAA. Note: Downloads of information may take a long time using a 3G connection or worse. 4G or WiFi connection is recommended, but not necessary. if (isset($_GET['lat'])==FALSE){ ?> } ?>
Note: Downloads of information may take a long time using a 3G connection or worse. 4G or WiFi connection is recommended, but not necessary.