function addPoint($row, $lon, $lat, $name) { global $shpFile, $dbfFile; // Create the shape $shp = ms_newShapeObj(MS_SHAPE_POINT); $pt = ms_newPointobj(); $pt->setXY($lon, $lat, 0); $line = ms_newLineObj(); $line->add($pt); $shp->add($line); $shpFile->addShape($shp); dbase_add_record($dbfFile, array($row["station"], $name, $row["years"], $row["cvalid"], $row["high"], $row["low"], $row["precip"], $row["max_precip"], $row["max_precip_yr"], $row["max_high"], $row["max_low"], $row["min_high"], $row["min_low"], $row["max_high_yr"], $row["max_low_yr"], $row["min_high_yr"], $row["min_low_yr"])); }
$table .= "</pre>\n"; } } else { if ($format == "shapefile") { /* Create SHP,DBF bases */ $filePre = "{$network}_locs"; if (!is_file("/var/webtmp/{$filePre}.zip")) { $shpFname = "/var/webtmp/{$filePre}"; @unlink($shpFname . ".shp"); @unlink($shpFname . ".shx"); @unlink($shpFname . ".dbf"); @unlink($shpFname . ".zip"); $shpFile = ms_newShapeFileObj($shpFname, MS_SHP_POINT); $dbfFile = dbase_create($shpFname . ".dbf", array(array("ID", "C", 6), array("NAME", "C", 50), array("NETWORK", "C", 20), array("BEGINTS", "C", 16))); for ($i = 0; $row = @pg_fetch_array($result, $i); $i++) { $pt = ms_newPointobj(); $pt->setXY($row["longitude"], $row["latitude"], 0); $shpFile->addPoint($pt); dbase_add_record($dbfFile, array($row["id"], $row["name"], $row["network"], substr($row["archive_begin"], 0, 16))); } unset($shpFile); dbase_close($dbfFile); chdir("/var/webtmp/"); copy("/mesonet/www/apps/iemwebsite/data/gis/meta/4326.prj", $filePre . ".prj"); popen("zip " . $filePre . ".zip " . $filePre . ".shp " . $filePre . ".shx " . $filePre . ".dbf " . $filePre . ".prj", 'r'); } $table .= "Shapefile Generation Complete.<br>"; $table .= "Please download this <a href=\"/tmp/" . $filePre . ".zip\">zipfile</a>."; chdir("/mesonet/www/apps/iemwebsite/htdocs/sites/"); } else { if ($format == "awips") {