Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
EPSG postgis scraper
/* from */
$conn_string = "host=localhost port=5432
dbname=mydatabase_with_postgis_activated user=my_user password=my_password";
$link = pg_connect($conn_string) or die("Could not connect");
$start_epsg = 'Proj4js.defs["EPSG:';
$end_epsg_start_proj4js = '"] = "';
$end_proj4js ='";';
$select_epsg = pg_query("SELECT srid,trim(proj4text) as proj4text from
//Uncomment if you want to make a particular file for proj4js file depending
on defined epsgvalues
$epsgvalues = "4326,2154";
$select_epsg = pg_query("SELECT srid,trim(proj4text) as proj4text from
spatial_ref_sys WHERE srid IN(".$epsgvalues.")");
while($proj4_code = pg_fetch_array($select_epsg)) {
//To view result
//To prepare content for writing result
$myFile = "epsg.js";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $stringData);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment