Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'develop' of github.com:Vizzuality/cartodb into develop
  • Loading branch information
tokumine committed Apr 12, 2012
2 parents 17e2f35 + 44dabae commit fd6e99a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 34 deletions.
16 changes: 14 additions & 2 deletions lib/importer/lib/cartodb-importer/loaders/shp.rb
Expand Up @@ -56,6 +56,19 @@ def process!
unless (reg = stdout.read).empty?
@runlog.stdout << reg
end

begin
rows_imported = @db_connection["SELECT count(*) as count from \"#{random_table_name}\""].first[:count]
rescue
@data_import.set_error_code(3005)
@data_import.log_error(stdout.read)
@data_import.log_error(stderr.read)
@data_import.log_error("ERROR: failed to generate SQL from #{@path}")
raise "ERROR: failed to generate SQL from #{@path}"
end




# TODO: THIS SHOULD BE UPDATE IF NOT NULL TO PREVENT CRASHING
#debugger
Expand All @@ -81,7 +94,7 @@ def process!
# TODO: We need to move this out of all loader methods and into the importer.rb method
column_names = @db_connection.schema(random_table_name).map{ |s| s[0].to_s }
need_sanitizing = column_names.each do |column_name|
debugger

if column_name != column_name.sanitize_column_name
@db_connection.run("ALTER TABLE #{random_table_name} RENAME COLUMN \"#{column_name}\" TO #{column_name.sanitize_column_name}")
end
Expand Down Expand Up @@ -123,7 +136,6 @@ def process!
end

@entries.each{ |e| FileUtils.rm_rf(e) } if @entries.any?
rows_imported = @db_connection["SELECT count(*) as count from \"#{@suggested_name}\""].first[:count]
@import_from_file.unlink

@data_import.save
Expand Down
4 changes: 2 additions & 2 deletions public/javascripts/admin/index/import.js
Expand Up @@ -121,7 +121,7 @@
element: document.getElementById('uploader'),
action: '/upload',
params: {},
allowedExtensions: ['csv', 'xls', 'xlsx', 'zip', 'kml', 'geojson', 'json', 'ods', 'kmz', 'gpx', 'tar', 'gz', 'tgz', 'osm', 'bz2'],
allowedExtensions: ['csv', 'xls', 'xlsx', 'zip', 'kml', 'geojson', 'json', 'ods', 'kmz', 'gpx', 'tar', 'gz', 'tgz', 'osm', 'bz2', 'tif', 'tiff'],
sizeLimit: 0, // max size
minSizeLimit: 0, // min size
debug: false,
Expand Down Expand Up @@ -151,7 +151,7 @@
element: document.getElementById('hugeUploader'),
action: '/upload',
params: {},
allowedExtensions: ['csv', 'xls', 'xlsx', 'zip', 'kml', 'geojson', 'json', 'ods', 'kmz', 'gpx', 'tar', 'gz', 'tgz', 'osm', 'bz2'],
allowedExtensions: ['csv', 'xls', 'xlsx', 'zip', 'kml', 'geojson', 'json', 'ods', 'kmz', 'gpx', 'tar', 'gz', 'tgz', 'osm', 'bz2', 'tif', 'tiff'],
sizeLimit: 0,
minSizeLimit: 0,
debug: false,
Expand Down
73 changes: 43 additions & 30 deletions public/javascripts/admin/show/map/carto_map.js
@@ -1,17 +1,17 @@

////////////////////////////////////////////////////////////////////////////////
// //
// CLASS TO MANAGE ALL THE STUFF IN THE MAP (variable -> carto_map) //
// Actually, this is map of the application, and everything that //
// occurs on/over/with/in the map will be manage here. //
// //
// Overlays: //
// .selection_area_ //
// .info_window_ //
// .tooltip_ //
// .delete_windsow_ //
// .map_canvas_ //
// status -> (add_point,add_polygon,add_polyline,selection,select) //
// //
// CLASS TO MANAGE ALL THE STUFF IN THE MAP (variable -> carto_map) //
// Actually, this is map of the application, and everything that //
// occurs on/over/with/in the map will be manage here. //
// //
// Overlays: //
// .selection_area_ //
// .info_window_ //
// .tooltip_ //
// .delete_windsow_ //
// .map_canvas_ //
// status -> (add_point,add_polygon,add_polyline,selection,select) //
// //
////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -712,29 +712,42 @@
success: function(data) {

if (data.rows[0].st_extent!=null) {

// TODO: make this code more widely available (pgis->gmaps bounds) -- {

var coordinates = data.rows[0].st_extent.replace('BOX(','').replace(')','').split(',');

var coor1 = coordinates[0].split(' ');
var coor2 = coordinates[1].split(' ');
var bounds = new google.maps.LatLngBounds();


var lon0 = coor1[0];
var lat0 = coor1[1];
var lon1 = coor2[0];
var lat1 = coor2[1];

// Check bounds
if (coor1[0] > 180
|| coor1[0] < -180
|| coor1[1] > 90
|| coor1[1] < -90
|| coor2[0] > 180
|| coor2[0] < -180
|| coor2[1] > 90
|| coor2[1] < -90) {
coor1[0] = '-30';
coor1[1] = '-50';
coor2[0] = '110';
coor2[1] = '80';

var minlat = -85.0511;
var maxlat = 85.0511;
var minlon = -179;
var maxlon = 179;

/* Clamp X to be between min and max (inclusive) */
var clampNum = function(x, min, max) {
return x < min ? min : x > max ? max : x;
}

bounds.extend(new google.maps.LatLng(coor1[1],coor1[0]));
bounds.extend(new google.maps.LatLng(coor2[1],coor2[0]));

lon0 = clampNum(lon0, minlon, maxlon);
lon1 = clampNum(lon1, minlon, maxlon);
lat0 = clampNum(lat0, minlat, maxlat);
lat1 = clampNum(lat1, minlat, maxlat);

var sw = new google.maps.LatLng(lat0, lon0);
var ne = new google.maps.LatLng(lat1, lon1);
var bounds = new google.maps.LatLngBounds(sw, ne);

// -- }


me.map_.fitBounds(bounds);

Expand Down

0 comments on commit fd6e99a

Please sign in to comment.