From ae75e682664a522b89d5eda3393e7d8e75cdac20 Mon Sep 17 00:00:00 2001
From: Emmanuel Christophe <emmanuel.christophe@orfeo-toolbox.org>
Date: Thu, 30 Apr 2009 17:29:59 +0800
Subject: [PATCH] ENH: Region extraction specification

---
 mapnikOTBClasses.cxx           | 13 +++++++++++--
 otbVectorDataToImageFilter.txx | 11 ++++++++---
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/mapnikOTBClasses.cxx b/mapnikOTBClasses.cxx
index 196aebe662..232c218a62 100644
--- a/mapnikOTBClasses.cxx
+++ b/mapnikOTBClasses.cxx
@@ -11,6 +11,7 @@
 
 //  ./mapnikOTBClasses /home/christop/OTB/trunk/OTB-Data/Input/waterways.shp output.png
 //  ./mapnikOTBClasses ~/OTB/trunk/OTB-Data/Input/ToulouseRoad-examples.shp output.png
+//  ./mapnikOTBClasses ~/OTB/trunk/OTB-Data/LargeInput/VECTOR/MidiPyrenees/roads.shp output.png
 
 int main(int argc, char * argv[])
 {
@@ -35,9 +36,17 @@ int main(int argc, char * argv[])
   VectorDataToImageFilterType::Pointer vectorDataRendering = VectorDataToImageFilterType::New();
   vectorDataRendering->SetInput(projection->GetOutput());
   ImageType::SizeType size;
-  size[0]=1000;
-  size[1]=1000;
+  size[0] = 1000;
+  size[1] = 1000;
   vectorDataRendering->SetSize(size);
+  ImageType::PointType origin;
+  origin[0] = 1.;//UL lon
+  origin[1] = 44;//UL lat
+  vectorDataRendering->SetOrigin(origin);
+  ImageType::SpacingType spacing;
+  spacing[0] = 0.001;
+  spacing[1] = -0.001;
+  vectorDataRendering->SetSpacing(spacing);
 
 
   //Save the image in a file
diff --git a/otbVectorDataToImageFilter.txx b/otbVectorDataToImageFilter.txx
index 5d949f2cfe..e1d6ffd2c8 100644
--- a/otbVectorDataToImageFilter.txx
+++ b/otbVectorDataToImageFilter.txx
@@ -221,9 +221,14 @@ namespace otb
 //     lyr.add_style("roads");
     m_Map.addLayer(lyr);
 
-
-    m_Map.zoomToBox(lyr.envelope());//FIXME: use the Origin/Spacing to calculate this
-    std::cout << "Envelope: " << lyr.envelope() << std::endl;
+    mapnik::Envelope<double> envelope(m_Origin[0],
+                                     m_Origin[1]+m_Spacing[1]*m_Size[1],
+                                     m_Origin[0]+m_Spacing[0]*m_Size[0],
+                                     m_Origin[1]);
+//     m_Map.zoomToBox(lyr.envelope());//FIXME: use the Origin/Spacing to calculate this
+    m_Map.zoomToBox(envelope);
+//     std::cout << "Envelope: " << lyr.envelope() << std::endl;
+    std::cout << "Envelope: " << envelope << std::endl;
 
     mapnik::Image32 buf(m_Map.getWidth(),m_Map.getHeight());
     mapnik::agg_renderer<mapnik::Image32> ren(m_Map,buf);
-- 
GitLab