comparison coordinates/local_monographs_coordinates.php @ 3:2b5a5cb5d6d1

update books_coordinates.csv
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 20 Apr 2015 11:36:07 +0200
parents 57bde4830927
children
comparison
equal deleted inserted replaced
2:b85894a9b2dc 3:2b5a5cb5d6d1
1 <?php 1 <?php
2 include_once("../../interface/config.php"); 2 include_once("../config/config.php");
3 include_once('../../interface/Lib_mb_utf8.php'); 3 include_once("../config/Lib_mb_utf8.php");
4 set_time_limit(0); 4 set_time_limit(0);
5 ini_set('memory_limit', '-1'); 5 ini_set('memory_limit', '-1');
6 ini_set("auto_detect_line_endings", true); 6 ini_set("auto_detect_line_endings", true);
7 7
8 $link_mysql = mysql_connect($mysql_server, $mysql_user, $mysql_password); 8 $link_mysql = mysql_connect($mysql_server, $mysql_user, $mysql_password);
151 } 151 }
152 } 152 }
153 echo "# of rows: ".$row."<br>"; 153 echo "# of rows: ".$row."<br>";
154 } 154 }
155 function getBookListFromDatabase(){ 155 function getBookListFromDatabase(){
156 $query="SELECT coor.place_name AS Address, coor.admin_type AS ADMIN_TYPE, books.level1 AS LEVEL1, books.level2 AS LEVEL2, 156 $query="SELECT coor.place_name AS Address, books.admin_type AS ADMIN_TYPE, books.level1 AS LEVEL1, books.level2 AS LEVEL2,
157 books.name AS Name, books.period AS PERIOD, 157 books.name AS Name, books.period AS PERIOD,
158 books.start_year AS 'TimeSpan:begin', books.end_year AS 'TimeSpan:end', 158 books.start_year AS 'TimeSpan:begin', books.end_year AS 'TimeSpan:end',
159 books.id AS BOOK_ID, coor.x AS Longitude, coor.y AS Latitude, 159 books.id AS BOOK_ID, coor.x AS Longitude, coor.y AS Latitude,
160 coor.chgis_id AS CHGIS_ID, coor.1820_id AS 1820_ID, 160 coor.chgis_id AS CHGIS_ID, coor.1820_id AS 1820_ID,
161 coor.1911_id AS 1911_ID, coor.cbdb_id AS CBDB_ID, 161 coor.1911_id AS 1911_ID, coor.cbdb_id AS CBDB_ID,
162 info.volume AS VOLUME, info.author AS AUTHOR, info.edition AS EDITION FROM books 162 books.volume AS VOLUME, books.author AS AUTHOR, books.edition AS EDITION FROM books
163 JOIN coordinates_books coor ON books.id=coor.books_id 163 JOIN coordinates_books coor ON books.id=coor.books_id";
164 JOIN books_info info ON books.id=info.books_id"; 164 //JOIN books_info info ON books.id=info.books_id";
165 $bookArray=array(); 165 $bookArray=array();
166 $result=mysql_query($query); 166 $result=mysql_query($query);
167 while($row=mysql_fetch_assoc($result)){ 167 while($row=mysql_fetch_assoc($result)){
168 $bookArray[]=$row; 168 $bookArray[]=$row;
169 } 169 }
170
170 return $bookArray; 171 return $bookArray;
171 } 172 }
172 173
173 ?> 174 ?>
174 175
184 } 185 }
185 </style> 186 </style>
186 </head> 187 </head>
187 <body> 188 <body>
188 <?php 189 <?php
189 $coordinateArray=getCoordinateFromFile(); //Read from local_monographs_coordinates_filtered.txt to get the most updated coordinates 190 //$coordinateArray=getCoordinateFromFile(); //Read from local_monographs_coordinates_filtered.txt to get the most updated coordinates
190 //printCoordinate($coordinateArray); 191 ////printCoordinate($coordinateArray);
191 insertCoordinateIntoDatabase($coordinateArray); //insert them to db 192 //insertCoordinateIntoDatabase($coordinateArray); //insert them to db
193
192 $bookArray=getBookListFromDatabase(); 194 $bookArray=getBookListFromDatabase();
193 foreach($bookArray as $idx=>$book){ 195 foreach($bookArray as $idx=>$book){
194 $bookArray[$idx]['Name']="(".$book['PERIOD'].") ".$book['Name']; 196 $bookArray[$idx]['Name']="(".$book['PERIOD'].") ".$book['Name'];
195 $book['AUTHOR']=str_replace("(","(",$book['AUTHOR']); 197 $book['AUTHOR']=str_replace("(","(",$book['AUTHOR']);
196 $book['AUTHOR']=str_replace(")",") ",$book['AUTHOR']); 198 $book['AUTHOR']=str_replace(")",") ",$book['AUTHOR']);