Skip to content
Permalink
Browse files
Added utility script from Mathieu Pellerin for updating the srs.db fr…
…om gdal

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15589 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Mar 24, 2011
1 parent 2cddedf commit 5ce0cc0e053b75c01652329351598efa3197978d
Showing with 45 additions and 0 deletions.
  1. +45 −0 scripts/update-srs-db.php
@@ -0,0 +1,45 @@
<?
$srs = null;
$i = 0;
$j = 1;
$srs_sync = 0;
$srs_nosync = 0;

$f = fopen('epsg',r);
while (!feof($f)) {
$line = trim(fgets($f));
if ($line[0] != '#' && $line != '') {
$chunks = explode('>',$line);
$srs[$i]['id'] = substr($chunks[0],1);
$srs[$i]['param'] = trim(substr($chunks[1],0,-1));
$srs[$i]['linenb'] = $j; //debugging info
$i++;
}
$j++;
}
fclose($f);

$f = fopen('update.sql',w);
$sqlread = new SQLite3('srs.db');
$sqlwrite = new SQLite3('srs-sync.db');

$r = $sqlread->query("SELECT srid, parameters FROM tbl_srs");
while ($row = $r->fetchArray(SQLITE3_ASSOC)) {
foreach($srs as $s) {
if ($row['srid'] == $s['id']) {
if ($row['parameters'] != $s['param']) {
$sqlwrite->query("UPDATE tbl_srs SET parameters='".$s['param']."' WHERE srid='".$s['id']."'");
fwrite($f,"UPDATE tbl_srs SET parameters='".$s['param']."' WHERE srid='".$s['id']."'".chr(13).chr(10));
$srs_sync++;
} else { $srs_nosync++; }
break;
}
}
}

$sqlread->close();
$sqlwrite->close();
fclose($f);

echo $srs_sync.' -- '.$srs_nosync;
?>

0 comments on commit 5ce0cc0

Please sign in to comment.