Skip to content
Snippets Groups Projects
Commit 71e0e2b2 authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

ENH: better handling of projections for VectorDataToImageFilter

parent f714626b
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,8 @@
#include <mapnik/value.hpp>
#include "ogr_spatialref.h"
namespace otb
{
......@@ -210,10 +212,23 @@ namespace otb
VectorDataConstPointer input = this->GetInput();
InternalTreeNodeType * inputRoot = const_cast<InternalTreeNodeType *>(input->GetDataTree()->GetRoot());
std::string vectorDataProjection;
// itk::ExposeMetaData<std::string>(input->GetMetaDataDictionary(), MetaDataKey::ProjectionRefKey, vectorDataProjection);
vectorDataProjection = "+proj=utm +zone=31 +ellps=WGS84";
m_Map.set_srs(vectorDataProjection);
//Converting the projection string to the porj.4 format
std::string vectorDataProjectionWKT;
itk::ExposeMetaData<std::string>(input->GetMetaDataDictionary(), MetaDataKey::ProjectionRefKey, vectorDataProjectionWKT);
// OGRSpatialReference oSRS;
// oSRS.importFromWkt(vectorDataProjectionWKT.c_str());
// std::cout << "WKT -> " << vectorDataProjectionWKT << std::endl;
OGRSpatialReference oSRS(vectorDataProjectionWKT.c_str());
char * pszProj4;
oSRS.exportToProj4(&pszProj4);
std::string vectorDataProjectionProj4(pszProj4);
CPLFree(pszProj4);
// std::cout << "Proj.4 -> " << vectorDataProjectionProj4 << std::endl;
// std::string vectorDataProjectionProj4 = "+proj=utm +zone=31 +ellps=WGS84";
m_Map.set_srs(vectorDataProjectionProj4);
ProcessNode(inputRoot,mDatasource);
......@@ -221,6 +236,7 @@ namespace otb
std::cout << "Datasource size: " << mDatasource->size() << std::endl;
mapnik::Layer lyr("world");
lyr.set_srs(vectorDataProjectionProj4);
lyr.set_datasource(mDatasource);
// lyr.add_style("river");
lyr.add_style("minor-roads-casing");
......@@ -352,6 +368,7 @@ namespace otb
// std::cout << " -> " << (*mfeature)["name"] << std::endl;
// std::cout << "Type: " << dataNode->GetFieldAsString("type") << std::endl;
// std::cout << "OSM ID: " << dataNode->GetFieldAsString("osm_id") << std::endl;
boost::put(*mfeature, "highway", tr.transcode((dataNode->GetFieldAsString("type")).c_str()));
mDatasource->push(mfeature);
......
......@@ -88,7 +88,7 @@ int otbVectorDataToImageFilter(int argc, char * argv[])
typedef otb::VectorDataExtractROI<VectorDataType> ExtractROIType;
ExtractROIType::Pointer extractROI = ExtractROIType::New();
extractROI->SetRegion(region);
extractROI->SetInput(reader->GetOutput());
extractROI->SetInput(projection->GetOutput());
typedef otb::VectorDataToImageFilter<VectorDataType, ImageType> VectorDataToImageFilterType;
VectorDataToImageFilterType::Pointer vectorDataRendering = VectorDataToImageFilterType::New();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment