Commit 811f7ed0 authored by Otmane Lahlou's avatar Otmane Lahlou

ENH : rename example to put kmz and mapfile generation in the same example

parent e7bc7953
......@@ -407,7 +407,6 @@ MapFileProductWriter<TInputImage>
// Write the IndexTile
typename VectorDataFileWriterType::Pointer writer = VectorDataFileWriterType::New();
writer->SetFileName(m_IndexShapeFileName);
std::cout <<" ---> Writing the vectordata : "<<m_IndexShapeFileName << std::endl;
writer->SetInput(m_VectorDataIndexTile);
writer->Update();
......@@ -536,7 +535,7 @@ MapFileProductWriter<TInputImage>
m_File <<"\t\tMETADATA" << std::endl;
m_File <<"\t\t 'wms_title' 'Level0'" << std::endl;
m_File <<"\t\t \'wms_onlineresource\' \'"<<m_CGIPath<<"?map="<<m_FileName<<"&\'" << std::endl;
m_File <<"\t\t \'wms_srs\' \'EPSG:"<<m_SRID<<" EPSG:900913\'" << std::endl; // TODO : guess the EPSG used
m_File <<"\t\t \'wms_srs\' \'EPSG:"<<m_SRID<<" EPSG:900913\'" << std::endl;
m_File <<"\t\tEND" << std::endl;
m_File <<"\tEND" << std::endl;
......@@ -565,7 +564,9 @@ MapFileProductWriter<TInputImage>
m_File <<"\t\t\tPROJECTION" << std::endl;
m_File <<"\t\t\t \"init=epsg:"<<m_SRID<<"\"" << std::endl;
m_File <<"\t\t\tEND" << std::endl;
m_File <<"\t\t#MINSCALE 250000" << std::endl;
m_File <<"\t\t#MINSCALE 250000" << std::endl; // TODO : problem with
// the MINSCALE AND
// MAXSCALE ..
m_File <<"\tEND" << std::endl;
}
......
......@@ -117,8 +117,8 @@ ENDIF( OTB_USE_CURL )
#ADD_EXECUTABLE(TransformReadWrite TransformReadWrite.cxx )
#TARGET_LINK_LIBRARIES(TransformReadWrite)
ADD_EXECUTABLE(ImageToKmzChain ImageToKmzChain.cxx)
TARGET_LINK_LIBRARIES(ImageToKmzChain OTBIO)
ADD_EXECUTABLE(ImageToKmzAndMapFileProductExample ImageToKmzAndMapFileProductExample.cxx)
TARGET_LINK_LIBRARIES(ImageToKmzAndMapFileProductExample OTBIO)
IF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING )
......@@ -169,14 +169,15 @@ ADD_TEST(ioTeDEMToImageGeneratorTest ${EXE_TESTS1}
${INPUTDATA}/DEM_srtm
)
# Testing the chain of creating a kmz from
# Testing the chain of creating a kmz and MapFilefrom
# a non georeferenced image
ADD_TEST(ioImageToKmzChain ${EXE_TESTS1}
#--compare-image ${EPSILON_5} ${BASELINE}/DEMToImageGenerator.tif
# ${TEMP}/DEMToImageGenerator.tif
ImageToKmzChain
ADD_TEST(ioImageToKmzAndMapFileProductExample ${EXE_TESTS1}
ImageToKmzAndMapFileProductExample
${DATA}/Haiti1.jpeg
${TEMP}/ioTeHaitiKmzProduct.kmz
${TEMP}/mapserverExample/ioTeHaitiMapFileProduct.map
${TEMP}/mapserverExample/shapeindex
http://localhost/cgi-bin/mapserv
1980.000000 1986.000000 -72.351257 18.555075 0.000000
1963.000000 1944.000000 -72.352051 18.556946 0.000000
2078.000000 1566.000000 -72.346130 18.574358 0.000000
......
......@@ -19,18 +19,23 @@
// Software Guide : BeginLatex
//
// This example demonstrates the use of the
// \doxygen{otb}{KmzProductWriter}. This filter is intended to
// produce Kmz file (Google Earth Readable). In this example we will
// use a file with no meta-data, use the
// \doxygen{otb}{KmzProductWriter} and the
// \doxygen{otb}{MapFileProductWriter}.
// The first filter is intended to produce Kmz file (Google Earth
// Readable), and the second one is intended to produce map files
// callable through a WMS (Web Map Service) service. In this example
// we will use a file with no meta-data, use the
// \doxygen{otb}{GGCPToRPCSensorModelImageFilter} in order to
// approximate a rpc model, and then use our filter to produce a kmz
// file.
// Note that the \doxygen{otb}{KmzProductWriter} can only process
// inputs with a non empty keyword list.
// approximate a rpc model, and then use our filters to produce a kmz
// and MapFile products.
// Note that the \doxygen{otb}{KmzProductWriter} and the
// \doxygen{otb}{MapFileProductWriter} can only process inputs with a
// non empty keyword list.
//
// The first step toward the use of these filters is to include the
// proper header files: the one for the rpc sensor estimation filter and
// the one defining the procedure for creating kmz files.
// the one defining the procedure for creating kmz files and finally
// the header concerning the MapProduct writer.
//
// Software Guide : EndLatex
......@@ -40,6 +45,7 @@
// Software Guide : BeginCodeSnippet
#include "otbKmzProductWriter.h"
#include "otbMapFileProductWriter.h"
#include "otbGCPsToRPCSensorModelImageFilter.h"
// Software Guide : EndCodeSnippet
//
......@@ -47,18 +53,17 @@
int main(int argc, char* argv[])
{
if (argc < 3)
if (argc < 6)
{
std::cerr << "Usage: " << argv[0] << " infname outfname kmzFileName a1x a1y b1x b1y b1z ... aNx aNy aNz bNx bNy bNz" << std::endl;
return EXIT_FAILURE;
}
else if ((argc - 3) % 5 != 0)
else if ((argc - 6) % 5 != 0)
{
std::cerr << "Inconsistent GCPs description!" << std::endl;
return EXIT_FAILURE;
}
// Software Guide : BeginLatex
//
// We will start by defining the types for the image and the image file
......@@ -90,7 +95,7 @@ int main(int argc, char* argv[])
rpcEstimator->SetInput(reader->GetOutput());
// Software Guide : EndCodeSnippet
unsigned int nbGCPs = (argc - 3) / 5;
unsigned int nbGCPs = (argc - 6) / 5;
std::cout << "Receiving " << nbGCPs << " from command line." << std::endl;
......@@ -111,13 +116,13 @@ int main(int argc, char* argv[])
// Software Guide : BeginCodeSnippet
Point2DType sensorPoint;
sensorPoint[0] = atof(argv[3 + gcpId * 5]);
sensorPoint[1] = atof(argv[4 + gcpId * 5]);
sensorPoint[0] = atof(argv[6 + gcpId * 5]);
sensorPoint[1] = atof(argv[7 + gcpId * 5]);
Point3DType geoPoint;
geoPoint[0] = atof(argv[5 + 5 * gcpId]);
geoPoint[1] = atof(argv[6 + 5 * gcpId]);
geoPoint[2] = atof(argv[7 + 5 * gcpId]);
geoPoint[0] = atof(argv[8 + 5 * gcpId]);
geoPoint[1] = atof(argv[9 + 5 * gcpId]);
geoPoint[2] = atof(argv[10+ 5 * gcpId]);
rpcEstimator->AddGCP(sensorPoint, geoPoint);
// Software Guide : EndCodeSnippet
......@@ -133,9 +138,9 @@ int main(int argc, char* argv[])
//
// The last step of the chain, is to export the image to a Google
// Earth understandable format using the KmzProductWriter. Note that
// the writer can associate legend via the method
// AddLegend(std::string description,ImageType * legend) and a logo
// SetLogo(ImageType*) to the kmz.
// the writer can add legends via the method
// AddLegend(std::string description,ImageType * legend) and a logo in
// the kmz using SetLogo(ImageType*).
//
// Software Guide : EndLatex
......@@ -158,5 +163,46 @@ int main(int argc, char* argv[])
kmzWriter->Update();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// The Mapfile is the heart of MapServer. It defines the relationships
// between objects, points MapServer (http://mapserver.org/) to where
// data are located and defines how things are to be drawn. The class
// \doxygen{otb}{MapFileProductWriter} allow producing the mapserver
// configuration file, the tiles to draw, and shapefiles descrining
// the tiles and where to find them.
// The Mapfile writer allow setting the complete path to the mapfile
// via SetFileName(std::string),the path where to store the tiles via
// the method SetShapeIndexPath() and finally the path to the cgi-bin
// to use via the method SetGCIPath().
//
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::MapFileProductWriter<ImageType> MapFileProductWriterType;
MapFileProductWriterType::Pointer mapWriter = MapFileProductWriterType::New();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// The user can also specify a Spatial Reference System Identifier
// (SRID) to choose his projection. In this example we choose WGS84 to
// project our datas in. The SRID relative to WGS84 is 4326.
// Finally, we trigger the MapFile writting by calling the
// \code{Update()} method on the writer.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
mapWriter->SetInput(rpcEstimator->GetOutput());
mapWriter->SetFileName(argv[3]);
mapWriter->SetShapeIndexPath(argv[4]);
mapWriter->SetCGIPath(argv[5]);
mapWriter->SetSRID(4326);
mapWriter->Update();
// Software Guide : EndCodeSnippet
return EXIT_SUCCESS;
}
......@@ -28,8 +28,7 @@ void RegisterTests()
{
REGISTER_TEST(ExtractROITest);
REGISTER_TEST(DEMToImageGeneratorTest);
REGISTER_TEST(ImageToKmzChain);
REGISTER_TEST(ImageToKmzAndMapFileProductExample);
}
#undef main
......@@ -41,5 +40,5 @@ void RegisterTests()
#include "DEMToImageGenerator.cxx"
#undef main
#define main ImageToKmzChain
#include "ImageToKmzChain.cxx"
#define main ImageToKmzAndMapFileProductExample
#include "ImageToKmzAndMapFileProductExample.cxx"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment