Skip to content

Commit ce4819b

Browse files
author
timlinux
committedMar 24, 2011
Added utility script from Mathieu Pellerin for updating the srs.db from gdal
git-svn-id: http://svn.osgeo.org/qgis/trunk@15589 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 6123281 commit ce4819b

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
 

‎scripts/update-srs-db.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
$sqlread = new SQLite3('srs.db');
24+
$sqlwrite = new SQLite3('srs-sync.db');
25+
26+
$r = $sqlread->query("SELECT srid, parameters FROM tbl_srs");
27+
while ($row = $r->fetchArray(SQLITE3_ASSOC)) {
28+
foreach($srs as $s) {
29+
if ($row['srid'] == $s['id']) {
30+
if ($row['parameters'] != $s['param']) {
31+
$sqlwrite->query("UPDATE tbl_srs SET parameters='".$s['param']."' WHERE srid='".$s['id']."'");
32+
fwrite($f,"UPDATE tbl_srs SET parameters='".$s['param']."' WHERE srid='".$s['id']."'".chr(13).chr(10));
33+
$srs_sync++;
34+
} else { $srs_nosync++; }
35+
break;
36+
}
37+
}
38+
}
39+
40+
$sqlread->close();
41+
$sqlwrite->close();
42+
fclose($f);
43+
44+
echo $srs_sync.' -- '.$srs_nosync;
45+
?>

0 commit comments

Comments
 (0)
Please sign in to comment.