Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// minX = -122.4565;
// minY = 37.756;
// maxX = -122.451;
// maxY = 37.761;
var min = [minX, minY];
var max = [maxX, maxY];
// project request coordinates into data coordinates
if (mapProjection !== this._projection) {
min = projector.project.Point(mapProjection, this._projection, min);
max = projector.project.Point(mapProjection, this._projection, max);
// console.log(min,max);
}
pg.connect(this._connectionString, function(err, client) { // Switched method signature... WTF?!
if (err) { console.error(err); return callback(err, null); }
// console.log("Loading features...");
var start, query;
start = Date.now();
if (this._attrFields) {
query = "SELECT ST_AsGeoJson("+this._geomField+") as geometry, "+this._attrFields+" FROM "+this._tableName+" WHERE "+this._geomField+" && ST_MakeEnvelope($1,$2,$3,$4);";
}
else {
query = "SELECT ST_AsGeoJson("+this._geomField+") as geometry,* FROM "+this._tableName+" WHERE "+this._geomField+" && ST_MakeEnvelope($1,$2,$3,$4);";
}
// console.log("Querying... "+query+" "+min+", "+max);
client.query(query, [min[0], min[1], max[0], max[1]], function(err, result) {
if (err) { return callback(err, null); }
// console.log("Loaded in " + (Date.now() - start) + "ms");
run (query, params, callback) {
Pg.connect(this.connectionString, (err, client, done) => {
if (err) {
return callback(err);
}
client.query(query, params, (err, result) => {
done(); // releases client
callback(err, result);
});
});
}
run (query, params, callback) {
Pg.connect(this.config.pg, (err, client, done) => {
if (err) {
return callback(err);
}
client.query(query, params, (err, result) => {
done(); // releases client
callback(err, result);
});
});
}
}
var execute = function(query, args, callback) {
pg.connect(conString, function(err, client, done) {
if (err) {
console.log(err);
return callback(err);
}
client.query(query, args, function(err, result) {
done();
if (err)
console.log(err);
callback(err, result);
});
});
};