# HG changeset patch # User Zoe Hong # Date 1435247231 -7200 # Node ID 30b59e7b88c0e539b3cabb8ecb7783dff0dba268 # Parent 6095925edcba0eb4997396a080aa734df6149ad5 add php error log diff -r 6095925edcba -r 30b59e7b88c0 .DS_Store Binary file .DS_Store has changed diff -r 6095925edcba -r 30b59e7b88c0 config/config.php --- a/config/config.php Thu Apr 23 16:13:07 2015 +0200 +++ b/config/config.php Thu Jun 25 17:47:11 2015 +0200 @@ -8,19 +8,19 @@ $mysql_server = "localhost"; $mysql_user = "root"; $mysql_password = "admin"; - $server_host = "http://localgazetteers-dev/"; - $lgserver_url = $server_host."LGServer/"; + $server_host = "http://localgazetteers.mpiwg-berlin.mpg.de/"; + $lgserver_url = $server_host."LGServices/"; } else { // localhost - $mysql_database = "Gazetteers"; + $mysql_database = "Gazetteer"; $mysql_server = "localhost"; $mysql_user = "root"; $mysql_password = "root"; $server_host = "http://localhost:1080/localgazetteers-dev/"; - $lgserver_url = "http://localgazetteers-dev/LGServer/"; - + //$lgserver_url = "http://localgazetteers-dev/LGServices/"; + $lgserver_url = "http://localhost:8080/LGServices/"; } $systemNAME = "interface"; diff -r 6095925edcba -r 30b59e7b88c0 get_coordinates_for_listed_books.php --- a/get_coordinates_for_listed_books.php Thu Apr 23 16:13:07 2015 +0200 +++ b/get_coordinates_for_listed_books.php Thu Jun 25 17:47:11 2015 +0200 @@ -19,43 +19,53 @@ function readCsvFile($fileName){ global $server_host; - $fp=fopen($server_host."LGSearch/csv_files/".$fileName,"r"); - $data=fgetcsv($fp); - $columnNameMappingArray=['BOOK_ID','LEVEL1','LEVEL2', - 'Name','PERIOD','TimeSpan:begin','TimeSpan:end','PAGE','SECTION','CONTENT', - 'Description']; //columns from input array/file - $columnNameArray=['Address','LEVEL1','LEVEL2', - 'Name','PERIOD','TimeSpan:begin','TimeSpan:end','Longitude','Latitude', - 'PAGE','SECTION','CONTENT', - 'BOOK_ID','CHGIS_ID','1820_ID','1911_ID','CBDB_ID','Description']; //columns for output array/file (for map.php) - /* - $columnNameArray=['Address','ADMIN_TYPE','LEVEL1','LEVEL2', - 'Name','PERIOD','TimeSpan:begin','TimeSpan:end','Longitude','Latitude', - 'PAGE','SECTION','CONTENT', - 'BOOK_ID','CHGIS_ID','1820_ID','1911_ID','CBDB_ID','Description']; //columns for output array/file (for map.php) - */ - $columnNameArray=array_flip($columnNameArray); //key, value swap in order to keep the order of the columns after merge - $bookArray=array(); - $count=0; - $line=0; - while(!feof($fp)){ + + if ($fp = fopen($server_host."LGSearch/csv_files/".$fileName,"r") ) { + + // $fp=fopen($server_host."LGSearch/csv_files/".$fileName,"r"); $data=fgetcsv($fp); - if(sizeof($data)$newName){ //use column names as the array indices (instead of 0,1,2,... as from $data) + $bookInfo[$newName]=$data[$idx]; + } + $bookId=$bookInfo['BOOK_ID']; + $coordinateArray=getCoordinateFromDatabase($bookId); + foreach($coordinateArray as $coordinate){ //merge a record from $booArray and ots cooresponding coordinateArray + $bookArray[$count]=array_merge($bookInfo,$coordinate); + $bookArray[$count]=array_merge($columnNameArray,$bookArray[$count]); + $count++; + } } - ///$bookId=$data[0]; - foreach($columnNameMappingArray as $idx=>$newName){ //use column names as the array indices (instead of 0,1,2,... as from $data) - $bookInfo[$newName]=$data[$idx]; - } - $bookId=$bookInfo['BOOK_ID']; - $coordinateArray=getCoordinateFromDatabase($bookId); - foreach($coordinateArray as $coordinate){ //merge a record from $booArray and ots cooresponding coordinateArray - $bookArray[$count]=array_merge($bookInfo,$coordinate); - $bookArray[$count]=array_merge($columnNameArray,$bookArray[$count]); - $count++; - } + fclose($fp); + + } else { + // file open failed + error_log("error when opening file: ".$server_host."LGSearch/csv_files/".$fileName, 0); + return array(); } - fclose($fp); + return $bookArray; } function writeCsvFile($fileName,$bookArray){ @@ -69,13 +79,20 @@ 'Name','PERIOD','TimeSpan:begin','TimeSpan:end','Longitude','Latitude', 'PAGE','SECTION','CONTENT', 'BOOK_ID','CHGIS_ID','1820_ID','1911_ID','CBDB_ID','Description']; - $fp=fopen("./datasets/".$fileName,"w"); - fputcsv($fp,$columnNameArray); + + if ($fp=fopen("./datasets/".$fileName,"w")) { + + //$fp=fopen("./datasets/".$fileName,"w"); + fputcsv($fp,$columnNameArray); - foreach($bookArray as $book){ - fputcsv($fp,$book); + foreach($bookArray as $book){ + fputcsv($fp,$book); + } + fclose($fp); + } else { + error_log("error when opening file: "."./datasets/".$fileName, 0); } - fclose($fp); + } function getCoordinateFromDatabase($bookId){ /* diff -r 6095925edcba -r 30b59e7b88c0 map.js --- a/map.js Thu Apr 23 16:13:07 2015 +0200 +++ b/map.js Thu Jun 25 17:47:11 2015 +0200 @@ -1,9 +1,10 @@ //geoserver url var url="http://geoserver.mpiwg-berlin.mpg.de/geoserver/China_Monograph_Project/ows"; + //"name": "layer name" var overlayArray=[{name:"provincial distribution of local monographs", file:"China_Monograph_Project:monograph_distribution_prov", - preload:true + preload:false }, { name:"test",