Hello to all,
Thanks for bearing with me.
I hope this mail will make more sense than my previous ones !
Currently, I have _________________________________
mapnik-0.6.0 duly installed on OpenSuse 11.2 (64 bit), with
postgresql 8.4.1,
postgis 1.4.1,
osm2pgsql SVN version 0.69-19233.
I have created the database "gis" successfully and here is what I have in it:
List of relations
Schema | Name | Type | Owner
--------+--------------------+-------+--------
public | geometry_columns | table | anisha
public | planet_osm_line | table | anisha
public | planet_osm_nodes | table | anisha
public | planet_osm_point | table | anisha
public | planet_osm_polygon | table | anisha
public | planet_osm_rels | table | anisha
public | planet_osm_roads | table | anisha
public | planet_osm_ways | table | anisha
public | spatial_ref_sys | table | anisha
(9 rows)
I have loaded data in the the database with the following command:
./osm2pgsql -m -d gis ../czechia-071115.osm.bz2
I added the following in rundemo.cpp file :
{
parameters p;
p["type"]="postgis";
p["host"]="127.0.0.1";
p["port"]=5432;
p["dbname"]="gis";
p["user"]="anisha";
p["password"]="";
p["table"]="planet_osm_point";
p["geometry_field"]="way";
Layer lyr("Roads");
lyr.set_datasource(datasource_cache::instance()->create(p));
lyr.add_style("roads");
m.addLayer(lyr);
}
and deleted the default shape file code of rundemo.cpp. (I have attached
rundemo.cpp)
Problem statement:
___________________________________________________________________________________________________
When I compile and run the rundemo.cpp, "demo.jpg" file is blank, i.e. doesn't
show any maps !
___________________________________________________________________________________________________
Here's the output of executing rundemo.cpp after modification:
./rundemo /usr/local/lib64/mapnik/
running demo ...
looking for 'shape.input' plugin in... /usr/local/lib64/mapnik//input/
registered datasource : raster
registered datasource : osm
registered datasource : shape
registered datasource : postgis
registered datasource : sqlite
looking for DejaVuSans font in... /usr/local/lib64/mapnik//fonts/DejaVuSans.ttf
size = 9
dbname=gis
geometry_field=way
host=127.0.0.1
password=
port=5432
row_limit=10
table=planet_osm_point
type=postgis
user=anisha
datasource=0x644a30 type=1
scale=376.547
start map processing
bbox=Envelope(1405120.04127408,-249015.180277767,1706357.31328276,-23087.22627125698)
start layer processing : Roads
datasource = 0x644a30
end map processing
Three maps have been rendered using AGG in the current directory:
- demo.jpg
- demo.png
- demo256.png
Have a look!
destroyed singleton
______________________________________________________________________________________________
Please guide !!
--
Regards,
Anisha Kaul
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
// $Id$
#include <mapnik/map.hpp>
#include <mapnik/datasource_cache.hpp>
#include <mapnik/font_engine_freetype.hpp>
#include <mapnik/agg_renderer.hpp>
#include <mapnik/filter_factory.hpp>
#include <mapnik/color_factory.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/config_error.hpp>
#if defined(HAVE_CAIRO)
// cairo
#include <mapnik/cairo_renderer.hpp>
#include <cairomm/surface.h>
#endif
#include <iostream>
int main ( int argc , char** argv)
{
if (argc != 2)
{
std::cout << "usage: ./rundemo <mapnik_install_dir>\nUsually /usr/local/lib/mapnik\n";
std::cout << "Warning: ./rundemo looks for data in ../data/,\nTherefore must be run from within the demo/c++ folder.\n";
return EXIT_SUCCESS;
}
using namespace mapnik;
try {
std::cout << " running demo ... \n";
std::string mapnik_dir(argv[1]);
std::cout << " looking for 'shape.input' plugin in... " << mapnik_dir << "/input/" << "\n";
datasource_cache::instance()->register_datasources(mapnik_dir + "/input/");
std::cout << " looking for DejaVuSans font in... " << mapnik_dir << "/fonts/DejaVuSans.ttf" << "\n";
freetype_engine::register_font(mapnik_dir + "/fonts/DejaVuSans.ttf");
Map m(800,600);
m.set_background(color_factory::from_string("white"));
{
parameters p;
p["type"]="postgis";
p["host"]="127.0.0.1";
p["port"]=5432;
p["dbname"]="gis";
p["user"]="anisha";
p["password"]="";
p["table"]="planet_osm_point";
p["geometry_field"]="way";
Layer lyr("Roads");
lyr.set_datasource(datasource_cache::instance()->create(p));
lyr.add_style("roads");
m.addLayer(lyr);
}
m.zoomToBox (Envelope<double>(1405120.04127408,-247003.813399447, 1706357.31328276,-25098.593149577));
Image32 buf(m.getWidth(),m.getHeight());
agg_renderer<Image32> ren(m,buf);
ren.apply();
save_to_file<ImageData32>(buf.data(),"demo.jpg","jpeg");
save_to_file<ImageData32>(buf.data(),"demo.png","png");
save_to_file<ImageData32>(buf.data(),"demo256.png","png256");
std::cout << "Three maps have been rendered using AGG in the current directory:\n"
"- demo.jpg\n"
"- demo.png\n"
"- demo256.png\n"
"Have a look!\n";
#if defined(HAVE_CAIRO)
Cairo::RefPtr<Cairo::ImageSurface> image_surface;
image_surface = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, m.getWidth(),m.getHeight());
cairo_renderer<Cairo::Surface> png_render(m, image_surface);
png_render.apply();
image_surface->write_to_png("cairo-demo.png");
Image32 im(image_surface);
save_to_file(im, "cairo-demo256.png","png256");
Cairo::RefPtr<Cairo::Surface> surface;
surface = Cairo::PdfSurface::create("cairo-demo.pdf", m.getWidth(),m.getHeight());
cairo_renderer<Cairo::Surface> pdf_render(m, surface);
pdf_render.apply();
surface = Cairo::SvgSurface::create("cairo-demo.svg", m.getWidth(),m.getHeight());
cairo_renderer<Cairo::Surface> svg_render(m, surface);
svg_render.apply();
std::cout << "Three maps have been rendered using Cairo in the current directory:\n"
"- cairo-demo.png\n"
"- cairo-demo256.png\n"
"- cairo-demo.pdf\n"
"- cairo-demo.svg\n"
"Have a look!\n";
#endif
}
catch ( const mapnik::config_error & ex )
{
std::cerr << "### Configuration error: " << ex.what() << std::endl;
return EXIT_FAILURE;
}
catch ( const std::exception & ex )
{
std::cerr << "### std::exception: " << ex.what() << std::endl;
return EXIT_FAILURE;
}
catch ( ... )
{
std::cerr << "### Unknown exception." << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
-------------------------------------
Hi-Tech Gears Limited, Gurgaon, India
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users