<commit_before>var pg = require("pg"),
    credentials = require("./credentials"),
    dbgeo = require("../lib/dbgeo");

var connString = "postgres://" + credentials.user + "@" + credentials.host + ":" + credentials.port + "/" + credentials.database,
    client = new pg.Client(connString);

// Connect to postgres
client.connect(function(error, success) {
  if (error) {
    console.log("Could not connect to postgres");
  }
});

/* Select two points, returning the geometry as a GeoJSON object in the field 'geometry' */
client.query("SELECT name, ST_AsGeoJSON(geom, 6) AS geometry FROM places LIMIT 2", function(error, result) {
  dbgeo.parse({
    "data": result.rows
  }, function(error, result) {
    if (error) {
      console.log("Test 1 --- error --- ", error);
    } else {
      console.log("Test 1 --- successful");
      //console.log(JSON.stringify(result));
    }
  });
});

/* Select two polygons, returning the geometry as a GeoJSON object in the field 'geom', then
   converting the result to TopoJSON */
client.query("SELECT name, ST_AsGeoJSON(geom, 6) AS geom FROM countries LIMIT 2", function(error, result) {
  dbgeo.parse({
    "data": result.rows,
    "geometryColumn": "geom",
    "outputFormat": "topojson"
  }, function(error, result) {
    if (error) {
      console.log("Test 2 --- error --- ", error);
    } else {
      console.log("Test 2 --- successful");
      //console.log(JSON.stringify(result));
    }
  });
});

/* Select two polygons, returning the geometry as WKT in the field 'wkt' */
client.query("SELECT name, ST_AsText(geom) AS wkt FROM countries LIMIT 2", function(error, result) {
  dbgeo.parse({
    "data": result.rows,
    "geometryColumn": "wkt",
    "geometryType": "wkt",
    "outputFormat": "geojson"
  }, function(error, result) {
    if (error) {
      console.log("Test 3 --- error --- ", error);
    } else {
      console.log("Test 3 --- successful");
     // console.log(JSON.stringify(result));
    }
  });
});

/* Select two points, returning a latitude and longitude for each */
client.query("SELECT name, latitude, longitude FROM places LIMIT 2", function(error, result) {
  dbgeo.parse({
    "data": result.rows,
    "geometryColumn": ["latitude", "longitude"],
    "geometryType": "ll"
  }, function(error, result) {
    if (error) {
      console.log("Test 4 --- error --- ", error);
    } else {
      console.log("Test 4 --- successful");
     // console.log(JSON.stringify(result));
    }
  });
  client.end();
});
<commit_msg>Add wkb test<commit_after>var pg = require("pg"),
    credentials = require("./credentials"),
    dbgeo = require("../lib/dbgeo");

var connString = "postgres://" + credentials.user + "@" + credentials.host + ":" + credentials.port + "/" + credentials.database,
    client = new pg.Client(connString);

// Connect to postgres
client.connect(function(error, success) {
  if (error) {
    console.log("Could not connect to postgres");
  }
});

/* Select two points, returning the geometry as a GeoJSON object in the field 'geometry' */
client.query("SELECT name, ST_AsGeoJSON(geom, 6) AS geometry FROM places LIMIT 2", function(error, result) {
  dbgeo.parse({
    "data": result.rows
  }, function(error, result) {
    if (error) {
      console.log("Test 1 --- error --- ", error);
    } else {
      console.log("Test 1 --- successful");
      //console.log(JSON.stringify(result));
    }
  });
});

/* Select two polygons, returning the geometry as a GeoJSON object in the field 'geom', then
   converting the result to TopoJSON */
client.query("SELECT name, ST_AsGeoJSON(geom, 6) AS geom FROM countries LIMIT 2", function(error, result) {
  dbgeo.parse({
    "data": result.rows,
    "geometryColumn": "geom",
    "outputFormat": "topojson"
  }, function(error, result) {
    if (error) {
      console.log("Test 2 --- error --- ", error);
    } else {
      console.log("Test 2 --- successful");
      //console.log(JSON.stringify(result));
    }
  });
});

/* Select two polygons, returning the geometry as WKT in the field 'wkt' */
client.query("SELECT name, ST_AsText(geom) AS wkt FROM countries LIMIT 2", function(error, result) {
  dbgeo.parse({
    "data": result.rows,
    "geometryColumn": "wkt",
    "geometryType": "wkt",
    "outputFormat": "geojson"
  }, function(error, result) {
    if (error) {
      console.log("Test 3 --- error --- ", error);
    } else {
      console.log("Test 3 --- successful");
     // console.log(JSON.stringify(result));
    }
  });
});

/* Select two points, returning a latitude and longitude for each */
client.query("SELECT name, latitude, longitude FROM places LIMIT 2", function(error, result) {
  dbgeo.parse({
    "data": result.rows,
    "geometryColumn": ["latitude", "longitude"],
    "geometryType": "ll"
  }, function(error, result) {
    if (error) {
      console.log("Test 4 --- error --- ", error);
    } else {
      console.log("Test 4 --- successful");
     // console.log(JSON.stringify(result));
    }
  });
  client.end();
});


/* Select two points and WKB geometry */
client.query("SELECT name, geom FROM places LIMIT 2", function(error, result) {
  dbgeo.parse({
    "data": result.rows,
    "geometryColumn": "geom",
    "geometryType": "wkb"
  }, function(error, result) {
    if (error) {
      console.log("Test 5 --- error --- ", error);
    } else {
      console.log("Test 5 --- successful");
     // console.log(JSON.stringify(result));
    }
  });
  client.end();
});
{'fraction_non_alphanumeric': 0.17410468319559227, 'fraction_numerical': 0.005693296602387512, 'mean_word_length': 3.058122205663189, 'pattern_counts': {'":': 27, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5723735', 'n_tokens_mistral': 1725, 'n_tokens_neox': 1681, 'n_words': 458}