Skip to content

Instantly share code, notes, and snippets.

@murindwaz
Forked from davidmcclure/gist:4163557
Created August 9, 2013 03:00
Show Gist options
  • Save murindwaz/6190858 to your computer and use it in GitHub Desktop.
Save murindwaz/6190858 to your computer and use it in GitHub Desktop.
var mysql = require('mysql');
var randy = require('randy');
var _ = require('underscore');
// Query base.
var sql = 'INSERT INTO omeka_neatline_records (' +
'exhibit_id,'+
'title,'+
'description,'+
'map_active,'+
'vector_color,'+
'stroke_color,'+
'select_color,'+
'point_radius,'+
'stroke_opacity,'+
'graphic_opacity,'+
'vector_opacity,'+
'select_opacity,'+
'stroke_width,'+
'min_zoom,'+
'max_zoom,'+
'coverage'+
') VALUES';
// Create records.
_(count).times(function(n) {
// Get random point coordinates and radius.
var lat = randy.randInt(-20000000,20000000);
var lon = randy.randInt(-20000000,20000000);
var geo = 'GeomFromText("POINT('+lon+' '+lat+')")';
var rad = randy.randInt(10,100);
// Values.
sql += '(' +
exhibit_id+','+
'"Record'+n+'",'+
'"Description'+n+'",'+
'1,'+
'"'+color+'",'+
'"#000000",'+
'"'+color+'",'+
rad+','+
100+','+
100+','+
30+','+
50+','+
2+','+
zoom+','+
zoom+','+
geo+
')';
// Comma, except for last.
if (n != count-1) sql += ',';
});
client.query(sql);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment