update.php
1 |
<?
|
---|---|
2 |
$srs = null; |
3 |
$i = 0; |
4 |
$j = 1; |
5 |
$srs_sync = 0; |
6 |
$srs_nosync = 0; |
7 |
|
8 |
$f = fopen('epsg',r); |
9 |
while (!feof($f)) { |
10 |
$line = trim(fgets($f)); |
11 |
if ($line[0] != '#' && $line != '') { |
12 |
$chunks = explode('>',$line); |
13 |
$srs[$i]['id'] = substr($chunks[0],1); |
14 |
$srs[$i]['param'] = trim(substr($chunks[1],0,-1)); |
15 |
$srs[$i]['linenb'] = $j; //debugging info |
16 |
$i++;
|
17 |
} |
18 |
$j++;
|
19 |
} |
20 |
fclose($f); |
21 |
|
22 |
$f = fopen('update.sql',w); |
23 |
$sqlite = new SQLite3('srs.db'); |
24 |
$r = $sqlite->query("SELECT srid, parameters FROM tbl_srs"); |
25 |
while ($row = $r->fetchArray(SQLITE3_ASSOC)) { |
26 |
foreach($srs as $s) { |
27 |
if ($row['srid'] == $s['id']) { |
28 |
if ($row['parameters'] != $s['param']) { |
29 |
fwrite($f,"UPDATE tbl_srs SET parameters='".$s['param']."' WHERE srid='".$s['id']."'".chr(13).chr(10)); |
30 |
$srs_sync++;
|
31 |
} else { $srs_nosync++; } |
32 |
break;
|
33 |
} |
34 |
} |
35 |
} |
36 |
$sqlite->close();
|
37 |
fclose($f); |
38 |
|
39 |
echo $srs_sync.' -- '.$srs_nosync; |
40 |
?>
|