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

ENH: parameter matching OTB QB image

parent 9950a87d
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
#include "otbImageFileWriter.h"
#include "otbVectorData.h"
#include "otbVectorDataProjectionFilter.h"
#include "otbVectorDataExtractROI.h"
#include <fstream>
#include <iostream>
......@@ -28,24 +29,55 @@ int main(int argc, char * argv[])
ProjectionFilterType::Pointer projection = ProjectionFilterType::New();
projection->SetInput(reader->GetOutput());
// projection->Update();
std::string projectionRefWkt ="PROJCS[\"UTM Zone 31, Northern Hemisphere\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4326\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",3],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1]]";
projection->SetOutputProjectionRef(projectionRefWkt);
//Convert the vector data into an image
typedef itk::RGBAPixel< unsigned char > PixelType;
typedef otb::Image<PixelType,2> ImageType;
ImageType::SizeType size;
// size[0] = 1000;
// size[1] = 1000;
size[0] = 500;
size[1] = 500;
ImageType::PointType origin;
// origin[0] = 1.3769;//UL lon
// origin[1] = 43.5455;//UL lat
origin[0] = 374149.980555821;//UL easting
origin[1] = 4829183.99443839;//UL northing
ImageType::SpacingType spacing;
// spacing[0] = 0.00002;
// spacing[1] = -0.00002;
spacing[0] = 0.6;
spacing[1] = -0.6;
typedef otb::RemoteSensingRegion<double> RegionType;
RegionType region;
RegionType::SizeType sizeInUnit;
sizeInUnit[0] = size[0]*spacing[0];
sizeInUnit[1] = size[1]*spacing[1];
region.SetSize(sizeInUnit);
region.SetOrigin(origin);
region.SetRegionProjection(projectionRefWkt);
typedef otb::VectorDataExtractROI<VectorDataType> ExtractROIType;
ExtractROIType::Pointer extractROI = ExtractROIType::New();
extractROI->SetRegion(region);
extractROI->SetInput(reader->GetOutput());
typedef otb::VectorDataToImageFilter<VectorDataType, ImageType> VectorDataToImageFilterType;
VectorDataToImageFilterType::Pointer vectorDataRendering = VectorDataToImageFilterType::New();
vectorDataRendering->SetInput(projection->GetOutput());
ImageType::SizeType size;
size[0] = 1000;
size[1] = 1000;
vectorDataRendering->SetInput(extractROI->GetOutput());
vectorDataRendering->SetSize(size);
ImageType::PointType origin;
origin[0] = 1.3769;//UL lon
origin[1] = 43.5455;//UL lat
vectorDataRendering->SetOrigin(origin);
ImageType::SpacingType spacing;
spacing[0] = 0.00002;
spacing[1] = -0.00002;
vectorDataRendering->SetSpacing(spacing);
......
......@@ -210,6 +210,11 @@ 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);
ProcessNode(inputRoot,mDatasource);
......@@ -314,7 +319,8 @@ namespace otb
// }
case otb::FEATURE_LINE:
{
std::cout << std::setprecision(15) << " ** Inserting new line **" << std::endl;
std::cout << std::setprecision(15);
// std::cout << " ** Inserting new line **" << std::endl;
typedef mapnik::vertex<double,2> vertex2d;
typedef mapnik::line_string<vertex2d,mapnik::vertex_vector2> line2d;
typedef boost::shared_ptr<line2d> line_ptr;
......@@ -329,35 +335,23 @@ namespace otb
++itVertex;
}
std::cout << "Num points: " << line->num_points() << std::endl;
// std::cout << "Num points: " << line->num_points() << std::endl;
typedef boost::shared_ptr<mapnik::raster> raster_ptr;
typedef mapnik::feature<mapnik::geometry2d,raster_ptr> Feature;
typedef boost::shared_ptr<Feature> feature_ptr;
// typedef std::map<std::string,mapnik::value> mapType;
// mapType myMap;
// myMap["name"] = mapnik::value("test");
// std::cout << myMap.size() << std::endl;
feature_ptr mfeature = feature_ptr(new Feature(1));
// feature_ptr mfeature = feature_ptr(new Feature(myMap));
mfeature->add_geometry(line);
// mfeature->properties().insert(make_pair(std::string("name"),
// std::string("test")));
// boost::put(*mfeature, "name", mapnik::value("test"));
mapnik::transcoder tr("ISO-8859-15");
// std::cout << dataNode->GetNodeTypeAsString() << std::endl;
// std::cout << "Name: " << dataNode->GetFieldAsString("name") << std::endl;
boost::put(*mfeature, "name", tr.transcode((dataNode->GetFieldAsString("name")).c_str()));
// boost::put(*mfeature, "name2", 10);
std::cout << mfeature->props().size() << std::endl;
std::cout << " -> " << (*mfeature)["name"] << std::endl;
// std::cout << " -> " << (*mfeature)["name2"] << std::endl;
std::cout << "Type: " << dataNode->GetFieldAsString("type") << std::endl;
// std::cout << mfeature->props().size() << std::endl;
// std::cout << " -> " << (*mfeature)["name"] << std::endl;
// std::cout << "Type: " << dataNode->GetFieldAsString("type") << std::endl;
boost::put(*mfeature, "highway", tr.transcode((dataNode->GetFieldAsString("type")).c_str()));
mDatasource->push(mfeature);
......
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