[Qgis-developer] Problems with reprojecting to mercator
hubbatov
hubbatov at mail.ru
Fri Oct 18 00:47:52 PDT 2013
Ok, how can i set extent to layers extent?
QgsApplication a(argc,argv, true);
QgsProviderRegistry::instance("/usr/local/lib/qgis/plugins");
a.setPkgDataPath(QDir::homePath() + QDir::separator() + ".harver/");
QgsMapCanvas *canvas = new QgsMapCanvas(0, 0);
canvas->enableAntiAliasing(true);
canvas->useImageToRender(false);
canvas->setCanvasColor(QColor(255, 255, 255));
canvas->freeze(false);
canvas->setVisible(true);
canvas->refresh();
canvas->show();
QgsCoordinateReferenceSystem pseudo_mercator(3857,
QgsCoordinateReferenceSystem::PostgisCrsId);
QgsCoordinateReferenceSystem wgs84_4326(4326,
QgsCoordinateReferenceSystem::PostgisCrsId);
canvas->mapRenderer()->setProjectionsEnabled(true);
canvas->mapRenderer()->setDestinationCrs(pseudo_mercator);
canvas->mapRenderer()->setMapUnits(pseudo_mercator.mapUnits());
QgsVectorLayer *layer = new
QgsVectorLayer("/home/xumuk/shapes/fields_r.SHP", "fields", "ogr");
QgsSingleSymbolRenderer *renderer = new
QgsSingleSymbolRenderer(layer->geometryType());
layer->setRenderer(renderer);
layer->setCrs(wgs84_4326);
layer->updateExtents();
QgsMapLayerRegistry::instance()->addMapLayers(QList<QgsMapLayer*>() <<
layer);
QList<QgsMapCanvasLayer> layerSet;
layerSet.append(QgsMapCanvasLayer(layer));
canvas->setExtent(layer->extent()); <====== here i have degrees, but i need
to set extent in pseudo_mercator.mapUnits
canvas->setLayerSet(layerSet);
canvas->refresh();
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Problems-with-reprojecting-to-mercator-tp5082191p5084362.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
More information about the Qgis-developer
mailing list