mapnik/plugins/input/osm/dataset_deliverer.cpp

57 lines
1.4 KiB
C++
Raw Normal View History

#include "dataset_deliverer.h"
#include "basiccurl.h"
#include <sstream>
osm_dataset * dataset_deliverer::dataset=NULL;
std::string dataset_deliverer::last_bbox = "";
std::string dataset_deliverer::last_filename = "";
osm_dataset* dataset_deliverer::load_from_file(const string& file,
2011-04-02 03:45:50 +00:00
const string& parser)
{
2011-04-02 03:45:50 +00:00
// Only actually load from file if we haven't done so already
if(dataset == NULL)
{
dataset = new osm_dataset;
if(dataset->load(file.c_str(),parser)==false)
return NULL;
atexit(dataset_deliverer::release);
last_filename = file;
}
else if(file != last_filename)
{
dataset = new osm_dataset;
if(dataset->load(file.c_str(),parser)==false)
return NULL;
last_filename = file;
}
return dataset;
}
osm_dataset* dataset_deliverer::load_from_url
2011-04-02 03:45:50 +00:00
(const string& url,const string& bbox,const string& parser)
{
2011-04-02 03:45:50 +00:00
if(dataset==NULL)
{
dataset = new osm_dataset;
if(dataset->load_from_url(url.c_str(),bbox,parser)==false)
return NULL;
atexit(dataset_deliverer::release);
last_bbox = bbox;
}
else if (bbox != last_bbox)
{
#ifdef MAPNIK_DEBUG
2011-04-02 03:45:50 +00:00
cerr<<"BBOXES ARE DIFFERENT: " << last_bbox<<","<<bbox<<endl;
#endif
2011-04-02 03:45:50 +00:00
// Reload the dataset
dataset->clear();
if(dataset->load_from_url(url.c_str(),bbox,parser)==false)
return NULL;
last_bbox = bbox;
}
return dataset;
}