2009-02-17 00:42:31 +01:00
|
|
|
#ifndef MAPSOURCE_H
|
|
|
|
#define MAPSOURCE_H
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <cmath>
|
|
|
|
#include <fstream>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include <boost/tokenizer.hpp>
|
|
|
|
#include <mapnik/map.hpp>
|
|
|
|
#include <mapnik/layer.hpp>
|
|
|
|
#include <mapnik/envelope.hpp>
|
|
|
|
#include <mapnik/agg_renderer.hpp>
|
|
|
|
#include <mapnik/image_util.hpp>
|
|
|
|
#include <mapnik/load_map.hpp>
|
|
|
|
#include <mapnik/datasource_cache.hpp>
|
|
|
|
#include <mapnik/font_engine_freetype.hpp>
|
|
|
|
#include <mapnik/projection.hpp>
|
|
|
|
#include "MapSource.h"
|
|
|
|
#include "GoogleProjection.h"
|
|
|
|
|
|
|
|
|
|
|
|
using namespace mapnik;
|
|
|
|
|
|
|
|
|
|
|
|
class MapSource
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::string source; // osm. postgis or api
|
|
|
|
std::string osmfile;
|
|
|
|
std::string xmlfile;
|
|
|
|
std::string url;
|
|
|
|
std::string outfile;
|
|
|
|
int width, height;
|
|
|
|
double w,s,e,n;
|
|
|
|
bool useBbox, tiled, multirqst;
|
|
|
|
int zoom_start,zoom_end;
|
2009-02-17 00:54:07 +01:00
|
|
|
bool srtm;
|
2009-02-17 00:42:31 +01:00
|
|
|
|
|
|
|
static void setOSMLayers(Map& m, const parameters &p);
|
|
|
|
static void addSRTMLayers(Map& m,double w,double s,double e,double n);
|
|
|
|
|
|
|
|
public:
|
|
|
|
MapSource()
|
|
|
|
{
|
|
|
|
osmfile="";
|
|
|
|
source="";
|
|
|
|
xmlfile="";
|
|
|
|
outfile="";
|
|
|
|
width=height=-1;
|
|
|
|
w=-181;
|
|
|
|
e=181;
|
|
|
|
n=91;
|
|
|
|
s=-91;
|
|
|
|
zoom_start=zoom_end=-1;
|
|
|
|
tiled=false;
|
|
|
|
multirqst=false;
|
|
|
|
//url="http://xapi.openstreetmap.org/api/0.5/map";
|
|
|
|
url="http://osmxapi.hypercube.telascience.org/api/0.5/map";
|
2009-02-17 00:54:07 +01:00
|
|
|
srtm=false;
|
2009-02-17 00:42:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool isValid()
|
|
|
|
{
|
|
|
|
return xmlfile!="" && ((tiled==false&&outfile!="" &&
|
|
|
|
width>0 && height>0) ||
|
|
|
|
(tiled==true&&zoom_start>=0)) &&
|
|
|
|
((source=="osm" && osmfile!="" && width>0 && height>0) ||
|
|
|
|
(source=="api" && hasBbox() && zoom_start>=0 && tiled==true));
|
|
|
|
}
|
|
|
|
|
|
|
|
void setSource(const std::string & src)
|
|
|
|
{
|
|
|
|
if(src=="api" || src=="osm")
|
|
|
|
{
|
|
|
|
source=src;
|
|
|
|
if(src=="api")
|
|
|
|
width=height=256;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getSource()
|
|
|
|
{
|
|
|
|
return source;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasBbox()
|
|
|
|
{
|
|
|
|
return w>=-180 && w<=180 && s>=-90 && s<=90
|
|
|
|
&& e>=-180 && e<=180 && n>=-90 && n<=90 && w<e && s<n;
|
|
|
|
}
|
|
|
|
|
|
|
|
void process_cmd_line_args(int argc,char *argv[]);
|
|
|
|
void generateMaps();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|