2007-08-07 17:09:41 +02:00
|
|
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
2011-10-23 15:04:25 +02:00
|
|
|
* Copyright (C) 2011 Artem Pavlenko
|
2007-08-07 17:09:41 +02:00
|
|
|
*
|
|
|
|
* Mapnik is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
//$Id$
|
|
|
|
|
2009-06-30 18:23:50 +02:00
|
|
|
// qt
|
2007-08-07 17:09:41 +02:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QStringList>
|
2010-06-18 12:53:57 +02:00
|
|
|
#include <QSettings>
|
2007-08-07 17:09:41 +02:00
|
|
|
#include <mapnik/datasource_cache.hpp>
|
|
|
|
#include <mapnik/font_engine_freetype.hpp>
|
|
|
|
#include "mainwindow.hpp"
|
2009-06-30 18:23:50 +02:00
|
|
|
// boost
|
|
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
#include <boost/filesystem/operations.hpp>
|
|
|
|
|
2010-06-18 12:53:57 +02:00
|
|
|
|
|
|
|
int main( int argc, char **argv )
|
|
|
|
{
|
|
|
|
using mapnik::datasource_cache;
|
2010-07-16 01:08:02 +02:00
|
|
|
using mapnik::freetype_engine;
|
2010-06-18 12:53:57 +02:00
|
|
|
|
|
|
|
QCoreApplication::setOrganizationName("Mapnik");
|
|
|
|
QCoreApplication::setOrganizationDomain("mapnik.org");
|
|
|
|
QCoreApplication::setApplicationName("Viewer");
|
|
|
|
|
|
|
|
QSettings settings("viewer.ini",QSettings::IniFormat);
|
|
|
|
|
|
|
|
// register input plug-ins
|
|
|
|
QString plugins_dir = settings.value("mapnik/plugins_dir",
|
2010-07-16 01:08:02 +02:00
|
|
|
QVariant("/usr/local/lib/mapnik2/input/")).toString();
|
2010-06-18 12:53:57 +02:00
|
|
|
datasource_cache::instance()->register_datasources(plugins_dir.toStdString());
|
|
|
|
// register fonts
|
|
|
|
int count = settings.beginReadArray("mapnik/fonts");
|
|
|
|
for (int index=0; index < count; ++index)
|
|
|
|
{
|
|
|
|
settings.setArrayIndex(index);
|
|
|
|
QString font_dir = settings.value("dir").toString();
|
2010-07-16 01:08:02 +02:00
|
|
|
freetype_engine::register_fonts(font_dir.toStdString());
|
2010-06-18 12:53:57 +02:00
|
|
|
}
|
|
|
|
settings.endArray();
|
|
|
|
|
2010-06-15 14:27:26 +02:00
|
|
|
QApplication app( argc, argv );
|
|
|
|
MainWindow window;
|
|
|
|
window.show();
|
|
|
|
if (argc > 1) window.open(argv[1]);
|
2010-06-17 10:26:08 +02:00
|
|
|
if (argc >= 3)
|
2010-06-15 14:27:26 +02:00
|
|
|
{
|
|
|
|
QStringList list = QString(argv[2]).split(",");
|
|
|
|
if (list.size()==4)
|
|
|
|
{
|
|
|
|
bool ok;
|
|
|
|
double x0 = list[0].toDouble(&ok);
|
|
|
|
double y0 = list[1].toDouble(&ok);
|
|
|
|
double x1 = list[2].toDouble(&ok);
|
|
|
|
double y1 = list[3].toDouble(&ok);
|
|
|
|
if (ok) window.set_default_extent(x0,y0,x1,y1);
|
|
|
|
}
|
|
|
|
}
|
2010-06-15 14:28:30 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
window.zoom_all();
|
2010-06-17 10:26:08 +02:00
|
|
|
}
|
|
|
|
if (argc == 4)
|
|
|
|
{
|
|
|
|
bool ok;
|
|
|
|
double scaling_factor = QString(argv[3]).toDouble(&ok);
|
|
|
|
if (ok) window.set_scaling_factor(scaling_factor);
|
|
|
|
}
|
2010-06-15 14:27:26 +02:00
|
|
|
return app.exec();
|
2007-08-07 17:09:41 +02:00
|
|
|
}
|