Ejemplo n.º 1
0
$result = $m->addStyle('popplaces', $popplaces_style);
$t->is($result, true, 'Feature style \'popplaces\' added to map');
$p = new Mapnik\Parameters();
$t->isnt($p, null, 'Created parameters to pass to layer');
$p->set('type', 'shape');
$p->set('file', '../mapnik-0.7.1/demo/data/popplaces');
$p->set('encoding', 'latin1');
$lyr = new Mapnik\Layer('Populated places');
$t->isnt($lyr, null, 'Created layer \'Populated places\'');
$shapefile_datasource = Mapnik\DatasourceCache::create($p);
$t->isnt($shapefile_datasource, null, 'Shape file data source created');
$lyr->setDatasource($shapefile_datasource);
$t->pass('Data source set');
$lyr->addStyle('popplaces');
$t->pass('popplaces style added');
$m->addLayer($lyr);
$t->pass('Layer added');
// Render the map
$m->zoomToBox(new Mapnik\Envelope(1405120.04127408, -247003.813399447, 1706357.31328276, -25098.593149577));
$t->pass('Zoomed to box');
$buf = new Mapnik\Image32($m->getWidth(), $m->getHeight());
$t->isnt($buf, null, 'Created Image32 image buffer');
// @todo test width and height
$agg_renderer = new Mapnik\AggRenderer($m, $buf);
$t->isnt($agg_renderer, null, 'Created renderer');
$agg_renderer->apply();
$t->pass('Agg renderer apply() didn\'t crash');
// Save the map
Mapnik\save_to_file($buf, 'demo.jpg', 'jpeg');
Mapnik\save_to_file($buf, 'demo.png', 'png');
Mapnik\save_to_file($buf, 'demo256.png', 'png256');
Ejemplo n.º 2
0
<?php

include 'lime.php';
$t = new lime_test(7, new lime_output_color());
/* Test the various constructors.  */
$m = new Mapnik\Map();
$t->is($m->getWidth(), 400, 'Default constructor: width is 400');
$t->is($m->getHeight(), 400, 'Default constructor: height is 400');
$t->is($m->getSrs(), '+proj=latlong +datum=WGS84', 'Default constructor: projection is "+proj=latlong +datum=WGS84"');
$fs = new Mapnik\FeatureStyle();
$t->is($m->addStyle('feature style name', $fs), true, 'Add feature style to map');
$t->is($m->getBackgroundColor(), null, 'No background color set yet, getBackgroundColor returns null');
$bg_color = new Mapnik\Color(255, 255, 255);
$m->setBackgroundColor($bg_color);
$t->isa_ok($m->getBackgroundColor(), 'Mapnik\\Color', 'getBackgroundColor returns a Color object');
$t->is($m->getBackgroundColor()->toHexString(), $bg_color->toHexString(), 'getBackgroundColor returns the right color');
$l = new Mapnik\Layer('test layer');
$m->addLayer($l);
// @todo test getLayer
$m->zoomToBox(new Mapnik\Envelope(0.0, 0.0, 1.0, 1.0));
// @todo test zoomToBox
/*
$t->getStyleNames
getStyle
removeStyle
removeAllStyles
*/
//$m = new Mapnik\Map(800, 600);
//$t->is();
//m->setBackground(Mapnik\ColorFactory::FromString("white"));
//m->zoomToBox(new Mapnik\Envelope(1405120.04127408, -247003.813399447, 1706357.31328276, -25098.593149577));