2009-02-15 14:51:07 +01:00
|
|
|
#include "dataset_deliverer.h"
|
|
|
|
#include "basiccurl.h"
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
osm_dataset * dataset_deliverer::dataset=NULL;
|
2009-02-17 00:10:58 +01:00
|
|
|
std::string dataset_deliverer::last_bbox = "";
|
2009-02-15 14:51:07 +01:00
|
|
|
|
|
|
|
osm_dataset* dataset_deliverer::load_from_file(const string& file,
|
|
|
|
const string& parser)
|
|
|
|
{
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
}
|
|
|
|
return dataset;
|
|
|
|
}
|
|
|
|
|
|
|
|
osm_dataset* dataset_deliverer::load_from_url
|
|
|
|
(const string& url,const string& bbox,const string& parser)
|
|
|
|
{
|
2009-02-17 00:10:58 +01:00
|
|
|
|
2009-02-15 14:51:07 +01: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);
|
2009-02-17 00:10:58 +01:00
|
|
|
last_bbox = bbox;
|
2009-02-15 14:51:07 +01:00
|
|
|
}
|
2009-02-17 00:10:58 +01:00
|
|
|
else if (bbox != last_bbox)
|
|
|
|
{
|
2009-04-28 22:07:18 +02:00
|
|
|
#ifdef MAPNIK_DEBUG
|
2009-02-17 00:10:58 +01:00
|
|
|
cerr<<"BBOXES ARE DIFFERENT: " << last_bbox<<","<<bbox<<endl;
|
2009-04-28 22:07:18 +02:00
|
|
|
#endif
|
|
|
|
|
2009-02-17 00:10:58 +01:00
|
|
|
// Reload the dataset
|
|
|
|
dataset->clear();
|
|
|
|
if(dataset->load_from_url(url.c_str(),bbox,parser)==false)
|
|
|
|
return NULL;
|
|
|
|
last_bbox = bbox;
|
|
|
|
}
|
|
|
|
return dataset;
|
2009-02-15 14:51:07 +01:00
|
|
|
}
|