|
| 1 | + |
| 2 | +#include "maprenderertest.h" |
| 3 | + |
| 4 | +#include <QApplication> |
| 5 | +#include <QPainter> |
| 6 | +#include <QPaintEvent> |
| 7 | + |
| 8 | +#include "qgsapplication.h" |
| 9 | +#include "qgsvectorlayer.h" |
| 10 | +#include "qgsmaplayerregistry.h" |
| 11 | + |
| 12 | +#include "qgsmapcanvas.h" |
| 13 | +#include "qgsmaptoolpan.h" |
| 14 | + |
| 15 | +int main(int argc, char* argv[]) |
| 16 | +{ |
| 17 | + QApplication app(argc, argv); |
| 18 | + |
| 19 | + QgsApplication::setPrefixPath("/home/martin/qgis/git-master/creator/output", true); |
| 20 | + QgsApplication::initQgis(); |
| 21 | + |
| 22 | + QString uri = "dbname='/data/gis/praha.osm.db' table=\"praha_polygons\" (geometry) sql="; |
| 23 | + QString uri2 = "dbname='/data/gis/praha.osm.db' table=\"praha_polylines\" (geometry) sql="; |
| 24 | + //QString uri = "/data/gis/cr-shp-wgs84/plochy/kraje_pseudo.shp"; |
| 25 | + QgsVectorLayer* layer = new QgsVectorLayer(uri, "praha", "spatialite"); |
| 26 | + if (!layer->isValid()) |
| 27 | + { |
| 28 | + qDebug("invalid layer"); |
| 29 | + return 1; |
| 30 | + } |
| 31 | + QgsMapLayerRegistry::instance()->addMapLayer(layer); |
| 32 | + |
| 33 | + QgsVectorLayer* layer2 = new QgsVectorLayer(uri2, "praha", "spatialite"); |
| 34 | + if (!layer2->isValid()) |
| 35 | + { |
| 36 | + qDebug("invalid layer"); |
| 37 | + return 1; |
| 38 | + } |
| 39 | + QgsMapLayerRegistry::instance()->addMapLayer(layer2); |
| 40 | + |
| 41 | + // open a window and do the rendering! |
| 42 | + /*TestWidget l(layer); |
| 43 | + l.resize(360,360); |
| 44 | + l.show();*/ |
| 45 | + |
| 46 | + QgsMapCanvas canvas; |
| 47 | + canvas.setCanvasColor(Qt::white); |
| 48 | + canvas.setExtent(layer->extent()); |
| 49 | + |
| 50 | + QList<QgsMapCanvasLayer> layers; |
| 51 | + layers.append(QgsMapCanvasLayer(layer2)); |
| 52 | + layers.append(QgsMapCanvasLayer(layer)); |
| 53 | + canvas.setLayerSet(layers); |
| 54 | + |
| 55 | + QgsMapTool* pan = new QgsMapToolPan(&canvas); |
| 56 | + canvas.setMapTool(pan); |
| 57 | + |
| 58 | + canvas.show(); |
| 59 | + |
| 60 | + return app.exec(); |
| 61 | +} |
0 commit comments