Skip to content
Snippets Groups Projects
Commit 71988920 authored by Etienne Bougoin's avatar Etienne Bougoin
Browse files

ENH : add automatic fileSuffix and addressMode configuration when filename is a server name

parent 96497802
Branches
Tags
No related merge requests found
...@@ -316,6 +316,7 @@ void TileMapImageIO::BuildFileName(const std::ostringstream& quad, std::ostrings ...@@ -316,6 +316,7 @@ void TileMapImageIO::BuildFileName(const std::ostringstream& quad, std::ostrings
void TileMapImageIO::RetrieveTile(const std::ostringstream & filename, std::ostringstream & urlStream) const void TileMapImageIO::RetrieveTile(const std::ostringstream & filename, std::ostringstream & urlStream) const
{ {
FILE* output_file = fopen(filename.str().c_str(), "w"); FILE* output_file = fopen(filename.str().c_str(), "w");
if (output_file == NULL) if (output_file == NULL)
{ {
itkExceptionMacro(<<"TileMap read : bad file name."); itkExceptionMacro(<<"TileMap read : bad file name.");
...@@ -467,6 +468,25 @@ void TileMapImageIO::ReadImageInformation() ...@@ -467,6 +468,25 @@ void TileMapImageIO::ReadImageInformation()
{ {
itkExceptionMacro(<<"Can't read server name from file"); itkExceptionMacro(<<"Can't read server name from file");
} }
std::string osmServer = "http://tile.openstreetmap.org/";
std::string nmServer = "http://www.nearmap.com/maps/";
if (m_ServerName == osmServer)
{
m_FileSuffix = "png";
m_AddressMode = TileMapAdressingStyle::OSM;
}
else if (m_ServerName == nmServer)
{
m_FileSuffix = "jpg";
m_AddressMode = TileMapAdressingStyle::NEARMAP;
}
else
{
m_FileSuffix = "jpg";
m_AddressMode = TileMapAdressingStyle::GM;
}
// File suffix and addres mode must be set with accessors // File suffix and addres mode must be set with accessors
otbMsgDevMacro( << "File parameters: " << m_ServerName << " " << m_FileSuffix << " " << m_AddressMode); otbMsgDevMacro( << "File parameters: " << m_ServerName << " " << m_FileSuffix << " " << m_AddressMode);
} }
......
...@@ -95,9 +95,6 @@ public: ...@@ -95,9 +95,6 @@ public:
itkGetMacro(Depth, int); itkGetMacro(Depth, int);
itkGetStringMacro(CacheDirectory); itkGetStringMacro(CacheDirectory);
itkSetStringMacro(FileSuffix);
itkSetMacro(AddressMode, TileMapAdressingStyle::TileMapAdressingStyle);
/** Determine the file type. Returns true if this ImageIO can read the /** Determine the file type. Returns true if this ImageIO can read the
* file specified. */ * file specified. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment