コード例 #1
0
ファイル: lib_pdf.php プロジェクト: netcon-source/dotspotting
<?php

#
# $Id$
#
# THIS NEEDS COMMENTS.
loadpear("fpdf");
loadlib("maps");
loadlib("kmeans");
#################################################################
function pdf_export_dots(&$dots, &$more)
{
    # PLEASE FOR TO BE CACHING ME, OBIWAN...
    # (20110120/straup)
    $w = 11;
    $h = 8.5;
    $margin = 0.5;
    $dpi = 72;
    $header_h = 0.2;
    $row_h = 0.2;
    $col_width = 1.25;
    # Here we go...
    $pdf = new FPDF("P", "in", array($w, $h));
    $pdf->setMargins($margin, $margin);
    # The legend gets added below (once we've figured out what page
    # each dot is on) but we'll just declare it here.
    $legend = array();
    $count_legend_items = floor($h / ($row_h * 1.4));
    $count_clusters = ceil(count($dots) / $count_legend_items);
    # Just turn clusters off for now... the map rendering time
    # is still too long for multiple map images (20110120/straup)
コード例 #2
0
<?php

#
# $Id$
#
loadpear("modestmaps/ModestMaps");
loadlib("wscompose");
#################################################################
function maps_png_for_dots_multi(&$dots, $more = array())
{
    $prefix = $more['img_prefix'] ? $more['img_prefix'] : 'nyan';
    $maps = maps_images_for_dots($dots, $more);
    $pngs = array();
    foreach ($maps as $data) {
        list($ignore, $gd_img) = $data;
        $pngs[] = maps_gd_to_png($gd_img, $prefix);
    }
    return $pngs;
}
#################################################################
function maps_png_for_dots(&$dots, $more = array())
{
    list($map, $gd_img) = maps_image_for_dots($dots, $more);
    $prefix = $more['img_prefix'] ? $more['img_prefix'] : 'nyan';
    return maps_gd_to_png($gd_img, $prefix);
}
#################################################################
# this returns GD image handle(s) for a bunch of dots
# this is the old code that's called throughout the site
function maps_image_for_dots(&$dots, $more = array())
{
コード例 #3
0
ファイル: lib_ppt.php プロジェクト: netcon-source/dotspotting
<?php

#
# $Id$
#
loadlib("maps");
loadpear("PHPPowerPoint");
loadpear("PHPPowerPoint/IOFactory");
#################################################################
function ppt_export_dots(&$dots, &$more)
{
    $maps = array();
    $w = 960;
    $h = 720;
    $ppt = new PHPPowerPoint();
    $ppt->getProperties()->setTitle($more['title']);
    $ppt->getProperties()->setCreator("Dotspotting");
    # set title here
    # $slide = $ppt->getActiveSlide();
    $ppt->removeSlideByIndex(0);
    # draw the maps
    $dot_per_slide = 1;
    $img_more = array('width' => $w, 'height' => $h, 'dot_size' => 20);
    if (!$dot_per_slide || count($dots) == 0) {
        $maps[] = maps_png_for_dots($dots, $img_more);
    } else {
        $img_more['dot_size'] = 25;
        $img_more['width'] = $img_more['height'];
        $img_more['img_prefix'] = 'ppt';
        # remember: 1 dot per slide
        $_dots = array();
コード例 #4
0
ファイル: OLE.php プロジェクト: netcon-source/dotspotting
// | Author: Xavier Noguer <*****@*****.**>                              |
// | Based on OLE::Storage_Lite by Kawai, Takanori                        |
// +----------------------------------------------------------------------+
//
// $Id: OLE.php,v 1.15 2007/12/18 20:59:11 schmidt Exp $
/**
* Constants for OLE package
*/
define('OLE_PPS_TYPE_ROOT', 5);
define('OLE_PPS_TYPE_DIR', 1);
define('OLE_PPS_TYPE_FILE', 2);
define('OLE_DATA_SIZE_SMALL', 0x1000);
define('OLE_LONG_INT_SIZE', 4);
define('OLE_PPS_SIZE', 0x80);
# require_once 'PEAR.php';
loadpear("PEAR");
/**
* Array for storing OLE instances that are accessed from
* OLE_ChainedBlockStream::stream_open().
* @var  array
*/
$GLOBALS['_OLE_INSTANCES'] = array();
/**
* OLE package base class.
*
* @category Structures
* @package  OLE
* @author   Xavier Noguer <*****@*****.**>
* @author   Christian Schmidt <*****@*****.**>
*/
class OLE extends PEAR
コード例 #5
0
ファイル: lib_shp.php プロジェクト: netcon-source/dotspotting
<?php

#
# $Id$
#
loadpear("ShapeFile");
#################################################################
function shp_parse_fh($fh, $more)
{
    # See also:
    # http://vis4.net/blog/de/2010/04/reading-esri-shapefiles-in-php/
    fclose($fh);
    $args = array('noparts' => true);
    $shp = new ShapeFile($more['file']['path'], $args);
    if (!$shp) {
        return array('ok' => 0, 'error' => 'Failed to parse shapefile');
    }
    $data = array();
    $errors = array();
    $record = 0;
    while ($record = $shp->getNext()) {
        # This is mostly here if/when we break in $parts loop
        if ($more['max_records'] && $record > $more['max_records']) {
            break;
        }
        # What to do about file specific metadata?
        $shp_data = $record->getShpData();
        $parts = isset($shp_data['parts']) ? $shp_data['parts'] : array($shp_data);
        foreach ($parts as $pt) {
            $record++;
            if ($more['max_records'] && $record > $more['max_records']) {
コード例 #6
-1
ファイル: lib_xls.php プロジェクト: netcon-source/dotspotting
function xls_export_dots(&$rows, $more)
{
    loadpear("PHPExcel");
    $xls = new PHPExcel();
    $sheet = $xls->setActiveSheetIndex(0);
    $col_names = array_keys($rows[0]);
    $row = 1;
    $col = 0;
    foreach ($col_names as $c) {
        $sheet->setCellValueByColumnAndRow($col, $row, $c);
        $col++;
    }
    $row = 2;
    $col = 0;
    foreach ($rows as $_row) {
        foreach (array_values($_row) as $value) {
            $sheet->setCellValueByColumnAndRow($col, $row, $value);
            $col++;
        }
        $row++;
        $col = 0;
    }
    # Excel 2007 is just plain weird and confuses
    # both OpenOffice and Numbers.app
    # (20110201/straup)
    $writer = PHPExcel_IOFactory::createWriter($xls, 'Excel5');
    $writer->save($more['path']);
    return $more['path'];
}