officeOfCoastSurvey.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. <?php
  2. // Office of Coast Service
  3. // http://www.nauticalcharts.noaa.gov/hsd/wrecks_and_obstructions.html
  4. // download and transform 3 datasets -> AWOIS Wreck, AWOIS Obstructions, ENC Wrecks to SPOI data model
  5. ?>
  6. <!DOCTYPE html>
  7. <html lang="cs" dir="ltr">
  8. <head>
  9. <title>Office of Coast Survey data to RDF</title>
  10. <meta charset="utf-8">
  11. <meta name="robots" content="index,follow">
  12. <meta name="author" content="Jáchym Kellar">
  13. <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> -->
  14. <style>
  15. body{
  16. margin-top: 80px;
  17. text-align: center;
  18. }
  19. .start{
  20. font-size: 28px;
  21. text-decoration: none;
  22. letter-spacing: 1px;
  23. }
  24. a{
  25. text-decoration: none;
  26. }
  27. a:hover{
  28. text-decoration: underline;
  29. }
  30. .pozn{
  31. font-size: 13px;
  32. }
  33. h4{
  34. margin-bottom: 5px;
  35. }
  36. </style>
  37. </head>
  38. <body>
  39. <h2>The Office of Coast Survey &rarr; SPOI data model</h2>
  40. <h4>The Office of Coast Survey: <a href="http://www.nauticalcharts.noaa.gov/hsd/wrecks_and_obstructions.html" target="_blank">http://www.nauticalcharts.noaa.gov/hsd/wrecks_and_obstructions.html</a></h4>
  41. <h4>SPOI: <a href="http://sdi4apps.eu/spoi/" target="_blank">http://sdi4apps.eu/spoi</a></h4>
  42. <br><br>
  43. <h4>AWOIS Wrecks</h4>
  44. <a href="officeOfCoastSurvey.php?transform=start_awois_wrecks" class="start">Start</a>
  45. <br><span class="pozn">(this may take a while)</span><br><br>
  46. <h4>ENC Wrecks</h4>
  47. <a href="officeOfCoastSurvey.php?transform=start_enc_wrecks" class="start">Start</a>
  48. <br><span class="pozn">(this may take a while)</span><br><br>
  49. <h4>AWOIS Obstructions</h4>
  50. <a href="officeOfCoastSurvey.php?transform=start_awois_obstructions" class="start">Start</a>
  51. <br><span class="pozn">(this may take a while)</span><br><br>
  52. <?php
  53. if (IsSet($_GET['transform'])){
  54. $status=$_GET['transform'];
  55. if($status == "start_awois_wrecks"){
  56. awois_wrecks();
  57. }
  58. if($status == "start_enc_wrecks"){
  59. enc_wrecks();
  60. }
  61. if($status == "start_awois_obstructions"){
  62. awois_obstructions();
  63. }
  64. }
  65. ?>
  66. </body>
  67. </html>
  68. <?php
  69. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ENC WRECKS
  70. function enc_wrecks(){
  71. file_put_contents("ENC_Wrecks.kml", fopen("http://wrecks.nauticalcharts.noaa.gov/downloads/ENC_Wrecks.kml", 'r'));
  72. echo "<br><br>ENC Wrecks<br>";
  73. // filesize of downloaded archive
  74. $filesize = filesize("ENC_Wrecks.kml");
  75. echo "Kml file size: ".format_size($filesize)."<br>";
  76. $contents = file_get_contents('ENC_Wrecks.kml');
  77. // create new rdf file
  78. $soubor = fopen("ENC_Wrecks.rdf", "w");
  79. // write head of rdf
  80. fwrite($soubor, '<?xml version="1.0" encoding="utf-8"?');
  81. fwrite($soubor, ">\r\n");
  82. fwrite($soubor, '<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/"
  83. xmlns:dcterms="http://purl.org/dc/terms/1.1/"
  84. xmlns:foaf="http://xmlns.com/foaf/0.1/"
  85. xmlns:geos="http://www.opengis.net/ont/geosparql#"
  86. xmlns:owl="http://www.w3.org/2002/07/owl#"
  87. xmlns:poi="http://www.openvoc.eu/poi#"
  88. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  89. xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  90. xmlns:sf="http://www.opengis.net/ont/sf#"
  91. xmlns:skos="http://www.w3.org/2004/02/skos/core#">
  92. ');
  93. // read xml
  94. $xml = new SimpleXMLElement($contents);
  95. $value = $xml->Document->Folder->Placemark;
  96. // memory usage
  97. echo 'Memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB<br>";
  98. $long;
  99. $lat;
  100. $label;
  101. $source = "ENCW";
  102. foreach($value as $coord) {
  103. $feature_type = "";
  104. $name = $coord -> name;
  105. $watlev = "";
  106. $depth = "";
  107. $chart = "";
  108. $value2 = $coord->ExtendedData->SchemaData->SimpleData;
  109. foreach($value2 as $coord2) {
  110. if($coord2['name'] == "feature_type"){
  111. $label = $coord2;
  112. }
  113. if($coord2['name'] == "latdec"){
  114. $lat = $coord2;
  115. }
  116. if($coord2['name'] == "londec"){
  117. $long = $coord2;
  118. }
  119. if($coord2['name'] == "watlev"){
  120. $watlev = $coord2;
  121. }
  122. if($coord2['name'] == "depth"){
  123. $depth = $coord2;
  124. }
  125. if($coord2['name'] == "chart"){
  126. $chart = $coord2;
  127. }
  128. if($coord2['name'] == "feature_type"){
  129. $feature_type = $coord2;
  130. }
  131. }
  132. if(substr($label, 0, 6) == "Wrecks"){
  133. $label = substr($label, 7);
  134. $label = 'Wreck '.$label;
  135. }
  136. fwrite($soubor, ' <rdf:Description rdf:about="http://www.sdi4apps.eu/poi/#'.$source.''.$name.'">');
  137. fwrite($soubor, "\r\n");
  138. if($feature_type != ""){
  139. fwrite($soubor, ' <rdfs:label xml:lang="en">'.$label.'</rdfs:label>');
  140. fwrite($soubor, "\r\n");
  141. }
  142. else{
  143. fwrite($soubor, ' <rdfs:label xml:lang="en">Wrecks</rdfs:label>');
  144. fwrite($soubor, "\r\n");
  145. }
  146. fwrite($soubor, ' <geos:asWKT rdf:datatype="http://www.openlinksw.com/schemas/virtrdf#Geometry">POINT('.$long.' '.$lat.')</geos:asWKT>');
  147. fwrite($soubor, "\r\n");
  148. fwrite($soubor, ' <poi:class rdf:resource="http://gis.zcu.cz/SPOI/Ontology#outdoor"/>');
  149. fwrite($soubor, "\r\n");
  150. fwrite($soubor, ' <geos:sfWithin rdf:resource="http://dbpedia.org/resource/United_States"/>');
  151. fwrite($soubor, "\r\n");
  152. fwrite($soubor, ' <geos:sfWithin rdf:resource="http://www.geonames.org/6252001"/>');
  153. fwrite($soubor, "\r\n");
  154. if($depth != ""){
  155. fwrite($soubor, ' <rdfs:comment xml:lang="en">Depth: '.$depth.' m</rdfs:comment>');
  156. fwrite($soubor, "\r\n");
  157. }
  158. if($watlev != ""){
  159. fwrite($soubor, ' <rdfs:comment xml:lang="en">Water Level Effect: '.$watlev.'</rdfs:comment>');
  160. fwrite($soubor, "\r\n");
  161. }
  162. if($chart != ""){
  163. fwrite($soubor, ' <rdfs:comment xml:lang="en">Chart: '.$chart.'</rdfs:comment>');
  164. fwrite($soubor, "\r\n");
  165. }
  166. fwrite($soubor, ' <dc:identifier rdf:resource="http://www.sdi4apps.eu/poi/#'.$source.''.$name.'"/>');
  167. fwrite($soubor, "\r\n");
  168. fwrite($soubor, ' <dc:publisher>SPOI (http://sdi4apps.eu/spoi)</dc:publisher>');
  169. fwrite($soubor, "\r\n");
  170. if($feature_type != ""){
  171. fwrite($soubor, ' <dc:title xml:lang="en">'.$label.'</dc:title>');
  172. fwrite($soubor, "\r\n");
  173. }
  174. else{
  175. fwrite($soubor, ' <dc:title xml:lang="en">Wrecks</dc:title>');
  176. fwrite($soubor, "\r\n");
  177. }
  178. fwrite($soubor, ' <dc:rights rdf:resource="http://opendatacommons.org/licenses/odbl/1.0/"/>');
  179. fwrite($soubor, "\r\n");
  180. fwrite($soubor, ' <dc:source rdf:resource="http://www.nauticalcharts.noaa.gov/"/> ');
  181. fwrite($soubor, "\r\n");
  182. $date = getdate();
  183. fwrite($soubor, ' <dcterms:created rdf:datatype="http://www.w3.org/2001/XMLSchema#date">'.$date['year']."-".$date['mon']."-".$date['mday'].'</dcterms:created>');
  184. fwrite($soubor, "\r\n");
  185. fwrite($soubor, ' </rdf:Description>');
  186. fwrite($soubor, "\r\n");
  187. }
  188. fwrite($soubor, "</rdf:RDF>");
  189. fclose($soubor);
  190. // delete downloaded kml
  191. unlink('ENC_Wrecks.kml');
  192. // link to download rdf
  193. echo '<a href="ENC_Wrecks.rdf" target="_blank">Download RDF file</a>';
  194. // filesize of rdf
  195. $filesize = filesize("ENC_Wrecks.rdf");
  196. echo " (".format_size($filesize).")<br>";
  197. }
  198. ////////////////////////////////////////////////////////////////////////////////////////////////////// AWOIS Wrecks
  199. function awois_wrecks(){
  200. file_put_contents("AWOIS_Wrecks.kml", fopen("http://wrecks.nauticalcharts.noaa.gov/downloads/AWOIS_Wrecks.kml", 'r'));
  201. echo "<br><br>AWOIS Wrecks<br>";
  202. // filesize of downloaded archive
  203. $filesize = filesize("AWOIS_Wrecks.kml");
  204. echo "Kml file size: ".format_size($filesize)."<br>";
  205. $contents = file_get_contents('AWOIS_Wrecks.kml');
  206. // create rdf
  207. $soubor = fopen("AWOIS_Wrecks.rdf", "w");
  208. // write head of rdf
  209. fwrite($soubor, '<?xml version="1.0" encoding="utf-8"?');
  210. fwrite($soubor, ">\r\n");
  211. fwrite($soubor, '<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/"
  212. xmlns:dcterms="http://purl.org/dc/terms/1.1/"
  213. xmlns:foaf="http://xmlns.com/foaf/0.1/"
  214. xmlns:geos="http://www.opengis.net/ont/geosparql#"
  215. xmlns:owl="http://www.w3.org/2002/07/owl#"
  216. xmlns:poi="http://www.openvoc.eu/poi#"
  217. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  218. xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  219. xmlns:sf="http://www.opengis.net/ont/sf#"
  220. xmlns:skos="http://www.w3.org/2004/02/skos/core#">
  221. ');
  222. // read xml
  223. $xml = new SimpleXMLElement($contents);
  224. $value = $xml->Document->Folder->Placemark;
  225. // memory usage
  226. echo 'Memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB<br>";
  227. $long;
  228. $lat;
  229. $label;
  230. $source = "AWOISW";
  231. foreach($value as $coord) {
  232. $vesslterm = "";
  233. $depth = "";
  234. $yearsunk = "";
  235. $feature_type = "";
  236. $name= $coord->name;
  237. $value2 = $coord->description;
  238. $unit = "";
  239. $vessltermexist = true;
  240. $DOM = new DOMDocument;
  241. @ $DOM->loadHTML($value2);
  242. $items = $DOM->getElementsByTagName('td');
  243. $vesslterm = $items->item(1)->nodeValue;
  244. $feature_type = $items->item(2)->nodeValue;
  245. $lat = $items->item(3)->nodeValue;
  246. $long = $items->item(4)->nodeValue;
  247. $depth = $items->item(6)->nodeValue;
  248. $unit = $items->item(7)->nodeValue;
  249. $yearsunk = $items->item(8)->nodeValue;
  250. $wreck = true;
  251. fwrite($soubor, ' <rdf:Description rdf:about="http://www.sdi4apps.eu/poi/#'.$source.''.$name.'">');
  252. fwrite($soubor, "\r\n");
  253. if($vesslterm == "UNKNOWN" OR $vesslterm == ""){
  254. $vessltermexist = false;
  255. if($feature_type != "Not Charted"){
  256. $wreck = false;
  257. fwrite($soubor, ' <rdfs:label xml:lang="en">'.$feature_type.'</rdfs:label>');
  258. fwrite($soubor, "\r\n");
  259. }
  260. else{
  261. $wreck = false;
  262. fwrite($soubor, ' <rdfs:label xml:lang="en">Wreck</rdfs:label>');
  263. fwrite($soubor, "\r\n");
  264. }
  265. }
  266. else{
  267. fwrite($soubor, ' <rdfs:label xml:lang="en">'.$vesslterm.'</rdfs:label>');
  268. fwrite($soubor, "\r\n");
  269. }
  270. fwrite($soubor, ' <geos:asWKT rdf:datatype="http://www.openlinksw.com/schemas/virtrdf#Geometry">POINT('.$long.' '.$lat.')</geos:asWKT>');
  271. fwrite($soubor, "\r\n");
  272. fwrite($soubor, ' <poi:class rdf:resource="http://gis.zcu.cz/SPOI/Ontology#outdoor"/>');
  273. fwrite($soubor, "\r\n");
  274. fwrite($soubor, ' <geos:sfWithin rdf:resource="http://dbpedia.org/resource/United_States"/>');
  275. fwrite($soubor, "\r\n");
  276. fwrite($soubor, ' <geos:sfWithin rdf:resource="http://www.geonames.org/6252001"/>');
  277. fwrite($soubor, "\r\n");
  278. if($wreck == false){
  279. }
  280. else if($feature_type != "Not Charted" AND $feature_type != "" AND $wreck == true){
  281. fwrite($soubor, ' <rdfs:comment xml:lang="en">'.$feature_type.'</rdfs:comment>');
  282. fwrite($soubor, "\r\n");
  283. }
  284. else{
  285. fwrite($soubor, ' <rdfs:comment xml:lang="en">Wreck</rdfs:comment>');
  286. fwrite($soubor, "\r\n");
  287. }
  288. if($depth != ""){
  289. fwrite($soubor, ' <rdfs:comment xml:lang="en">Depth: '.$depth.' ');
  290. if($unit != ""){
  291. if($unit == "Feet and tenths"){
  292. fwrite($soubor, 'ft</rdfs:comment>');
  293. fwrite($soubor, "\r\n");
  294. }
  295. else if($unit == "Meters and tenths"){
  296. fwrite($soubor, 'm</rdfs:comment>');
  297. fwrite($soubor, "\r\n");
  298. }
  299. else if($unit == "Fathoms and tenths"){
  300. fwrite($soubor, 'fathoms</rdfs:comment>');
  301. fwrite($soubor, "\r\n");
  302. }
  303. else{
  304. fwrite($soubor, $unit.'</rdfs:comment>');
  305. fwrite($soubor, "\r\n");
  306. }
  307. }
  308. else{
  309. fwrite($soubor, 'm</rdfs:comment>');
  310. fwrite($soubor, "\r\n");
  311. }
  312. }
  313. if($yearsunk != ""){
  314. fwrite($soubor, ' <rdfs:comment xml:lang="en">Year Sunk: '.$yearsunk.'</rdfs:comment>');
  315. fwrite($soubor, "\r\n");
  316. }
  317. fwrite($soubor, ' <dc:identifier rdf:resource="http://www.sdi4apps.eu/poi/#'.$source.''.$name.'"/>');
  318. fwrite($soubor, "\r\n");
  319. fwrite($soubor, ' <dc:publisher>SPOI (http://sdi4apps.eu/spoi)</dc:publisher>');
  320. fwrite($soubor, "\r\n");
  321. if($vesslterm == "UNKNOWN" OR $vesslterm == ""){
  322. $vessltermexist = false;
  323. if($feature_type != "Not Charted"){
  324. fwrite($soubor, ' <dc:title xml:lang="en">'.$feature_type.'</dc:title>');
  325. fwrite($soubor, "\r\n");
  326. }
  327. else{
  328. fwrite($soubor, ' <dc:title xml:lang="en">Wreck</dc:title>');
  329. fwrite($soubor, "\r\n");
  330. }
  331. }
  332. else{
  333. fwrite($soubor, ' <dc:title xml:lang="en">'.$vesslterm.'</dc:title>');
  334. fwrite($soubor, "\r\n");
  335. }
  336. fwrite($soubor, ' <dc:rights rdf:resource="http://opendatacommons.org/licenses/odbl/1.0/"/>');
  337. fwrite($soubor, "\r\n");
  338. fwrite($soubor, ' <dc:source rdf:resource="http://www.nauticalcharts.noaa.gov/"/> ');
  339. fwrite($soubor, "\r\n");
  340. $date = getdate();
  341. fwrite($soubor, ' <dcterms:created rdf:datatype="http://www.w3.org/2001/XMLSchema#date">'.$date['year']."-".$date['mon']."-".$date['mday'].'</dcterms:created>');
  342. fwrite($soubor, "\r\n");
  343. fwrite($soubor, ' </rdf:Description>');
  344. fwrite($soubor, "\r\n");
  345. }
  346. fwrite($soubor, "</rdf:RDF>");
  347. fclose($soubor);
  348. // delete downloaded kml
  349. unlink('AWOIS_Wrecks.kml');
  350. // link to download rdf
  351. echo '<a href="AWOIS_Wrecks.rdf" target="_blank">Download RDF file</a>';
  352. // filesize of rdf
  353. $filesize = filesize("AWOIS_Wrecks.rdf");
  354. echo " (".format_size($filesize).")<br>";
  355. }
  356. ////////////////////////////////////////////////////////////////////////////////////////////////////// AWOIS Obstructions
  357. function awois_obstructions(){
  358. file_put_contents("AWOIS_Obscructions.kml", fopen("http://wrecks.nauticalcharts.noaa.gov/downloads/AWOIS_Obstructions.kml", 'r'));
  359. echo "<br><br>AWOIS Obscructions<br>";
  360. // filesize of downloaded archive
  361. $filesize = filesize("AWOIS_Obscructions.kml");
  362. echo "Kml file size: ".format_size($filesize)."<br>";
  363. $contents = file_get_contents('AWOIS_Obscructions.kml');
  364. // create rdf file
  365. $soubor = fopen("AWOIS_Obscructions.rdf", "w");
  366. // write head of rdf
  367. fwrite($soubor, '<?xml version="1.0" encoding="utf-8"?');
  368. fwrite($soubor, ">\r\n");
  369. fwrite($soubor, '<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/"
  370. xmlns:dcterms="http://purl.org/dc/terms/1.1/"
  371. xmlns:foaf="http://xmlns.com/foaf/0.1/"
  372. xmlns:geos="http://www.opengis.net/ont/geosparql#"
  373. xmlns:owl="http://www.w3.org/2002/07/owl#"
  374. xmlns:poi="http://www.openvoc.eu/poi#"
  375. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  376. xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  377. xmlns:sf="http://www.opengis.net/ont/sf#"
  378. xmlns:skos="http://www.w3.org/2004/02/skos/core#">
  379. ');
  380. // read xml
  381. $xml = new SimpleXMLElement($contents);
  382. $value = $xml->Document->Folder->Placemark;
  383. echo 'Memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB<br>";
  384. $long;
  385. $lat;
  386. $label;
  387. $source = "AWOISO";
  388. foreach($value as $coord) {
  389. $depth = "";
  390. $yearsunk = "";
  391. $feature_type = "";
  392. $name= $coord->name;
  393. $value2 = $coord->description;
  394. $unit = "";
  395. $DOM = new DOMDocument;
  396. @ $DOM->loadHTML($value2);
  397. $items = $DOM->getElementsByTagName('td');
  398. $vesslterm = $items->item(1)->nodeValue;
  399. $feature_type = $items->item(2)->nodeValue;
  400. $lat = $items->item(3)->nodeValue;
  401. $long = $items->item(4)->nodeValue;
  402. $depth = $items->item(6)->nodeValue;
  403. $unit = $items->item(7)->nodeValue;
  404. $yearsunk = $items->item(8)->nodeValue;
  405. fwrite($soubor, ' <rdf:Description rdf:about="http://www.sdi4apps.eu/poi/#'.$source.''.$name.'">');
  406. fwrite($soubor, "\r\n");
  407. if($feature_type != "Not Charted" AND $feature_type != ""){
  408. fwrite($soubor, ' <rdfs:label xml:lang="en">'.$feature_type.'</rdfs:label>');
  409. fwrite($soubor, "\r\n");
  410. }
  411. else{
  412. fwrite($soubor, ' <rdfs:label xml:lang="en">Obstruction</rdfs:label>');
  413. fwrite($soubor, "\r\n");
  414. }
  415. fwrite($soubor, ' <geos:asWKT rdf:datatype="http://www.openlinksw.com/schemas/virtrdf#Geometry">POINT('.$long.' '.$lat.')</geos:asWKT>');
  416. fwrite($soubor, "\r\n");
  417. fwrite($soubor, ' <poi:class rdf:resource="http://gis.zcu.cz/SPOI/Ontology#outdoor"/>');
  418. fwrite($soubor, "\r\n");
  419. fwrite($soubor, ' <geos:sfWithin rdf:resource="http://dbpedia.org/resource/United_States"/>');
  420. fwrite($soubor, "\r\n");
  421. fwrite($soubor, ' <geos:sfWithin rdf:resource="http://www.geonames.org/6252001"/>');
  422. fwrite($soubor, "\r\n");
  423. if($depth != ""){
  424. fwrite($soubor, ' <rdfs:comment xml:lang="en">Depth: '.$depth.' ');
  425. if($unit != ""){
  426. if($unit == "Feet and tenths"){
  427. fwrite($soubor, 'ft</rdfs:comment>');
  428. fwrite($soubor, "\r\n");
  429. }
  430. else if($unit == "Meters and tenths"){
  431. fwrite($soubor, 'm</rdfs:comment>');
  432. fwrite($soubor, "\r\n");
  433. }
  434. else if($unit == "Fathoms and tenths"){
  435. fwrite($soubor, 'fathoms</rdfs:comment>');
  436. fwrite($soubor, "\r\n");
  437. }
  438. else{
  439. fwrite($soubor, $unit.'</rdfs:comment>');
  440. fwrite($soubor, "\r\n");
  441. }
  442. }
  443. else{
  444. fwrite($soubor, 'm</rdfs:comment>');
  445. fwrite($soubor, "\r\n");
  446. }
  447. }
  448. if($yearsunk != ""){
  449. fwrite($soubor, ' <rdfs:comment xml:lang="en">Year Sunk: '.$yearsunk.'</rdfs:comment>');
  450. fwrite($soubor, "\r\n");
  451. }
  452. fwrite($soubor, ' <dc:identifier rdf:resource="http://www.sdi4apps.eu/poi/#'.$source.''.$name.'"/>');
  453. fwrite($soubor, "\r\n");
  454. fwrite($soubor, ' <dc:publisher>SPOI (http://sdi4apps.eu/spoi)</dc:publisher>');
  455. fwrite($soubor, "\r\n");
  456. if($feature_type != "Not Charted" AND $feature_type != ""){
  457. fwrite($soubor, ' <dc:title xml:lang="en">'.$feature_type.'</dc:title>');
  458. fwrite($soubor, "\r\n");
  459. }
  460. else{
  461. fwrite($soubor, ' <dc:title xml:lang="en">Obstruction</dc:title>');
  462. fwrite($soubor, "\r\n");
  463. }
  464. fwrite($soubor, ' <dc:rights rdf:resource="http://opendatacommons.org/licenses/odbl/1.0/"/>');
  465. fwrite($soubor, "\r\n");
  466. fwrite($soubor, ' <dc:source rdf:resource="http://www.nauticalcharts.noaa.gov/"/> ');
  467. fwrite($soubor, "\r\n");
  468. $date = getdate();
  469. fwrite($soubor, ' <dcterms:created rdf:datatype="http://www.w3.org/2001/XMLSchema#date">'.$date['year']."-".$date['mon']."-".$date['mday'].'</dcterms:created>');
  470. fwrite($soubor, "\r\n");
  471. fwrite($soubor, ' </rdf:Description>');
  472. fwrite($soubor, "\r\n");
  473. }
  474. fwrite($soubor, "</rdf:RDF>");
  475. fclose($soubor);
  476. // delete downloaded kml
  477. unlink('AWOIS_Obscructions.kml');
  478. // link to download rdf
  479. echo '<a href="AWOIS_Obscructions.rdf" target="_blank">Download RDF file</a>';
  480. // filesize of rdf
  481. $filesize = filesize("AWOIS_Obscructions.rdf");
  482. echo " (".format_size($filesize).")<br>";
  483. }
  484. // filesize function
  485. function format_size($size) {
  486. $sizes = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
  487. if ($size == 0) { return('n/a'); } else {
  488. return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]); }
  489. }
  490. ?>