1 / 18

Information and Mapping in the Public Interest

Information and Mapping in the Public Interest www.greeninfo.org www.mapsportal.org . Roadmap. 1. About GreenInfo Network Web maps, GIS, and the take-away message Examples Techniques and program code Greg Allensworth , Senior Web GIS Developer gregor@greeninfo.org.

jenski
Download Presentation

Information and Mapping in the Public Interest

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Information and Mapping in the Public Interest www.greeninfo.org www.mapsportal.org

  2. Roadmap 1 • About GreenInfo Network • Web maps, GIS, and the take-away message • Examples • Techniques and program code Greg Allensworth, Senior Web GIS Developer gregor@greeninfo.org

  3. GreenInfo Network 2 • Largest dedicated nonprofit GIS support group in U.S. • 16 years, 500 organizations • 14 staff, 20-30 projects at a time • Wide range of geospatial capacities • Extensive experience with foundations and mapping

  4. 1 Web maps, GIS, And the take-away message

  5. Web Maps, GIS, and the take-away message 2 • The growth of the web. More interactive and engaging websites. Mobile devices. This means maps in the hands and eyes of billions. • Your map educates and it advocates, but…

  6. But decisions aren’t made in front of the computer 1

  7. It helps to be able to take something away, for analysis or for presentation 1

  8. 1 Some examples

  9. 1 Looks great! How do I do it?

  10. TCPDF 1 • Library for producing PDFs in PHP. • Can generate sophisticated PDFs: pictures, borders, fills. • Can be tedious to adjust every pixel.

  11. TCPDF 2 require_once('tcpdf/config/lang/eng.php'); require_once('tcpdf/tcpdf.php'); class MYPDF extends TCPDF { public function Header() { $this->Image(K_PATH_IMAGES.'legend.jpg', 5, 100); $this->Image(K_PATH_IMAGES.'report_header.png', 5, 5); $arial = $this->addTTFfont('Arial.ttf', '', 'TrueType'); $this->SetFont($arial, '', 24, '', false); $this->SetX(90); $this->SetY(10); $this->Cell(642, 55, "Duck Populations by Parcel, 2012", 0, 0, 'C'); } public function Footer() { $footfont = $this->addTTFfont('impact.ttf', '', 'TrueType'); $this->SetFont($footfont, '', 10, '', false); $date = date("F j, Y"); $this->Cell(762, 10, "Map created on $date. Disclaimer and so forth.", 0, 0, 'C'); } } $pdf = new MYPDF(L, 'px', LETTER, true, 'UTF-8', false); $pdf->AddPage(); $pdf->Image("/var/www/tmp/images.201209281107.jpg", 155, 70, 632, 507);

  12. wkhtmltopdf / wkhtmltoimage 1 • Command-line utilities for Linux, using a real browser engine to draw pictures. Feed it a HTML file, it generates a PDF or JPEG file. • Supports JavaScript, including Google Maps, OpenLayers, et cetera. • Develop your PDF layouts in HTML, JavaScript, and CSS! • Command-line tool means saving HTML to a file, reading PDF as a file or capturing filename, …

  13. wkhtmltopdf / wkhtmltoimage 2 $html .= <<<ENDOFPDF <html> <head> <style type="text/css"> @font-face { font-family:Calibri; src:url("file:/var/www/fonts/calibri.ttf"); format(TrueType); } body { font-size:12pt; font-family: Calibri; color:black; } @page { margin:0.25in 0.25in 0.25in0.25in; width:8.5in; height:11.0in; } </style> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script type="text/javascript" src="http://openlayers.org/dev/OpenLayers.js"></script> <script type="text/javascript"> $(document).ready(function () { var MAP = new OpenLayers.Map(‘map_canvas’, { other map setup options … }); var BBOX = new OpenLayers.Bounds({$_GET['west']},{$_GET['south']},{$_GET['east']},{$_GET['north']}); MAP.addLayer(new OpenLayers.Layer.Google("Streets", { } )); MAP.zoomToExtent(BBOX); }); </script> </head> <body> <div id="map_canvas"></div> </body> </html> ENDOFPDF ?>

  14. wkhtmltopdf / wkhtmltoimage 3 // define a random directory name, and filenames under it // this allows a nice filename based on the County, without two people colliding if they ask for the same report $tempdir = md5(microtime() . mt_rand()); mkdir("/var/www/tmp/$tempdir"); $htmfile = sprintf("%s/ManagementOpportunitiesReport_%s.html", $tempdir, $county ); $pdffile = sprintf("%s/ManagementOpportunitiesReport_%s.pdf" , $tempdir, $county ); // using a simple require() we can load our variables into the template easily // with a template engine like Smarty or CodeIgniter, this is even better require 'report.pdf.php'; // save the HTML to a file // debugging is easy: simply print out the resulting HTML and see how it looks in our browser file_put_contents($htmfile, $html); //print $html; exit; // done, tell the browser where they can find the finished PDF // alternately, we could print Content-disposition headers to make the browser download the resulting PDF $command = escapeshellcmd("wkhtmltopdf --quiet --page-size letter $htmfile $pdffile"); header(sprintf("Location: /tmp/%s", basename($pdffile) ));

  15. PHPExcel 1 • PHP library for reading and generating Excel spreadsheets. • Supports modern XLSX format, advanced spreadsheet options: formulas, embedding of links, images, etc.

  16. PHPExcel 2 // load up PHPExcel require '/usr/lib/php/PHPExcel/Classes/PHPExcel.php'; require '/usr/lib/php/PHPExcel/Classes/PHPExcel/Writer/Excel2007.php'; $xls = new PHPExcel(); // set auto-sizing and bold for all columns, then the column titles in row 1 $xls->getActiveSheet()->setTitle('Species of Concern'); $xls->getActiveSheet()->getColumnDimension('A')->setAutoSize(true); $xls->getActiveSheet()->getColumnDimension('B')->setAutoSize(true); $xls->getActiveSheet()->getColumnDimension('C')->setAutoSize(true); $xls->getActiveSheet()->getColumnDimension('D')->setAutoSize(true); $xls->getActiveSheet()->getStyle("A1")->getFont()->setBold(true); $xls->getActiveSheet()->getStyle("B1")->getFont()->setBold(true); $xls->getActiveSheet()->getStyle("C1")->getFont()->setBold(true); $xls->getActiveSheet()->getStyle("D1")->getFont()->setBold(true); $xls->getActiveSheet()->SetCellValue("A1", "COUNTY"); $xls->getActiveSheet()->SetCellValue("B1", "SPECIES"); $xls->getActiveSheet()->SetCellValue("C1", "PRIORITY"); $xls->getActiveSheet()->SetCellValue("D1", "COMMENTS"); $row = 1; foreach ($allspecies as $spec) { $row++; $sheet->SetCellValue("A$row", $spec['location_name']); $sheet->SetCellValue("B$row", $spec['species_binominal']); $sheet->SetCellValue("C$row", $spec['priority_rating']); $sheet->SetCellValue("D$row", $spec['editornote']); } // done! save it to disk, spit it out to the browser $tempfile = sprintf("/var/www/tmp/%s.xlsx", md5(mt_rand() . microtime() ) ); $xls = new PHPExcel_Writer_Excel2007($xls); $xls->save($tempfile); header("Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml"); header("Content-disposition: attachment; filename=\"SpeciesReport.xlsx\""); readfile($tempfile);

  17. 1 The take-away message

  18. The End

More Related