Skip to content

v0.2.54..v0.2.55 changeset PrintTDSCsv.js

Garret Voltz edited this page Aug 14, 2020 · 1 revision
diff --git a/translations/PrintTDSCsv.js b/translations/PrintTDSCsv.js
index 6e770da..86a585a 100644
--- a/translations/PrintTDSCsv.js
+++ b/translations/PrintTDSCsv.js
@@ -33,64 +33,64 @@
 */
 
 // Set the "require" statements to what needs to be printed
-tds61 = {}
-hoot.require('tds61_schema')
+tds61 = {};
+hoot.require('tds61_schema');
 
 // tds40 = {}
 // hoot.require('tds40.schema')
 
-hoot.require('config')
+hoot.require('config');
 
 
 // The initialize function gets called once BEFORE the translateToXXX functions
 // We are hijacking this function to print out documentation
 function initialize()
 {
-    var tagList = {} // Final list of tags
+  var tagList = {}; // Final list of tags
 
-    // Change the Schema as well
-    // var schema = tds40.schema.getDbSchema();
-    var schema = tds61.schema.getDbSchema();
+  // Change the Schema as well
+  // var schema = tds40.schema.getDbSchema();
+  var schema = tds61.schema.getDbSchema();
     
-    // Print the tagList
-    switch (config.getTagPrintingFormat())
-    {
-//         case 'html':
-//             dumpHtmlTags(tagList);
-//             break;
-//
-//         case 'asciidoc':
-//             dumpAsciidocTags(tagList);
-//             break;
-//
-//         case 'json':
-//             dumpJsonTags(tagList);
-//             break;
-//
-//         case 'redmine':
-//             dumpRedmineTags(tagList);
-//             break;
-//
-        case 'csv':
-        default:
-            dumpCsvTags(schema);
-            break;
-    }
-
-    return null;
+  // Print the tagList
+  switch (config.getTagPrintingFormat())
+  {
+  //         case 'html':
+  //             dumpHtmlTags(tagList);
+  //             break;
+  //
+  //         case 'asciidoc':
+  //             dumpAsciidocTags(tagList);
+  //             break;
+  //
+  //         case 'json':
+  //             dumpJsonTags(tagList);
+  //             break;
+  //
+  //         case 'redmine':
+  //             dumpRedmineTags(tagList);
+  //             break;
+  //
+  case 'csv':
+  default:
+    dumpCsvTags(schema);
+    break;
+  }
+
+  return null;
 } // end Initialize
 
 // The finalize function gets called once AFTER the translateToXXX functions
 function finalize()
 {
-    // print('In the finalize function');
+  // print('In the finalize function');
 }
 
 
 // We are not using this any more.
 function translateToOsm(attrs, layerName, geometryType)
 { 
-    return null;
+  return null;
 }
 
 
@@ -102,64 +102,64 @@ function createLookup(tagList, schema)
 // Dump the tagList out in HTML format.
 function dumpHtmlTags(tagList)
 {
-    var desc = '';
-    var shortTag = '';
-    var source = '';
-    var tag = '';
-    var val = '';
-    var value = '';
-
-    var shortKeys = Object.keys(tagList);
-    shortKeys.sort();
-
-    // Start the HTML document
-    print('<html>');
-    print('<head>');
-    print('<title>Hootennanny OSM+ Tags</title>');
-    print('</head>');
-    print('<style>');
-    print('table,th,td { border:1px solid black; border-collapse:collapse; padding-left:5px; padding-right:5px; }');
-    print('caption { text-align:left; font-weight:bold;}');
-    print('</style>');
-    print('<body>');
-    print('<h2 align=center>Hootennanny OSM+ Tags</h2>');
-    print('<p>Generated: ' + Date() + '</p>');
-
-    for (var i = 0, tlen = shortKeys.length; i < tlen; i++)
+  var desc = '';
+  var shortTag = '';
+  var source = '';
+  var tag = '';
+  var val = '';
+  var value = '';
+
+  var shortKeys = Object.keys(tagList);
+  shortKeys.sort();
+
+  // Start the HTML document
+  print('<html>');
+  print('<head>');
+  print('<title>Hootennanny OSM+ Tags</title>');
+  print('</head>');
+  print('<style>');
+  print('table,th,td { border:1px solid black; border-collapse:collapse; padding-left:5px; padding-right:5px; }');
+  print('caption { text-align:left; font-weight:bold;}');
+  print('</style>');
+  print('<body>');
+  print('<h2 align=center>Hootennanny OSM+ Tags</h2>');
+  print('<p>Generated: ' + Date() + '</p>');
+
+  for (var i = 0, tlen = shortKeys.length; i < tlen; i++)
+  {
+    shortTag = shortKeys[i];
+
+    print('<table>');
+    print('<caption>' + shortTag + '<caption>');
+    print('<tr>');
+    print('<th>Key</th><th>Value</th><th>Comment</th><th>Source</th>');
+    print('</tr>');
+
+    var extraKeys = Object.keys(tagList[shortTag]);
+    extraKeys.sort();
+
+    for (var j = 0, elen = extraKeys.length; j < elen; j++)
     {
-        shortTag = shortKeys[i];
-
-        print('<table>');
-        print('<caption>' + shortTag + '<caption>');
-        print('<tr>');
-        print('<th>Key</th><th>Value</th><th>Comment</th><th>Source</th>');
-        print('</tr>');
-
-        var extraKeys = Object.keys(tagList[shortTag]);
-        extraKeys.sort();
+      val = extraKeys[j];
 
-        for (var j = 0, elen = extraKeys.length; j < elen; j++)
-        {
-            val = extraKeys[j];
-
-            // Just to make things a bit clearer while building the print statement
-            desc = tagList[shortTag][val]['desc'];
-            source = tagList[shortTag][val]['src'];
-            tag = tagList[shortTag][val]['tag'];
-            value = tagList[shortTag][val]['value'];
+      // Just to make things a bit clearer while building the print statement
+      desc = tagList[shortTag][val]['desc'];
+      source = tagList[shortTag][val]['src'];
+      tag = tagList[shortTag][val]['tag'];
+      value = tagList[shortTag][val]['value'];
 
-            print('<tr>');
-            print('<td>' + tag + '</td><td>' + value + '</td><td>' + desc + '</td><td>' + source + '</td>');
-            print('</tr>');
-        }
-        print('</table>');
-        print('<br>');
-        print('<br>');
+      print('<tr>');
+      print('<td>' + tag + '</td><td>' + value + '</td><td>' + desc + '</td><td>' + source + '</td>');
+      print('</tr>');
     }
+    print('</table>');
+    print('<br>');
+    print('<br>');
+  }
 
-    // End the HTML document
-    print('</body>');
-    print('</html>');
+  // End the HTML document
+  print('</body>');
+  print('</html>');
 
 } // End dumpHtmlTags
 
@@ -167,142 +167,142 @@ function dumpHtmlTags(tagList)
 // Dump the tagList out in asciidoc format.
 function dumpAsciidocTags(tagList)
 {
-    var desc = '';
-    var shortTag = '';
-    var source = '';
-    var tag = '';
-    var val = '';
-    var value = '';
-
-    var shortKeys = Object.keys(tagList);
-    shortKeys.sort();
-
-    print('Hootennanny OSM+ Tags');
-    print('=====================');
-    print('Generated: ' + Date());
-    print('');
-
-    for (var i = 0, tlen = shortKeys.length; i < tlen; i++)
+  var desc = '';
+  var shortTag = '';
+  var source = '';
+  var tag = '';
+  var val = '';
+  var value = '';
+
+  var shortKeys = Object.keys(tagList);
+  shortKeys.sort();
+
+  print('Hootennanny OSM+ Tags');
+  print('=====================');
+  print('Generated: ' + Date());
+  print('');
+
+  for (var i = 0, tlen = shortKeys.length; i < tlen; i++)
+  {
+    shortTag = shortKeys[i];
+
+    // print('.An ' + shortTag);
+    print('.' + shortTag);
+    print('[options="header"]');
+    print('|==========');
+    print('| Key | Value | Comment | Source');
+
+    var extraKeys = Object.keys(tagList[shortTag]);
+    extraKeys.sort();
+
+    for (var j = 0, elen = extraKeys.length; j < elen; j++)
     {
-        shortTag = shortKeys[i];
+      val = extraKeys[j];
 
-        // print('.An ' + shortTag);
-        print('.' + shortTag);
-        print('[options="header"]');
-        print('|==========');
-        print('| Key | Value | Comment | Source');
+      // Just to make things a bit clearer while building the print statement
+      desc = tagList[shortTag][val]['desc'];
+      source = tagList[shortTag][val]['src'];
+      tag = tagList[shortTag][val]['tag'];
+      value = tagList[shortTag][val]['value'];
 
-        var extraKeys = Object.keys(tagList[shortTag]);
-        extraKeys.sort();
-
-        for (var j = 0, elen = extraKeys.length; j < elen; j++)
-        {
-            val = extraKeys[j];
-
-            // Just to make things a bit clearer while building the print statement
-            desc = tagList[shortTag][val]['desc'];
-            source = tagList[shortTag][val]['src'];
-            tag = tagList[shortTag][val]['tag'];
-            value = tagList[shortTag][val]['value'];
-
-            print('| ' + tag + ' | ' + value + ' | ' + desc + ' | ' + source);
-        }
-
-        print('|==========');
-        print('');
-        print('');
+      print('| ' + tag + ' | ' + value + ' | ' + desc + ' | ' + source);
     }
 
+    print('|==========');
+    print('');
+    print('');
+  }
+
 } // End dumpAsciidocTags
 
 
 // Dump the tagList out in Redmine format.
 function dumpRedmineTags(tagList)
 {
-    var desc = '';
-    var shortTag = '';
-    var source = '';
-    var tag = '';
-    var val = '';
-    var value = '';
-
-    var shortKeys = Object.keys(tagList);
-    shortKeys.sort();
-
-    print('h1. Hootennanny OSM+ Tags');
-    print('');
-    print('Generated: ' + Date());
+  var desc = '';
+  var shortTag = '';
+  var source = '';
+  var tag = '';
+  var val = '';
+  var value = '';
+
+  var shortKeys = Object.keys(tagList);
+  shortKeys.sort();
+
+  print('h1. Hootennanny OSM+ Tags');
+  print('');
+  print('Generated: ' + Date());
+  print('');
+  print('----');
+  print('');
+
+  for (var i = 0, tlen = shortKeys.length; i < tlen; i++)
+  {
+    shortTag = shortKeys[i];
+
+    print('h2. ' + shortTag);
     print('');
-    print('----');
-    print('');
-
-    for (var i = 0, tlen = shortKeys.length; i < tlen; i++)
-    {
-        shortTag = shortKeys[i];
-
-        print('h2. ' + shortTag);
-        print('');
-        print('|_.Key| _.Value|_.Comment|_.Source|');
+    print('|_.Key| _.Value|_.Comment|_.Source|');
 
-        var extraKeys = Object.keys(tagList[shortTag]);
-        extraKeys.sort();
+    var extraKeys = Object.keys(tagList[shortTag]);
+    extraKeys.sort();
 
-        for (var j = 0, elen = extraKeys.length; j < elen; j++)
-        {
-            val = extraKeys[j];
-
-            // Just to make things a bit clearer while building the print statement
-            desc = tagList[shortTag][val]['desc'];
-            source = tagList[shortTag][val]['src'];
-            tag = tagList[shortTag][val]['tag'];
-            value = tagList[shortTag][val]['value'];
+    for (var j = 0, elen = extraKeys.length; j < elen; j++)
+    {
+      val = extraKeys[j];
 
-            print('| ' + tag + ' | ' + value + ' | ' + desc + ' | ' + source + ' |');
-        }
+      // Just to make things a bit clearer while building the print statement
+      desc = tagList[shortTag][val]['desc'];
+      source = tagList[shortTag][val]['src'];
+      tag = tagList[shortTag][val]['tag'];
+      value = tagList[shortTag][val]['value'];
 
-        print('');
-        print('----');
-        print('');
+      print('| ' + tag + ' | ' + value + ' | ' + desc + ' | ' + source + ' |');
     }
+
+    print('');
+    print('----');
+    print('');
+  }
 } // End dumpRedmineTags
 
 
 // Dump the tagList out as a Large Ugly JSON Blob.
 function dumpJsonTags(tagList)
 {
-    print('JSON format is not working yet');
-    print(tagList.toString());
+  print('JSON format is not working yet');
+  print(tagList.toString());
 } // End dumpJsonTags
 
 
 // Dump the schema out in CSV format.
 function dumpCsvTags(schema)
 {
-    print('"Feature","Tag","Value"');
+  print('"Feature","Tag","Value"');
         
-    for (var i = 0, iLen = schema.length; i < iLen; i++)
-    {
-        var fName = schema[i].name;
+  for (var i = 0, iLen = schema.length; i < iLen; i++)
+  {
+    var fName = schema[i].name;
         
-        for (var j = 0, jLen = schema[i].columns.length; j < jLen; j++)
-        {
-            var cName = schema[i].columns[j].desc;
+    for (var j = 0, jLen = schema[i].columns.length; j < jLen; j++)
+    {
+      var cName = schema[i].columns[j].desc;
             
-            if (cName == 'Feature Code') continue; // Skip the F_CODE
+      if (cName == 'Feature Code') continue; // Skip the F_CODE
             
-            if (schema[i].columns[j].type !== 'enumeration')
-            {
-                print('"' + fName + '","' + cName + '","Value"');
-            }
-            else
-            {
-                for (var k = 0, kLen = schema[i].columns[j].enumerations.length; k < kLen; k++)
-                {
-                    print('"' + fName + '","' + cName + '","' + schema[i].columns[j].enumerations[k].name + '"');
-                }
-            } 
-        } // End for j
-    } // End for i
+      if (schema[i].columns[j].type !== 'enumeration')
+      {
+        print('"' + fName + '","' + cName + '","Value"');
+      }
+      else
+      {
+        for (var k = 0, kLen = schema[i].columns[j].enumerations.length; k < kLen; k++)
+        {
+          print('"' + fName + '","' + cName + '","' + schema[i].columns[j].enumerations[k].name + '"');
+        }
+      } 
+    } // End for j
+  } // End for i
     
 } // End dumpCsvTags
 
Clone this wiki locally