AWOIS Wreck, AWOIS Obstructions, ENC Wrecks to SPOI data model ?> Office of Coast Survey data to RDF

The Office of Coast Survey → SPOI data model

The Office of Coast Survey: http://www.nauticalcharts.noaa.gov/hsd/wrecks_and_obstructions.html

SPOI: http://sdi4apps.eu/spoi



AWOIS Wrecks

Start
(this may take a while)

ENC Wrecks

Start
(this may take a while)

AWOIS Obstructions

Start
(this may take a while)


ENC Wrecks
"; // filesize of downloaded archive $filesize = filesize("ENC_Wrecks.kml"); echo "Kml file size: ".format_size($filesize)."
"; $contents = file_get_contents('ENC_Wrecks.kml'); // create new rdf file $soubor = fopen("ENC_Wrecks.rdf", "w"); // write head of rdf fwrite($soubor, '\r\n"); fwrite($soubor, ' '); // read xml $xml = new SimpleXMLElement($contents); $value = $xml->Document->Folder->Placemark; // memory usage echo 'Memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB
"; $long; $lat; $label; $source = "ENCW"; foreach($value as $coord) { $feature_type = ""; $name = $coord -> name; $watlev = ""; $depth = ""; $chart = ""; $value2 = $coord->ExtendedData->SchemaData->SimpleData; foreach($value2 as $coord2) { if($coord2['name'] == "feature_type"){ $label = $coord2; } if($coord2['name'] == "latdec"){ $lat = $coord2; } if($coord2['name'] == "londec"){ $long = $coord2; } if($coord2['name'] == "watlev"){ $watlev = $coord2; } if($coord2['name'] == "depth"){ $depth = $coord2; } if($coord2['name'] == "chart"){ $chart = $coord2; } if($coord2['name'] == "feature_type"){ $feature_type = $coord2; } } if(substr($label, 0, 6) == "Wrecks"){ $label = substr($label, 7); $label = 'Wreck '.$label; } fwrite($soubor, ' '); fwrite($soubor, "\r\n"); if($feature_type != ""){ fwrite($soubor, ' '.$label.''); fwrite($soubor, "\r\n"); } else{ fwrite($soubor, ' Wrecks'); fwrite($soubor, "\r\n"); } fwrite($soubor, ' POINT('.$long.' '.$lat.')'); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); if($depth != ""){ fwrite($soubor, ' Depth: '.$depth.' m'); fwrite($soubor, "\r\n"); } if($watlev != ""){ fwrite($soubor, ' Water Level Effect: '.$watlev.''); fwrite($soubor, "\r\n"); } if($chart != ""){ fwrite($soubor, ' Chart: '.$chart.''); fwrite($soubor, "\r\n"); } fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' SPOI (http://sdi4apps.eu/spoi)'); fwrite($soubor, "\r\n"); if($feature_type != ""){ fwrite($soubor, ' '.$label.''); fwrite($soubor, "\r\n"); } else{ fwrite($soubor, ' Wrecks'); fwrite($soubor, "\r\n"); } fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); $date = getdate(); fwrite($soubor, ' '.$date['year']."-".$date['mon']."-".$date['mday'].''); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); } fwrite($soubor, "
"); fclose($soubor); // delete downloaded kml unlink('ENC_Wrecks.kml'); // link to download rdf echo 'Download RDF file'; // filesize of rdf $filesize = filesize("ENC_Wrecks.rdf"); echo " (".format_size($filesize).")
"; } ////////////////////////////////////////////////////////////////////////////////////////////////////// AWOIS Wrecks function awois_wrecks(){ file_put_contents("AWOIS_Wrecks.kml", fopen("http://wrecks.nauticalcharts.noaa.gov/downloads/AWOIS_Wrecks.kml", 'r')); echo "

AWOIS Wrecks
"; // filesize of downloaded archive $filesize = filesize("AWOIS_Wrecks.kml"); echo "Kml file size: ".format_size($filesize)."
"; $contents = file_get_contents('AWOIS_Wrecks.kml'); // create rdf $soubor = fopen("AWOIS_Wrecks.rdf", "w"); // write head of rdf fwrite($soubor, '\r\n"); fwrite($soubor, ' '); // read xml $xml = new SimpleXMLElement($contents); $value = $xml->Document->Folder->Placemark; // memory usage echo 'Memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB
"; $long; $lat; $label; $source = "AWOISW"; foreach($value as $coord) { $vesslterm = ""; $depth = ""; $yearsunk = ""; $feature_type = ""; $name= $coord->name; $value2 = $coord->description; $unit = ""; $vessltermexist = true; $DOM = new DOMDocument; @ $DOM->loadHTML($value2); $items = $DOM->getElementsByTagName('td'); $vesslterm = $items->item(1)->nodeValue; $feature_type = $items->item(2)->nodeValue; $lat = $items->item(3)->nodeValue; $long = $items->item(4)->nodeValue; $depth = $items->item(6)->nodeValue; $unit = $items->item(7)->nodeValue; $yearsunk = $items->item(8)->nodeValue; $wreck = true; fwrite($soubor, ' '); fwrite($soubor, "\r\n"); if($vesslterm == "UNKNOWN" OR $vesslterm == ""){ $vessltermexist = false; if($feature_type != "Not Charted"){ $wreck = false; fwrite($soubor, ' '.$feature_type.''); fwrite($soubor, "\r\n"); } else{ $wreck = false; fwrite($soubor, ' Wreck'); fwrite($soubor, "\r\n"); } } else{ fwrite($soubor, ' '.$vesslterm.''); fwrite($soubor, "\r\n"); } fwrite($soubor, ' POINT('.$long.' '.$lat.')'); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); if($wreck == false){ } else if($feature_type != "Not Charted" AND $feature_type != "" AND $wreck == true){ fwrite($soubor, ' '.$feature_type.''); fwrite($soubor, "\r\n"); } else{ fwrite($soubor, ' Wreck'); fwrite($soubor, "\r\n"); } if($depth != ""){ fwrite($soubor, ' Depth: '.$depth.' '); if($unit != ""){ if($unit == "Feet and tenths"){ fwrite($soubor, 'ft'); fwrite($soubor, "\r\n"); } else if($unit == "Meters and tenths"){ fwrite($soubor, 'm'); fwrite($soubor, "\r\n"); } else if($unit == "Fathoms and tenths"){ fwrite($soubor, 'fathoms'); fwrite($soubor, "\r\n"); } else{ fwrite($soubor, $unit.''); fwrite($soubor, "\r\n"); } } else{ fwrite($soubor, 'm'); fwrite($soubor, "\r\n"); } } if($yearsunk != ""){ fwrite($soubor, ' Year Sunk: '.$yearsunk.''); fwrite($soubor, "\r\n"); } fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' SPOI (http://sdi4apps.eu/spoi)'); fwrite($soubor, "\r\n"); if($vesslterm == "UNKNOWN" OR $vesslterm == ""){ $vessltermexist = false; if($feature_type != "Not Charted"){ fwrite($soubor, ' '.$feature_type.''); fwrite($soubor, "\r\n"); } else{ fwrite($soubor, ' Wreck'); fwrite($soubor, "\r\n"); } } else{ fwrite($soubor, ' '.$vesslterm.''); fwrite($soubor, "\r\n"); } fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); $date = getdate(); fwrite($soubor, ' '.$date['year']."-".$date['mon']."-".$date['mday'].''); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); } fwrite($soubor, "
"); fclose($soubor); // delete downloaded kml unlink('AWOIS_Wrecks.kml'); // link to download rdf echo 'Download RDF file'; // filesize of rdf $filesize = filesize("AWOIS_Wrecks.rdf"); echo " (".format_size($filesize).")
"; } ////////////////////////////////////////////////////////////////////////////////////////////////////// AWOIS Obstructions function awois_obstructions(){ file_put_contents("AWOIS_Obscructions.kml", fopen("http://wrecks.nauticalcharts.noaa.gov/downloads/AWOIS_Obstructions.kml", 'r')); echo "

AWOIS Obscructions
"; // filesize of downloaded archive $filesize = filesize("AWOIS_Obscructions.kml"); echo "Kml file size: ".format_size($filesize)."
"; $contents = file_get_contents('AWOIS_Obscructions.kml'); // create rdf file $soubor = fopen("AWOIS_Obscructions.rdf", "w"); // write head of rdf fwrite($soubor, '\r\n"); fwrite($soubor, ' '); // read xml $xml = new SimpleXMLElement($contents); $value = $xml->Document->Folder->Placemark; echo 'Memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB
"; $long; $lat; $label; $source = "AWOISO"; foreach($value as $coord) { $depth = ""; $yearsunk = ""; $feature_type = ""; $name= $coord->name; $value2 = $coord->description; $unit = ""; $DOM = new DOMDocument; @ $DOM->loadHTML($value2); $items = $DOM->getElementsByTagName('td'); $vesslterm = $items->item(1)->nodeValue; $feature_type = $items->item(2)->nodeValue; $lat = $items->item(3)->nodeValue; $long = $items->item(4)->nodeValue; $depth = $items->item(6)->nodeValue; $unit = $items->item(7)->nodeValue; $yearsunk = $items->item(8)->nodeValue; fwrite($soubor, ' '); fwrite($soubor, "\r\n"); if($feature_type != "Not Charted" AND $feature_type != ""){ fwrite($soubor, ' '.$feature_type.''); fwrite($soubor, "\r\n"); } else{ fwrite($soubor, ' Obstruction'); fwrite($soubor, "\r\n"); } fwrite($soubor, ' POINT('.$long.' '.$lat.')'); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); if($depth != ""){ fwrite($soubor, ' Depth: '.$depth.' '); if($unit != ""){ if($unit == "Feet and tenths"){ fwrite($soubor, 'ft'); fwrite($soubor, "\r\n"); } else if($unit == "Meters and tenths"){ fwrite($soubor, 'm'); fwrite($soubor, "\r\n"); } else if($unit == "Fathoms and tenths"){ fwrite($soubor, 'fathoms'); fwrite($soubor, "\r\n"); } else{ fwrite($soubor, $unit.''); fwrite($soubor, "\r\n"); } } else{ fwrite($soubor, 'm'); fwrite($soubor, "\r\n"); } } if($yearsunk != ""){ fwrite($soubor, ' Year Sunk: '.$yearsunk.''); fwrite($soubor, "\r\n"); } fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' SPOI (http://sdi4apps.eu/spoi)'); fwrite($soubor, "\r\n"); if($feature_type != "Not Charted" AND $feature_type != ""){ fwrite($soubor, ' '.$feature_type.''); fwrite($soubor, "\r\n"); } else{ fwrite($soubor, ' Obstruction'); fwrite($soubor, "\r\n"); } fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); $date = getdate(); fwrite($soubor, ' '.$date['year']."-".$date['mon']."-".$date['mday'].''); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); } fwrite($soubor, "
"); fclose($soubor); // delete downloaded kml unlink('AWOIS_Obscructions.kml'); // link to download rdf echo 'Download RDF file'; // filesize of rdf $filesize = filesize("AWOIS_Obscructions.rdf"); echo " (".format_size($filesize).")
"; } // filesize function function format_size($size) { $sizes = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"); if ($size == 0) { return('n/a'); } else { return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]); } } ?>