remove tabs
This commit is contained in:
parent
819a67fd42
commit
5a1842aad1
40 changed files with 702 additions and 696 deletions
|
@ -27,10 +27,10 @@ install_prefix = env['DESTDIR'] + '/' + prefix
|
|||
plugin_env = env.Clone()
|
||||
|
||||
gdal_src = Split(
|
||||
"""
|
||||
gdal_datasource.cpp
|
||||
gdal_featureset.cpp
|
||||
"""
|
||||
"""
|
||||
gdal_datasource.cpp
|
||||
gdal_featureset.cpp
|
||||
"""
|
||||
)
|
||||
|
||||
libraries = [env['PLUGINS']['gdal']['lib']]
|
||||
|
|
|
@ -28,10 +28,10 @@ install_prefix = env['DESTDIR'] + '/' + prefix
|
|||
plugin_env = env.Clone()
|
||||
|
||||
geos_src = Split(
|
||||
"""
|
||||
geos_datasource.cpp
|
||||
geos_featureset.cpp
|
||||
"""
|
||||
"""
|
||||
geos_datasource.cpp
|
||||
geos_featureset.cpp
|
||||
"""
|
||||
)
|
||||
|
||||
libraries = [env['PLUGINS']['geos']['lib']]
|
||||
|
|
|
@ -27,10 +27,10 @@ install_prefix = env['DESTDIR'] + '/' + prefix
|
|||
plugin_env = env.Clone()
|
||||
|
||||
kismet_src = Split(
|
||||
"""
|
||||
kismet_datasource.cpp
|
||||
kismet_featureset.cpp
|
||||
"""
|
||||
"""
|
||||
kismet_datasource.cpp
|
||||
kismet_featureset.cpp
|
||||
"""
|
||||
)
|
||||
|
||||
libraries = []
|
||||
|
|
|
@ -27,13 +27,13 @@ install_prefix = env['DESTDIR'] + '/' + prefix
|
|||
plugin_env = env.Clone()
|
||||
|
||||
occi_src = Split(
|
||||
"""
|
||||
occi_types.cpp
|
||||
occi_datasource.cpp
|
||||
occi_featureset.cpp
|
||||
spatial_classesm.cpp
|
||||
spatial_classeso.cpp
|
||||
"""
|
||||
"""
|
||||
occi_types.cpp
|
||||
occi_datasource.cpp
|
||||
occi_featureset.cpp
|
||||
spatial_classesm.cpp
|
||||
spatial_classeso.cpp
|
||||
"""
|
||||
)
|
||||
|
||||
libraries = [ 'occi', 'ociei' ]
|
||||
|
|
|
@ -189,7 +189,7 @@ feature_ptr occi_featureset::next()
|
|||
std::clog << "OCCI Plugin: unknown datatype (type_oid=" << type_oid << ")" << std::endl;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++count_;
|
||||
|
|
|
@ -28,12 +28,12 @@ install_prefix = env['DESTDIR'] + '/' + prefix
|
|||
plugin_env = env.Clone()
|
||||
|
||||
ogr_src = Split(
|
||||
"""
|
||||
ogr_converter.cpp
|
||||
ogr_datasource.cpp
|
||||
ogr_featureset.cpp
|
||||
ogr_index_featureset.cpp
|
||||
"""
|
||||
"""
|
||||
ogr_converter.cpp
|
||||
ogr_datasource.cpp
|
||||
ogr_featureset.cpp
|
||||
ogr_index_featureset.cpp
|
||||
"""
|
||||
)
|
||||
|
||||
libraries = [env['PLUGINS']['ogr']['lib']]
|
||||
|
|
|
@ -300,7 +300,7 @@ featureset_ptr ogr_datasource::features(query const& q) const
|
|||
{
|
||||
s <<",\""<<*pos<<"\"";
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
s << " from " << layerName_ ;
|
||||
|
||||
// execute existing SQL
|
||||
|
@ -353,8 +353,8 @@ featureset_ptr ogr_datasource::features_at_point(coord2d const& pt) const
|
|||
else
|
||||
{
|
||||
OGRPoint point;
|
||||
point.setX (pt.x);
|
||||
point.setY (pt.y);
|
||||
point.setX (pt.x);
|
||||
point.setY (pt.y);
|
||||
|
||||
return featureset_ptr(new ogr_featureset (*dataset_,
|
||||
*layer_,
|
||||
|
|
|
@ -3,7 +3,7 @@ LDFLAGS = `xml2-config --libs` -L/usr/local/lib
|
|||
LDFLAGS5 = `xml2-config --libs` -L/usr/local/lib -lmapnik
|
||||
OBJ = test.o osm.o osmparser.o
|
||||
test: $(OBJ)
|
||||
g++ -o test $(OBJ) $(LDFLAGS)
|
||||
g++ -o test $(OBJ) $(LDFLAGS)
|
||||
render: render.o
|
||||
g++ -o render render.o $(LDFLAGS5)
|
||||
g++ -o render render.o $(LDFLAGS5)
|
||||
|
||||
|
|
|
@ -27,14 +27,14 @@ install_prefix = env['DESTDIR'] + '/' + prefix
|
|||
plugin_env = env.Clone()
|
||||
|
||||
osm_src = Split(
|
||||
"""
|
||||
osmparser.cpp
|
||||
osm.cpp
|
||||
osm_datasource.cpp
|
||||
osm_featureset.cpp
|
||||
dataset_deliverer.cpp
|
||||
basiccurl.cpp
|
||||
"""
|
||||
"""
|
||||
osmparser.cpp
|
||||
osm.cpp
|
||||
osm_datasource.cpp
|
||||
osm_featureset.cpp
|
||||
dataset_deliverer.cpp
|
||||
basiccurl.cpp
|
||||
"""
|
||||
)
|
||||
|
||||
libraries = [ 'xml2' ]
|
||||
|
|
|
@ -2,44 +2,44 @@
|
|||
|
||||
CURL_LOAD_DATA *grab_http_response(const char *url)
|
||||
{
|
||||
CURL_LOAD_DATA *data;
|
||||
CURL_LOAD_DATA *data;
|
||||
|
||||
CURL *curl = curl_easy_init();
|
||||
CURL *curl = curl_easy_init();
|
||||
|
||||
if(curl)
|
||||
{
|
||||
data = do_grab(curl,url);
|
||||
curl_easy_cleanup(curl);
|
||||
return data;
|
||||
}
|
||||
return NULL;
|
||||
if(curl)
|
||||
{
|
||||
data = do_grab(curl,url);
|
||||
curl_easy_cleanup(curl);
|
||||
return data;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CURL_LOAD_DATA *do_grab(CURL *curl,const char *url)
|
||||
{
|
||||
CURLcode res;
|
||||
CURL_LOAD_DATA *data = (CURL_LOAD_DATA *)malloc(sizeof(CURL_LOAD_DATA));
|
||||
data->data = NULL;
|
||||
data->nbytes = 0;
|
||||
|
||||
curl_easy_setopt(curl,CURLOPT_URL,url);
|
||||
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,response_callback);
|
||||
curl_easy_setopt(curl,CURLOPT_WRITEDATA,data);
|
||||
CURLcode res;
|
||||
CURL_LOAD_DATA *data = (CURL_LOAD_DATA *)malloc(sizeof(CURL_LOAD_DATA));
|
||||
data->data = NULL;
|
||||
data->nbytes = 0;
|
||||
|
||||
curl_easy_setopt(curl,CURLOPT_URL,url);
|
||||
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,response_callback);
|
||||
curl_easy_setopt(curl,CURLOPT_WRITEDATA,data);
|
||||
|
||||
res=curl_easy_perform(curl);
|
||||
res=curl_easy_perform(curl);
|
||||
|
||||
return data;
|
||||
return data;
|
||||
}
|
||||
|
||||
size_t response_callback(void *ptr,size_t size,size_t nmemb, void *d)
|
||||
{
|
||||
size_t rsize=size*nmemb;
|
||||
CURL_LOAD_DATA *data=(CURL_LOAD_DATA *)d;
|
||||
// fprintf(stderr,"rsize is %d\n", rsize);
|
||||
data->data=(char *)realloc(data->data,(data->nbytes+rsize)
|
||||
*sizeof(char));
|
||||
memcpy(&(data->data[data->nbytes]),ptr,rsize);
|
||||
data->nbytes += rsize;
|
||||
// fprintf(stderr,"data->nbytes is %d\n", data->nbytes);
|
||||
return rsize;
|
||||
size_t rsize=size*nmemb;
|
||||
CURL_LOAD_DATA *data=(CURL_LOAD_DATA *)d;
|
||||
// fprintf(stderr,"rsize is %d\n", rsize);
|
||||
data->data=(char *)realloc(data->data,(data->nbytes+rsize)
|
||||
*sizeof(char));
|
||||
memcpy(&(data->data[data->nbytes]),ptr,rsize);
|
||||
data->nbytes += rsize;
|
||||
// fprintf(stderr,"data->nbytes is %d\n", data->nbytes);
|
||||
return rsize;
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
char *data;
|
||||
int nbytes;
|
||||
char *data;
|
||||
int nbytes;
|
||||
} CURL_LOAD_DATA;
|
||||
|
||||
CURL_LOAD_DATA *grab_http_response(const char *url);
|
||||
|
|
|
@ -7,50 +7,50 @@ std::string dataset_deliverer::last_bbox = "";
|
|||
std::string dataset_deliverer::last_filename = "";
|
||||
|
||||
osm_dataset* dataset_deliverer::load_from_file(const string& file,
|
||||
const string& parser)
|
||||
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);
|
||||
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;
|
||||
// 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
|
||||
(const string& url,const string& bbox,const string& parser)
|
||||
(const string& url,const string& bbox,const string& parser)
|
||||
{
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
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
|
||||
cerr<<"BBOXES ARE DIFFERENT: " << last_bbox<<","<<bbox<<endl;
|
||||
cerr<<"BBOXES ARE DIFFERENT: " << last_bbox<<","<<bbox<<endl;
|
||||
#endif
|
||||
|
||||
// Reload the dataset
|
||||
dataset->clear();
|
||||
if(dataset->load_from_url(url.c_str(),bbox,parser)==false)
|
||||
return NULL;
|
||||
last_bbox = bbox;
|
||||
}
|
||||
return dataset;
|
||||
// Reload the dataset
|
||||
dataset->clear();
|
||||
if(dataset->load_from_url(url.c_str(),bbox,parser)==false)
|
||||
return NULL;
|
||||
last_bbox = bbox;
|
||||
}
|
||||
return dataset;
|
||||
}
|
||||
|
|
|
@ -10,16 +10,16 @@ using std::vector;
|
|||
|
||||
struct ScreenPos
|
||||
{
|
||||
int x,y;
|
||||
ScreenPos() { x=y=0; }
|
||||
ScreenPos(int x,int y) { this->x=x; this->y=y; }
|
||||
int x,y;
|
||||
ScreenPos() { x=y=0; }
|
||||
ScreenPos(int x,int y) { this->x=x; this->y=y; }
|
||||
};
|
||||
|
||||
struct EarthPoint
|
||||
{
|
||||
double x,y;
|
||||
EarthPoint() { x=y=0.0; }
|
||||
EarthPoint(double x,double y) { this->x=x; this->y=y; }
|
||||
double x,y;
|
||||
EarthPoint() { x=y=0.0; }
|
||||
EarthPoint(double x,double y) { this->x=x; this->y=y; }
|
||||
};
|
||||
|
||||
class GoogleProjection
|
||||
|
@ -29,69 +29,69 @@ class GoogleProjection
|
|||
vector<double> Bc,Cc,zc,Ac;
|
||||
int levels;
|
||||
|
||||
double minmax (double a,double b, double c)
|
||||
{
|
||||
a = max(a,b);
|
||||
a = min(a,c);
|
||||
return a;
|
||||
}
|
||||
double minmax (double a,double b, double c)
|
||||
{
|
||||
a = max(a,b);
|
||||
a = min(a,c);
|
||||
return a;
|
||||
}
|
||||
|
||||
public:
|
||||
GoogleProjection(int levels=18)
|
||||
{
|
||||
this->levels=levels;
|
||||
this->levels=levels;
|
||||
double c = 256;
|
||||
double e;
|
||||
double e;
|
||||
for (int d=0; d<levels; d++)
|
||||
{
|
||||
{
|
||||
e = c/2;
|
||||
Bc.push_back(c/360.0);
|
||||
Cc.push_back(c/(2 * M_PI));
|
||||
zc.push_back(e);
|
||||
Ac.push_back(c);
|
||||
c *= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ScreenPos fromLLToPixel(double lon,double lat,int zoom)
|
||||
{
|
||||
double d = zc[zoom];
|
||||
double e = round(d + lon * Bc[zoom]);
|
||||
double f = minmax(sin((M_PI/180.0) * lat),-0.9999,0.9999);
|
||||
double g = round(d + 0.5*log((1+f)/(1-f))*-Cc[zoom]);
|
||||
return ScreenPos(e,g);
|
||||
}
|
||||
ScreenPos fromLLToPixel(double lon,double lat,int zoom)
|
||||
{
|
||||
double d = zc[zoom];
|
||||
double e = round(d + lon * Bc[zoom]);
|
||||
double f = minmax(sin((M_PI/180.0) * lat),-0.9999,0.9999);
|
||||
double g = round(d + 0.5*log((1+f)/(1-f))*-Cc[zoom]);
|
||||
return ScreenPos(e,g);
|
||||
}
|
||||
|
||||
EarthPoint fromPixelToLL(int x,int y,int zoom)
|
||||
{
|
||||
double e = zc[zoom];
|
||||
double f = (x - e)/Bc[zoom];
|
||||
double g = (y - e)/-Cc[zoom];
|
||||
double h = (180.0/M_PI) * ( 2 * atan(exp(g)) - 0.5 * M_PI);
|
||||
return EarthPoint(f,h);
|
||||
}
|
||||
EarthPoint fromPixelToLL(int x,int y,int zoom)
|
||||
{
|
||||
double e = zc[zoom];
|
||||
double f = (x - e)/Bc[zoom];
|
||||
double g = (y - e)/-Cc[zoom];
|
||||
double h = (180.0/M_PI) * ( 2 * atan(exp(g)) - 0.5 * M_PI);
|
||||
return EarthPoint(f,h);
|
||||
}
|
||||
|
||||
// convert to the zoom independent Google system; TBH I don't really
|
||||
// understand what it represents....
|
||||
static EarthPoint fromLLToGoog(double lon,double lat)
|
||||
{
|
||||
double a = log(tan((90+lat)*M_PI / 360))/(M_PI / 180);
|
||||
double custLat = a * 20037508.34 / 180;
|
||||
double custLon=lon;
|
||||
custLon = custLon * 20037508.34 / 180;
|
||||
return EarthPoint(custLon,custLat);
|
||||
}
|
||||
// convert to the zoom independent Google system; TBH I don't really
|
||||
// understand what it represents....
|
||||
static EarthPoint fromLLToGoog(double lon,double lat)
|
||||
{
|
||||
double a = log(tan((90+lat)*M_PI / 360))/(M_PI / 180);
|
||||
double custLat = a * 20037508.34 / 180;
|
||||
double custLon=lon;
|
||||
custLon = custLon * 20037508.34 / 180;
|
||||
return EarthPoint(custLon,custLat);
|
||||
}
|
||||
|
||||
// other way round
|
||||
static EarthPoint fromGoogToLL(double x,double y)
|
||||
{
|
||||
double lat_deg,lon_deg;
|
||||
lat_deg = (y / 20037508.34) * 180;
|
||||
lon_deg = (x / 20037508.34) * 180;
|
||||
lat_deg = 180/M_PI *
|
||||
(2 * atan(exp(lat_deg * M_PI / 180)) - M_PI / 2);
|
||||
return EarthPoint(lon_deg,lat_deg);
|
||||
}
|
||||
// other way round
|
||||
static EarthPoint fromGoogToLL(double x,double y)
|
||||
{
|
||||
double lat_deg,lon_deg;
|
||||
lat_deg = (y / 20037508.34) * 180;
|
||||
lon_deg = (x / 20037508.34) * 180;
|
||||
lat_deg = 180/M_PI *
|
||||
(2 * atan(exp(lat_deg * M_PI / 180)) - M_PI / 2);
|
||||
return EarthPoint(lon_deg,lat_deg);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // GOOGLEPROJECTION_H
|
||||
|
|
|
@ -132,23 +132,23 @@ void MapSource::generateMaps()
|
|||
bottomRight.x /= 256;
|
||||
bottomRight.y /= 256;
|
||||
|
||||
int x_fetch_freq, y_fetch_freq, x_fetches, y_fetches;
|
||||
int x_fetch_freq, y_fetch_freq, x_fetches, y_fetches;
|
||||
|
||||
if(multirqst)
|
||||
{
|
||||
// Gives a value approx equal to 0.1 lat/lon in southern UK
|
||||
x_fetch_freq = (int)(pow(2.0,zoom_start-11));
|
||||
y_fetch_freq = (int)(pow(2.0,zoom_start-11));
|
||||
x_fetches = ((bottomRight.x-topLeft.x) / x_fetch_freq)+1,
|
||||
if(multirqst)
|
||||
{
|
||||
// Gives a value approx equal to 0.1 lat/lon in southern UK
|
||||
x_fetch_freq = (int)(pow(2.0,zoom_start-11));
|
||||
y_fetch_freq = (int)(pow(2.0,zoom_start-11));
|
||||
x_fetches = ((bottomRight.x-topLeft.x) / x_fetch_freq)+1,
|
||||
y_fetches = ((bottomRight.y-topLeft.y) / y_fetch_freq)+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
x_fetch_freq = bottomRight.x - topLeft.x;
|
||||
y_fetch_freq = bottomRight.y - topLeft.y;
|
||||
x_fetches = 1;
|
||||
y_fetches = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
x_fetch_freq = bottomRight.x - topLeft.x;
|
||||
y_fetch_freq = bottomRight.y - topLeft.y;
|
||||
x_fetches = 1;
|
||||
y_fetches = 1;
|
||||
}
|
||||
|
||||
fprintf(stderr,"topLeft: %d %d\n",topLeft.x,topLeft.y);
|
||||
fprintf(stderr,"bottomRight: %d %d\n",bottomRight.x,bottomRight.y);
|
||||
|
@ -170,7 +170,7 @@ void MapSource::generateMaps()
|
|||
*256, zoom_start),
|
||||
bottomR_LL =
|
||||
proj.fromPixelToLL( ((topLeft.x+xfetch*x_fetch_freq)+
|
||||
x_fetch_freq)*256,
|
||||
x_fetch_freq)*256,
|
||||
((topLeft.y+yfetch*y_fetch_freq)
|
||||
+y_fetch_freq)*256, zoom_start),
|
||||
topL_LL =
|
||||
|
@ -179,10 +179,10 @@ void MapSource::generateMaps()
|
|||
(topLeft.y+yfetch*y_fetch_freq)
|
||||
*256, zoom_start);
|
||||
|
||||
double w1 = min(bottomL_LL.x-0.01,topL_LL.x-0.01),
|
||||
s1 = min(bottomL_LL.y-0.01,bottomR_LL.y-0.01),
|
||||
e1 = max(bottomR_LL.x+0.01,topR_LL.x+0.01),
|
||||
n1 = max(topL_LL.y+0.01,topR_LL.y+0.01);
|
||||
double w1 = min(bottomL_LL.x-0.01,topL_LL.x-0.01),
|
||||
s1 = min(bottomL_LL.y-0.01,bottomR_LL.y-0.01),
|
||||
e1 = max(bottomR_LL.x+0.01,topR_LL.x+0.01),
|
||||
n1 = max(topL_LL.y+0.01,topR_LL.y+0.01);
|
||||
|
||||
parameters p;
|
||||
if(getSource()=="api")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CXXFLAGS = `xml2-config --cflags` -I/usr/local/include/mapnik -I/usr/include/boost -I/usr/include/freetype2 -I/home/nick/mapnik-osm/agg/include -fPIC -g
|
||||
MAPNIK_OSM_OBJ = osmparser.o osm.o osm_datasource.o osm_featureset.o
|
||||
osm.input: $(MAPNIK_OSM_OBJ)
|
||||
g++ -shared -o osm.input $(MAPNIK_OSM_OBJ)
|
||||
g++ -shared -o osm.input $(MAPNIK_OSM_OBJ)
|
||||
|
|
|
@ -15,86 +15,86 @@ polygon_types osm_way::ptypes;
|
|||
|
||||
bool osm_dataset::load(const char* filename,const std::string& parser)
|
||||
{
|
||||
if (parser=="libxml2")
|
||||
{
|
||||
return osmparser::parse(this,filename);
|
||||
}
|
||||
return false;
|
||||
if (parser=="libxml2")
|
||||
{
|
||||
return osmparser::parse(this,filename);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool osm_dataset::load_from_url(const std::string& url,
|
||||
const std::string& bbox,
|
||||
const std::string& parser)
|
||||
const std::string& bbox,
|
||||
const std::string& parser)
|
||||
{
|
||||
if(parser=="libxml2")
|
||||
{
|
||||
if(parser=="libxml2")
|
||||
{
|
||||
#ifdef MAPNIK_DEBUG
|
||||
cerr<<"osm_dataset::load_from_url: url=" << url <<
|
||||
" bbox="<<bbox<<endl;
|
||||
cerr<<"osm_dataset::load_from_url: url=" << url <<
|
||||
" bbox="<<bbox<<endl;
|
||||
#endif
|
||||
std::ostringstream str;
|
||||
// use curl to grab the data
|
||||
// fetch all the data we want - probably from osmxpai
|
||||
std::ostringstream str;
|
||||
// use curl to grab the data
|
||||
// fetch all the data we want - probably from osmxpai
|
||||
|
||||
str << url << "?bbox=" << bbox;
|
||||
|
||||
#ifdef MAPNIK_DEBUG
|
||||
cerr << "FULL URL : " << str.str() << endl;
|
||||
cerr << "FULL URL : " << str.str() << endl;
|
||||
#endif
|
||||
|
||||
CURL_LOAD_DATA *resp = grab_http_response(str.str().c_str());
|
||||
if(resp!=NULL)
|
||||
{
|
||||
char *blx = new char[resp->nbytes+1];
|
||||
memcpy(blx,resp->data,resp->nbytes);
|
||||
blx[resp->nbytes] = '\0';
|
||||
if(resp!=NULL)
|
||||
{
|
||||
char *blx = new char[resp->nbytes+1];
|
||||
memcpy(blx,resp->data,resp->nbytes);
|
||||
blx[resp->nbytes] = '\0';
|
||||
|
||||
#ifdef MAPNIK_DEBUG
|
||||
cerr<< " CURL RESPONSE: " << blx << endl;
|
||||
cerr<< " CURL RESPONSE: " << blx << endl;
|
||||
#endif
|
||||
|
||||
delete[] blx;
|
||||
bool success= osmparser::parse(this,resp->data,resp->nbytes);
|
||||
return success;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
delete[] blx;
|
||||
bool success= osmparser::parse(this,resp->data,resp->nbytes);
|
||||
return success;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
osm_dataset::~osm_dataset()
|
||||
{
|
||||
clear();
|
||||
clear();
|
||||
}
|
||||
|
||||
void osm_dataset::clear()
|
||||
{
|
||||
#ifdef MAPNIK_DEBUG
|
||||
cerr<<"osm_dataset::clear()"<<endl;
|
||||
cerr<<"deleting ways"<<endl;
|
||||
cerr<<"osm_dataset::clear()"<<endl;
|
||||
cerr<<"deleting ways"<<endl;
|
||||
#endif
|
||||
|
||||
for(unsigned int count=0; count<ways.size(); count++)
|
||||
{
|
||||
delete ways[count];
|
||||
ways[count]=NULL;
|
||||
}
|
||||
for(unsigned int count=0; count<ways.size(); count++)
|
||||
{
|
||||
delete ways[count];
|
||||
ways[count]=NULL;
|
||||
}
|
||||
|
||||
#ifdef MAPNIK_DEBUG
|
||||
cerr<<"deleting nodes"<<endl;
|
||||
cerr<<"deleting nodes"<<endl;
|
||||
#endif
|
||||
|
||||
for(unsigned int count=0; count<nodes.size(); count++)
|
||||
{
|
||||
delete nodes[count];
|
||||
nodes[count]=NULL;
|
||||
}
|
||||
for(unsigned int count=0; count<nodes.size(); count++)
|
||||
{
|
||||
delete nodes[count];
|
||||
nodes[count]=NULL;
|
||||
}
|
||||
|
||||
#ifdef MAPNIK_DEBUG
|
||||
cerr<<"Clearing ways/nodes"<<endl;
|
||||
cerr<<"Clearing ways/nodes"<<endl;
|
||||
#endif
|
||||
|
||||
ways.clear();
|
||||
nodes.clear();
|
||||
ways.clear();
|
||||
nodes.clear();
|
||||
|
||||
#ifdef MAPNIK_DEBUG
|
||||
cerr<<"Done"<<endl;
|
||||
|
@ -103,161 +103,161 @@ void osm_dataset::clear()
|
|||
|
||||
std::string osm_dataset::to_string()
|
||||
{
|
||||
std::string result;
|
||||
std::string result;
|
||||
|
||||
for(unsigned int count=0; count<nodes.size(); count++)
|
||||
{
|
||||
result += nodes[count]->to_string();
|
||||
}
|
||||
for(unsigned int count=0; count<ways.size(); count++)
|
||||
{
|
||||
result += ways[count]->to_string();
|
||||
}
|
||||
return result;
|
||||
for(unsigned int count=0; count<nodes.size(); count++)
|
||||
{
|
||||
result += nodes[count]->to_string();
|
||||
}
|
||||
for(unsigned int count=0; count<ways.size(); count++)
|
||||
{
|
||||
result += ways[count]->to_string();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bounds osm_dataset::get_bounds()
|
||||
{
|
||||
bounds b (-180,-90,180,90);
|
||||
for(unsigned int count=0; count<nodes.size();count++)
|
||||
{
|
||||
if(nodes[count]->lon > b.w)
|
||||
b.w=nodes[count]->lon;
|
||||
if(nodes[count]->lon < b.e)
|
||||
b.e=nodes[count]->lon;
|
||||
if(nodes[count]->lat > b.s)
|
||||
b.s=nodes[count]->lat;
|
||||
if(nodes[count]->lat < b.n)
|
||||
b.n=nodes[count]->lat;
|
||||
}
|
||||
return b;
|
||||
bounds b (-180,-90,180,90);
|
||||
for(unsigned int count=0; count<nodes.size();count++)
|
||||
{
|
||||
if(nodes[count]->lon > b.w)
|
||||
b.w=nodes[count]->lon;
|
||||
if(nodes[count]->lon < b.e)
|
||||
b.e=nodes[count]->lon;
|
||||
if(nodes[count]->lat > b.s)
|
||||
b.s=nodes[count]->lat;
|
||||
if(nodes[count]->lat < b.n)
|
||||
b.n=nodes[count]->lat;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
osm_node *osm_dataset::next_node()
|
||||
{
|
||||
if(node_i!=nodes.end())
|
||||
{
|
||||
return *(node_i++);
|
||||
}
|
||||
return NULL;
|
||||
|
||||
if(node_i!=nodes.end())
|
||||
{
|
||||
return *(node_i++);
|
||||
}
|
||||
return NULL;
|
||||
|
||||
}
|
||||
osm_way *osm_dataset::next_way()
|
||||
{
|
||||
if(way_i!=ways.end())
|
||||
{
|
||||
return *(way_i++);
|
||||
}
|
||||
return NULL;
|
||||
if(way_i!=ways.end())
|
||||
{
|
||||
return *(way_i++);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
osm_item *osm_dataset::next_item()
|
||||
{
|
||||
osm_item *item=NULL;
|
||||
if(next_item_mode==Node)
|
||||
{
|
||||
item = next_node();
|
||||
if(item==NULL)
|
||||
{
|
||||
next_item_mode=Way;
|
||||
rewind_ways();
|
||||
item = next_way();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
item = next_way();
|
||||
}
|
||||
return item;
|
||||
osm_item *item=NULL;
|
||||
if(next_item_mode==Node)
|
||||
{
|
||||
item = next_node();
|
||||
if(item==NULL)
|
||||
{
|
||||
next_item_mode=Way;
|
||||
rewind_ways();
|
||||
item = next_way();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
item = next_way();
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
std::set<std::string> osm_dataset::get_keys()
|
||||
{
|
||||
std::set<std::string> keys;
|
||||
for(unsigned int count=0; count<nodes.size(); count++)
|
||||
{
|
||||
for(std::map<std::string,std::string>::iterator i=
|
||||
nodes[count]->keyvals.begin(); i!=nodes[count]->keyvals.end(); i++)
|
||||
{
|
||||
keys.insert(i->first);
|
||||
}
|
||||
}
|
||||
for(unsigned int count=0; count<ways.size(); count++)
|
||||
{
|
||||
for(std::map<std::string,std::string>::iterator i=
|
||||
ways[count]->keyvals.begin(); i!=ways[count]->keyvals.end(); i++)
|
||||
{
|
||||
keys.insert(i->first);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
std::set<std::string> keys;
|
||||
for(unsigned int count=0; count<nodes.size(); count++)
|
||||
{
|
||||
for(std::map<std::string,std::string>::iterator i=
|
||||
nodes[count]->keyvals.begin(); i!=nodes[count]->keyvals.end(); i++)
|
||||
{
|
||||
keys.insert(i->first);
|
||||
}
|
||||
}
|
||||
for(unsigned int count=0; count<ways.size(); count++)
|
||||
{
|
||||
for(std::map<std::string,std::string>::iterator i=
|
||||
ways[count]->keyvals.begin(); i!=ways[count]->keyvals.end(); i++)
|
||||
{
|
||||
keys.insert(i->first);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
std::string osm_item::to_string()
|
||||
{
|
||||
std::ostringstream strm;
|
||||
strm << "id=" << id << std::endl << "Keyvals: " << std::endl;
|
||||
for(std::map<std::string,std::string>::iterator i=keyvals.begin();
|
||||
i!=keyvals.end(); i++)
|
||||
{
|
||||
strm << "Key " << i->first << " Value " << i->second << std::endl;
|
||||
}
|
||||
return strm.str();
|
||||
std::ostringstream strm;
|
||||
strm << "id=" << id << std::endl << "Keyvals: " << std::endl;
|
||||
for(std::map<std::string,std::string>::iterator i=keyvals.begin();
|
||||
i!=keyvals.end(); i++)
|
||||
{
|
||||
strm << "Key " << i->first << " Value " << i->second << std::endl;
|
||||
}
|
||||
return strm.str();
|
||||
}
|
||||
|
||||
std::string osm_node::to_string()
|
||||
{
|
||||
std::ostringstream strm;
|
||||
strm << "Node: "<< osm_item::to_string() <<
|
||||
" Lat=" << lat <<" lon=" <<lon << std::endl;
|
||||
return strm.str();
|
||||
std::ostringstream strm;
|
||||
strm << "Node: "<< osm_item::to_string() <<
|
||||
" Lat=" << lat <<" lon=" <<lon << std::endl;
|
||||
return strm.str();
|
||||
}
|
||||
|
||||
std::string osm_way::to_string()
|
||||
{
|
||||
std::ostringstream strm;
|
||||
strm << "Way: " << osm_item::to_string() << "Nodes in way:";
|
||||
std::ostringstream strm;
|
||||
strm << "Way: " << osm_item::to_string() << "Nodes in way:";
|
||||
|
||||
for(unsigned int count=0; count<nodes.size(); count++)
|
||||
{
|
||||
if(nodes[count]!=NULL)
|
||||
{
|
||||
strm << nodes[count]->id << " ";
|
||||
}
|
||||
}
|
||||
strm << std::endl;
|
||||
return strm.str();
|
||||
for(unsigned int count=0; count<nodes.size(); count++)
|
||||
{
|
||||
if(nodes[count]!=NULL)
|
||||
{
|
||||
strm << nodes[count]->id << " ";
|
||||
}
|
||||
}
|
||||
strm << std::endl;
|
||||
return strm.str();
|
||||
}
|
||||
|
||||
bounds osm_way::get_bounds()
|
||||
{
|
||||
bounds b (-180,-90,180,90);
|
||||
for(unsigned int count=0; count<nodes.size();count++)
|
||||
{
|
||||
if(nodes[count]->lon > b.w)
|
||||
b.w=nodes[count]->lon;
|
||||
if(nodes[count]->lon < b.e)
|
||||
b.e=nodes[count]->lon;
|
||||
if(nodes[count]->lat > b.s)
|
||||
b.s=nodes[count]->lat;
|
||||
if(nodes[count]->lat < b.n)
|
||||
b.n=nodes[count]->lat;
|
||||
}
|
||||
return b;
|
||||
bounds b (-180,-90,180,90);
|
||||
for(unsigned int count=0; count<nodes.size();count++)
|
||||
{
|
||||
if(nodes[count]->lon > b.w)
|
||||
b.w=nodes[count]->lon;
|
||||
if(nodes[count]->lon < b.e)
|
||||
b.e=nodes[count]->lon;
|
||||
if(nodes[count]->lat > b.s)
|
||||
b.s=nodes[count]->lat;
|
||||
if(nodes[count]->lat < b.n)
|
||||
b.n=nodes[count]->lat;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
bool osm_way::is_polygon()
|
||||
{
|
||||
for(unsigned int count=0; count<ptypes.ptypes.size(); count++)
|
||||
{
|
||||
if(keyvals.find(ptypes.ptypes[count].first) != keyvals.end() &&
|
||||
keyvals[ptypes.ptypes[count].first] == ptypes.ptypes[count].second)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
for(unsigned int count=0; count<ptypes.ptypes.size(); count++)
|
||||
{
|
||||
if(keyvals.find(ptypes.ptypes[count].first) != keyvals.end() &&
|
||||
keyvals[ptypes.ptypes[count].first] == ptypes.ptypes[count].second)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
ptypes.push_back(std::pair<std::string,std::string>("natural","heath"));
|
||||
ptypes.push_back(std::pair<std::string,std::string>("natural","marsh"));
|
||||
ptypes.push_back(std::pair<std::string,std::string>("military",
|
||||
"danger_area"));
|
||||
"danger_area"));
|
||||
ptypes.push_back(std::pair<std::string,std::string>
|
||||
("landuse","forest"));
|
||||
ptypes.push_back(std::pair<std::string,std::string>
|
||||
|
|
|
@ -71,7 +71,7 @@ void osm_datasource::bind() const
|
|||
{
|
||||
// otherwise if we supplied a url and a bounding box, load from the url
|
||||
#ifdef MAPNIK_DEBUG
|
||||
cerr<<"loading_from_url: url="<<url << " bbox="<<bbox<<endl;
|
||||
cerr<<"loading_from_url: url="<<url << " bbox="<<bbox<<endl;
|
||||
#endif
|
||||
if((osm_data_=dataset_deliverer::load_from_url
|
||||
(url,bbox,parser))==NULL)
|
||||
|
|
|
@ -45,22 +45,22 @@ class osm_datasource : public datasource
|
|||
osm_datasource(const parameters ¶ms, bool bind=true);
|
||||
virtual ~osm_datasource();
|
||||
|
||||
// these must be overridden
|
||||
// these must be overridden
|
||||
int type() const;
|
||||
featureset_ptr features(const query& q) const;
|
||||
featureset_ptr features_at_point(coord2d const& pt) const;
|
||||
box2d<double> envelope() const;
|
||||
layer_descriptor get_descriptor() const;
|
||||
static std::string name();
|
||||
void bind() const;
|
||||
static std::string name();
|
||||
void bind() const;
|
||||
private:
|
||||
osm_datasource(const osm_datasource&);
|
||||
osm_datasource& operator=(const osm_datasource&);
|
||||
private:
|
||||
mutable box2d<double> extent_;
|
||||
mutable osm_dataset * osm_data_;
|
||||
int type_;
|
||||
mutable layer_descriptor desc_;
|
||||
int type_;
|
||||
mutable layer_descriptor desc_;
|
||||
};
|
||||
|
||||
#endif //OSM_DATASOURCE_HPP
|
||||
|
|
|
@ -47,8 +47,8 @@ class osm_featureset : public Featureset
|
|||
mutable box2d<double> feature_ext_;
|
||||
mutable int total_geom_size;
|
||||
mutable int count_;
|
||||
osm_dataset *dataset_;
|
||||
std::set<std::string> attribute_names_;
|
||||
osm_dataset *dataset_;
|
||||
std::set<std::string> attribute_names_;
|
||||
|
||||
public:
|
||||
osm_featureset(const filterT& filter,
|
||||
|
|
|
@ -18,140 +18,140 @@ using std::endl;
|
|||
|
||||
void osmparser::processNode(xmlTextReaderPtr reader)
|
||||
{
|
||||
xmlChar *name = xmlTextReaderName(reader);
|
||||
if(name==NULL)
|
||||
name=xmlStrdup(BAD_CAST "--");
|
||||
xmlChar *name = xmlTextReaderName(reader);
|
||||
if(name==NULL)
|
||||
name=xmlStrdup(BAD_CAST "--");
|
||||
|
||||
switch(xmlTextReaderNodeType(reader))
|
||||
{
|
||||
case XML_READER_TYPE_ELEMENT:
|
||||
startElement(reader,name);
|
||||
break;
|
||||
switch(xmlTextReaderNodeType(reader))
|
||||
{
|
||||
case XML_READER_TYPE_ELEMENT:
|
||||
startElement(reader,name);
|
||||
break;
|
||||
|
||||
case XML_READER_TYPE_END_ELEMENT:
|
||||
endElement(name);
|
||||
}
|
||||
xmlFree(name);
|
||||
case XML_READER_TYPE_END_ELEMENT:
|
||||
endElement(name);
|
||||
}
|
||||
xmlFree(name);
|
||||
}
|
||||
|
||||
void osmparser::startElement(xmlTextReaderPtr reader, const xmlChar *name)
|
||||
{
|
||||
std::string tags;
|
||||
xmlChar *xid, *xlat, *xlon, *xk, *xv;
|
||||
std::string tags;
|
||||
xmlChar *xid, *xlat, *xlon, *xk, *xv;
|
||||
|
||||
if(xmlStrEqual(name,BAD_CAST "node"))
|
||||
{
|
||||
curID = 0;
|
||||
in_node = true;
|
||||
osm_node *node=new osm_node;
|
||||
xlat=xmlTextReaderGetAttribute(reader,BAD_CAST "lat");
|
||||
xlon=xmlTextReaderGetAttribute(reader,BAD_CAST "lon");
|
||||
xid=xmlTextReaderGetAttribute(reader,BAD_CAST "id");
|
||||
assert(xlat);
|
||||
assert(xlon);
|
||||
assert(xid);
|
||||
node->lat=atof((char*)xlat);
|
||||
node->lon=atof((char*)xlon);
|
||||
node->id = atol((char*)xid);
|
||||
cur_item = node;
|
||||
tmp_node_store[node->id] = node;
|
||||
xmlFree(xid);
|
||||
xmlFree(xlon);
|
||||
xmlFree(xlat);
|
||||
}
|
||||
else if (xmlStrEqual(name,BAD_CAST "way"))
|
||||
{
|
||||
curID=0;
|
||||
in_way = true;
|
||||
osm_way *way=new osm_way;
|
||||
xid=xmlTextReaderGetAttribute(reader,BAD_CAST "id");
|
||||
assert(xid);
|
||||
way->id = atol((char*)xid);
|
||||
cur_item = way;
|
||||
// Prevent ways with no name being assigned a name of "0"
|
||||
cur_item->keyvals["name"] = "";
|
||||
if(xmlStrEqual(name,BAD_CAST "node"))
|
||||
{
|
||||
curID = 0;
|
||||
in_node = true;
|
||||
osm_node *node=new osm_node;
|
||||
xlat=xmlTextReaderGetAttribute(reader,BAD_CAST "lat");
|
||||
xlon=xmlTextReaderGetAttribute(reader,BAD_CAST "lon");
|
||||
xid=xmlTextReaderGetAttribute(reader,BAD_CAST "id");
|
||||
assert(xlat);
|
||||
assert(xlon);
|
||||
assert(xid);
|
||||
node->lat=atof((char*)xlat);
|
||||
node->lon=atof((char*)xlon);
|
||||
node->id = atol((char*)xid);
|
||||
cur_item = node;
|
||||
tmp_node_store[node->id] = node;
|
||||
xmlFree(xid);
|
||||
xmlFree(xlon);
|
||||
xmlFree(xlat);
|
||||
}
|
||||
else if (xmlStrEqual(name,BAD_CAST "way"))
|
||||
{
|
||||
curID=0;
|
||||
in_way = true;
|
||||
osm_way *way=new osm_way;
|
||||
xid=xmlTextReaderGetAttribute(reader,BAD_CAST "id");
|
||||
assert(xid);
|
||||
way->id = atol((char*)xid);
|
||||
cur_item = way;
|
||||
// Prevent ways with no name being assigned a name of "0"
|
||||
cur_item->keyvals["name"] = "";
|
||||
|
||||
// HACK: allows comparison with "" in the XML file. Otherwise it
|
||||
// doesn't work. Only do for the most crucial tags for Freemap's
|
||||
// purposes. TODO investigate why this is
|
||||
cur_item->keyvals["width"] = "";
|
||||
cur_item->keyvals["horse"] = "";
|
||||
cur_item->keyvals["foot"] = "";
|
||||
cur_item->keyvals["bicycle"] = "";
|
||||
xmlFree(xid);
|
||||
}
|
||||
else if (xmlStrEqual(name,BAD_CAST "nd"))
|
||||
{
|
||||
xid=xmlTextReaderGetAttribute(reader,BAD_CAST "ref");
|
||||
assert(xid);
|
||||
long ndid = atol((char*)xid);
|
||||
if(tmp_node_store.find(ndid)!=tmp_node_store.end())
|
||||
{
|
||||
(static_cast<osm_way*>(cur_item))->nodes.push_back
|
||||
(tmp_node_store[ndid]);
|
||||
}
|
||||
xmlFree(xid);
|
||||
}
|
||||
else if (xmlStrEqual(name,BAD_CAST "tag"))
|
||||
{
|
||||
std::string key="", value="";
|
||||
xk = xmlTextReaderGetAttribute(reader,BAD_CAST "k");
|
||||
xv = xmlTextReaderGetAttribute(reader,BAD_CAST "v");
|
||||
assert(xk);
|
||||
assert(xv);
|
||||
cur_item->keyvals[(char*)xk] = (char*)xv;
|
||||
xmlFree(xk);
|
||||
xmlFree(xv);
|
||||
}
|
||||
// HACK: allows comparison with "" in the XML file. Otherwise it
|
||||
// doesn't work. Only do for the most crucial tags for Freemap's
|
||||
// purposes. TODO investigate why this is
|
||||
cur_item->keyvals["width"] = "";
|
||||
cur_item->keyvals["horse"] = "";
|
||||
cur_item->keyvals["foot"] = "";
|
||||
cur_item->keyvals["bicycle"] = "";
|
||||
xmlFree(xid);
|
||||
}
|
||||
else if (xmlStrEqual(name,BAD_CAST "nd"))
|
||||
{
|
||||
xid=xmlTextReaderGetAttribute(reader,BAD_CAST "ref");
|
||||
assert(xid);
|
||||
long ndid = atol((char*)xid);
|
||||
if(tmp_node_store.find(ndid)!=tmp_node_store.end())
|
||||
{
|
||||
(static_cast<osm_way*>(cur_item))->nodes.push_back
|
||||
(tmp_node_store[ndid]);
|
||||
}
|
||||
xmlFree(xid);
|
||||
}
|
||||
else if (xmlStrEqual(name,BAD_CAST "tag"))
|
||||
{
|
||||
std::string key="", value="";
|
||||
xk = xmlTextReaderGetAttribute(reader,BAD_CAST "k");
|
||||
xv = xmlTextReaderGetAttribute(reader,BAD_CAST "v");
|
||||
assert(xk);
|
||||
assert(xv);
|
||||
cur_item->keyvals[(char*)xk] = (char*)xv;
|
||||
xmlFree(xk);
|
||||
xmlFree(xv);
|
||||
}
|
||||
}
|
||||
|
||||
void osmparser::endElement(const xmlChar* name)
|
||||
{
|
||||
if(xmlStrEqual(name,BAD_CAST "node"))
|
||||
{
|
||||
in_node = false;
|
||||
components->add_node(static_cast<osm_node*>(cur_item));
|
||||
}
|
||||
else if(xmlStrEqual(name,BAD_CAST "way"))
|
||||
{
|
||||
in_way = false;
|
||||
components->add_way(static_cast<osm_way*>(cur_item));
|
||||
}
|
||||
if(xmlStrEqual(name,BAD_CAST "node"))
|
||||
{
|
||||
in_node = false;
|
||||
components->add_node(static_cast<osm_node*>(cur_item));
|
||||
}
|
||||
else if(xmlStrEqual(name,BAD_CAST "way"))
|
||||
{
|
||||
in_way = false;
|
||||
components->add_way(static_cast<osm_way*>(cur_item));
|
||||
}
|
||||
}
|
||||
|
||||
bool osmparser::parse(osm_dataset *ds, const char* filename)
|
||||
{
|
||||
components=ds;
|
||||
xmlTextReaderPtr reader = xmlNewTextReaderFilename(filename);
|
||||
int ret=do_parse(reader);
|
||||
xmlFreeTextReader(reader);
|
||||
return (ret==0) ? true:false;
|
||||
components=ds;
|
||||
xmlTextReaderPtr reader = xmlNewTextReaderFilename(filename);
|
||||
int ret=do_parse(reader);
|
||||
xmlFreeTextReader(reader);
|
||||
return (ret==0) ? true:false;
|
||||
}
|
||||
|
||||
bool osmparser::parse(osm_dataset *ds,char* data, int nbytes)
|
||||
{
|
||||
// from cocoasamurai.blogspot.com/2008/10/getting-some-xml-love-with-
|
||||
// libxml2.html, converted from Objective-C to straight C
|
||||
// from cocoasamurai.blogspot.com/2008/10/getting-some-xml-love-with-
|
||||
// libxml2.html, converted from Objective-C to straight C
|
||||
|
||||
components=ds;
|
||||
xmlTextReaderPtr reader = xmlReaderForMemory(data,nbytes,NULL,NULL,0);
|
||||
int ret=do_parse(reader);
|
||||
xmlFreeTextReader(reader);
|
||||
return (ret==0) ? true:false;
|
||||
components=ds;
|
||||
xmlTextReaderPtr reader = xmlReaderForMemory(data,nbytes,NULL,NULL,0);
|
||||
int ret=do_parse(reader);
|
||||
xmlFreeTextReader(reader);
|
||||
return (ret==0) ? true:false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int osmparser::do_parse(xmlTextReaderPtr reader)
|
||||
{
|
||||
int ret=-1;
|
||||
if(reader!=NULL)
|
||||
{
|
||||
ret = xmlTextReaderRead(reader);
|
||||
while(ret==1)
|
||||
{
|
||||
processNode(reader);
|
||||
ret=xmlTextReaderRead(reader);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
int ret=-1;
|
||||
if(reader!=NULL)
|
||||
{
|
||||
ret = xmlTextReaderRead(reader);
|
||||
while(ret==1)
|
||||
{
|
||||
processNode(reader);
|
||||
ret=xmlTextReaderRead(reader);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ private:
|
|||
static std::string error;
|
||||
static std::map<long,osm_node*> tmp_node_store;
|
||||
|
||||
static int do_parse(xmlTextReaderPtr);
|
||||
static int do_parse(xmlTextReaderPtr);
|
||||
|
||||
public:
|
||||
static void processNode(xmlTextReaderPtr reader);
|
||||
|
|
|
@ -9,20 +9,20 @@
|
|||
class osm_tag_types
|
||||
{
|
||||
private:
|
||||
std::map<std::string,mapnik::eAttributeType> types;
|
||||
std::map<std::string,mapnik::eAttributeType> types;
|
||||
|
||||
public:
|
||||
void add_type(std::string tag, mapnik::eAttributeType type)
|
||||
{
|
||||
types[tag]=type;
|
||||
}
|
||||
void add_type(std::string tag, mapnik::eAttributeType type)
|
||||
{
|
||||
types[tag]=type;
|
||||
}
|
||||
|
||||
mapnik::eAttributeType get_type(std::string tag)
|
||||
{
|
||||
std::map<std::string,mapnik::eAttributeType>::iterator i =
|
||||
types.find(tag);
|
||||
return (i==types.end()) ? mapnik::String: i->second;
|
||||
}
|
||||
mapnik::eAttributeType get_type(std::string tag)
|
||||
{
|
||||
std::map<std::string,mapnik::eAttributeType>::iterator i =
|
||||
types.find(tag);
|
||||
return (i==types.end()) ? mapnik::String: i->second;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // OSMTAGTYPES_H
|
||||
|
|
|
@ -17,43 +17,43 @@ using namespace std;
|
|||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
if(argc < 6)
|
||||
{
|
||||
std::cerr<<"Usage: render XMLfile w s e n [OSMfile]" << std::endl;
|
||||
exit(0);
|
||||
}
|
||||
if(argc < 6)
|
||||
{
|
||||
std::cerr<<"Usage: render XMLfile w s e n [OSMfile]" << std::endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
datasource_cache::instance()->register_datasources
|
||||
("/usr/local/lib/mapnik/input");
|
||||
freetype_engine::register_font
|
||||
("/usr/local/lib/mapnik/fonts/DejaVuSans.ttf");
|
||||
datasource_cache::instance()->register_datasources
|
||||
("/usr/local/lib/mapnik/input");
|
||||
freetype_engine::register_font
|
||||
("/usr/local/lib/mapnik/fonts/DejaVuSans.ttf");
|
||||
|
||||
Map m (800,800);
|
||||
load_map(m,argv[1]);
|
||||
|
||||
if(argc>6)
|
||||
{
|
||||
parameters p;
|
||||
p["type"] = "osm";
|
||||
p["file"] = argv[6];
|
||||
for(int count=0; count<m.layer_count(); count++)
|
||||
{
|
||||
parameters q = m.getLayer(count).datasource()->params();
|
||||
m.getLayer(count).set_datasource(datasource_cache::instance()->
|
||||
create(p));
|
||||
}
|
||||
}
|
||||
Map m (800,800);
|
||||
load_map(m,argv[1]);
|
||||
|
||||
if(argc>6)
|
||||
{
|
||||
parameters p;
|
||||
p["type"] = "osm";
|
||||
p["file"] = argv[6];
|
||||
for(int count=0; count<m.layer_count(); count++)
|
||||
{
|
||||
parameters q = m.getLayer(count).datasource()->params();
|
||||
m.getLayer(count).set_datasource(datasource_cache::instance()->
|
||||
create(p));
|
||||
}
|
||||
}
|
||||
|
||||
box2d<double> bbox (atof(argv[2]),atof(argv[3]),
|
||||
atof(argv[4]),atof(argv[5]));
|
||||
|
||||
m.zoom_to_box(bbox);
|
||||
box2d<double> bbox (atof(argv[2]),atof(argv[3]),
|
||||
atof(argv[4]),atof(argv[5]));
|
||||
|
||||
m.zoom_to_box(bbox);
|
||||
|
||||
image_32 buf (m.width(), m.height());
|
||||
agg_renderer<image_32> r(m,buf);
|
||||
r.apply();
|
||||
image_32 buf (m.width(), m.height());
|
||||
agg_renderer<image_32> r(m,buf);
|
||||
r.apply();
|
||||
|
||||
save_to_file<image_data_32>(buf.data(),"blah.png","png");
|
||||
save_to_file<image_data_32>(buf.data(),"blah.png","png");
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -5,21 +5,21 @@ using std::endl;
|
|||
|
||||
int main(int argc,char* argv[])
|
||||
{
|
||||
if(argc>=2)
|
||||
{
|
||||
osm_dataset dataset(argv[1]);
|
||||
bounds b = dataset.get_bounds();
|
||||
osm_item *item;
|
||||
dataset.rewind();
|
||||
while((item=dataset.next_item())!=NULL)
|
||||
{
|
||||
std::cerr << item->to_string() << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr<<"Usage: test OSMfile"<<std::endl;
|
||||
exit(1);
|
||||
}
|
||||
return 0;
|
||||
if(argc>=2)
|
||||
{
|
||||
osm_dataset dataset(argv[1]);
|
||||
bounds b = dataset.get_bounds();
|
||||
osm_item *item;
|
||||
dataset.rewind();
|
||||
while((item=dataset.next_item())!=NULL)
|
||||
{
|
||||
std::cerr << item->to_string() << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr<<"Usage: test OSMfile"<<std::endl;
|
||||
exit(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -4,18 +4,18 @@
|
|||
|
||||
<Style name="coast-poly">
|
||||
<Rule>
|
||||
<PolygonSymbolizer>
|
||||
<CssParameter name="fill">#f2efe9</CssParameter>
|
||||
</PolygonSymbolizer>
|
||||
</Rule>
|
||||
<PolygonSymbolizer>
|
||||
<CssParameter name="fill">#f2efe9</CssParameter>
|
||||
</PolygonSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
|
||||
<Style name="coast-line">
|
||||
<Rule>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">skyblue</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">skyblue</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
|
||||
<Style name="leisure">
|
||||
|
@ -39,7 +39,7 @@
|
|||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[leisure] = 'park' or [leisure] = 'common' or
|
||||
[leisure] = 'golf_course'</Filter>
|
||||
[leisure] = 'golf_course'</Filter>
|
||||
<PolygonSymbolizer>
|
||||
<CssParameter name="fill">#d8e8d0</CssParameter>
|
||||
</PolygonSymbolizer>
|
||||
|
@ -91,12 +91,12 @@
|
|||
<Filter>[natural] = 'peak'</Filter>
|
||||
<TextSymbolizer name="name" face_name="Bitstream Vera Sans Roman" size="11" fill="#000" halo_radius="1" wrap_width="0"/>
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[natural] = 'wood' or [natural] = 'water' or [natural] = 'heath'
|
||||
or [leisure] = 'golf_course' </Filter>
|
||||
<TextSymbolizer name="name" face_name="Bitstream Vera Sans Roman"
|
||||
size="10" fill="#000" halo_radius="2" wrap_width="0" />
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[natural] = 'wood' or [natural] = 'water' or [natural] = 'heath'
|
||||
or [leisure] = 'golf_course' </Filter>
|
||||
<TextSymbolizer name="name" face_name="Bitstream Vera Sans Roman"
|
||||
size="10" fill="#000" halo_radius="2" wrap_width="0" />
|
||||
</Rule>
|
||||
</Style>
|
||||
|
||||
<Style name="river">
|
||||
|
@ -193,7 +193,7 @@
|
|||
<Filter>[highway] = 'unsurfaced' or [highway] = 'track'</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#999</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">6,4</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">6,4</CssParameter>
|
||||
<CssParameter name="stroke-width">4</CssParameter>
|
||||
<CssParameter name="stroke-linejoin">round</CssParameter>
|
||||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
|
@ -211,7 +211,7 @@
|
|||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
</Style>
|
||||
<Style name="trunk">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'trunk' or [highway] = 'trunk_link'</Filter>
|
||||
|
@ -275,7 +275,7 @@
|
|||
<Style name="residential">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'residential' or [highway] = 'service' or
|
||||
[highway] = 'unsurfaced' or [highway] = 'track'</Filter>
|
||||
[highway] = 'unsurfaced' or [highway] = 'track'</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#fff</CssParameter>
|
||||
<CssParameter name="stroke-width">2</CssParameter>
|
||||
|
@ -283,9 +283,9 @@
|
|||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style name="bridleway">
|
||||
<Style name="bridleway">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'bridleway' and [newforest_pathtype] = ''</Filter>
|
||||
<LineSymbolizer>
|
||||
|
@ -305,7 +305,7 @@
|
|||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[highway] = 'bridleway' and [foot] = 'yes' and [horse] = 'yes'
|
||||
and [bicycle] = 'yes'</Filter>
|
||||
and [bicycle] = 'yes'</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#fff</CssParameter>
|
||||
<CssParameter name="stroke-width">6</CssParameter>
|
||||
|
@ -323,7 +323,7 @@
|
|||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[highway] = 'bridleway' and [newforest_pathtype] = 'narrow'
|
||||
</Filter>
|
||||
</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#00c000</CssParameter>
|
||||
<CssParameter name="stroke-width">1.0</CssParameter>
|
||||
|
@ -351,7 +351,7 @@
|
|||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[highway] = 'bridleway' and [newforest_pathtype] = 'gravel'
|
||||
</Filter>
|
||||
</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#fff</CssParameter>
|
||||
<CssParameter name="stroke-width">6</CssParameter>
|
||||
|
@ -361,7 +361,7 @@
|
|||
</LineSymbolizer>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">brown</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">6,4</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">6,4</CssParameter>
|
||||
<CssParameter name="stroke-width">2</CssParameter>
|
||||
<CssParameter name="stroke-linejoin">round</CssParameter>
|
||||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
|
@ -369,17 +369,17 @@
|
|||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[highway] = 'bridleway' and [newforest_pathtype] = 'track'
|
||||
</Filter>
|
||||
</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">brown</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">2,4</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">2,4</CssParameter>
|
||||
<CssParameter name="stroke-width">2</CssParameter>
|
||||
<CssParameter name="stroke-linejoin">round</CssParameter>
|
||||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
<Style name="footway">
|
||||
</Style>
|
||||
<Style name="footway">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'footway'</Filter>
|
||||
<LineSymbolizer>
|
||||
|
@ -414,8 +414,8 @@
|
|||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
<Style name="cycleway">
|
||||
</Style>
|
||||
<Style name="cycleway">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'cycleway'</Filter>
|
||||
<LineSymbolizer>
|
||||
|
@ -433,8 +433,8 @@
|
|||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
<Style name="byway">
|
||||
</Style>
|
||||
<Style name="byway">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'byway'</Filter>
|
||||
<LineSymbolizer>
|
||||
|
@ -454,16 +454,16 @@
|
|||
</Style>
|
||||
|
||||
<Style name="contours">
|
||||
<Rule>
|
||||
<Filter>[major] = 1</Filter>
|
||||
<Rule>
|
||||
<Filter>[major] = 1</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#fb9b67</CssParameter>
|
||||
<CssParameter name="stroke-width">1.0</CssParameter>
|
||||
<CssParameter name="stroke-linejoin">round</CssParameter>
|
||||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
<Rule>
|
||||
</Rule>
|
||||
<Rule>
|
||||
<ElseFilter/>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#fb9b67</CssParameter>
|
||||
|
@ -477,7 +477,7 @@
|
|||
<Style name="contours-text">
|
||||
<Rule>
|
||||
<TextSymbolizer name="height" face_name="Bitstream Vera Sans Roman"
|
||||
size="8" fill="#fb9b67" halo_radius="0" placement="line"/>
|
||||
size="8" fill="#fb9b67" halo_radius="0" placement="line"/>
|
||||
</Rule>
|
||||
</Style>
|
||||
|
||||
|
|
|
@ -5,22 +5,22 @@
|
|||
<Rule>
|
||||
<Filter>[amenity]='pub'</Filter>
|
||||
<PointSymbolizer file="/home/nick/images/pub.png" type="png"
|
||||
width="16" height="16" />
|
||||
width="16" height="16" />
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[man_made]='mast'</Filter>
|
||||
<PointSymbolizer file="/home/nick/images/mast.png" type="png"
|
||||
width="16" height="16" />
|
||||
width="16" height="16" />
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[amenity]='parking'</Filter>
|
||||
<PointSymbolizer file="/home/nick/images/carpark.png" type="png"
|
||||
width="16" height="16"/>
|
||||
width="16" height="16"/>
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[residence]='farm'</Filter>
|
||||
<PointSymbolizer file="/home/nick/images/farm.png" type="png"
|
||||
width="16" height="16"/>
|
||||
width="16" height="16"/>
|
||||
</Rule>
|
||||
</Style>
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
|||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[leisure] = 'park' or [leisure] = 'common' or
|
||||
[leisure] = 'golf_course'</Filter>
|
||||
[leisure] = 'golf_course'</Filter>
|
||||
<PolygonSymbolizer>
|
||||
<CssParameter name="fill">#d8e8d0</CssParameter>
|
||||
</PolygonSymbolizer>
|
||||
|
@ -98,12 +98,12 @@
|
|||
<Filter>[natural] = 'peak'</Filter>
|
||||
<TextSymbolizer name="name" face_name="DejaVu Sans Book" size="11" fill="#000" halo_radius="1" wrap_width="0"/>
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[natural] = 'wood' or [natural] = 'water' or [natural] = 'heath'
|
||||
or [leisure] = 'golf_course' </Filter>
|
||||
<TextSymbolizer name="name" face_name="DejaVu Sans Book"
|
||||
size="10" fill="#000" halo_radius="2" wrap_width="0" />
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[natural] = 'wood' or [natural] = 'water' or [natural] = 'heath'
|
||||
or [leisure] = 'golf_course' </Filter>
|
||||
<TextSymbolizer name="name" face_name="DejaVu Sans Book"
|
||||
size="10" fill="#000" halo_radius="2" wrap_width="0" />
|
||||
</Rule>
|
||||
</Style>
|
||||
|
||||
<Style name="river">
|
||||
|
@ -200,7 +200,7 @@
|
|||
<Filter>[highway] = 'unsurfaced' or [highway] = 'track'</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#999</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">6,4</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">6,4</CssParameter>
|
||||
<CssParameter name="stroke-width">4</CssParameter>
|
||||
<CssParameter name="stroke-linejoin">round</CssParameter>
|
||||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
|
@ -218,7 +218,7 @@
|
|||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
</Style>
|
||||
<Style name="trunk">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'trunk' or [highway] = 'trunk_link'</Filter>
|
||||
|
@ -282,7 +282,7 @@
|
|||
<Style name="residential">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'residential' or [highway] = 'service' or
|
||||
[highway] = 'unsurfaced' or [highway] = 'track'</Filter>
|
||||
[highway] = 'unsurfaced' or [highway] = 'track'</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#fff</CssParameter>
|
||||
<CssParameter name="stroke-width">2</CssParameter>
|
||||
|
@ -290,9 +290,9 @@
|
|||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style name="bridleway">
|
||||
<Style name="bridleway">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'bridleway' and [newforest_pathtype] = ''</Filter>
|
||||
<LineSymbolizer>
|
||||
|
@ -312,7 +312,7 @@
|
|||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[highway] = 'bridleway' and [foot] = 'yes' and [horse] = 'yes'
|
||||
and [bicycle] = 'yes'</Filter>
|
||||
and [bicycle] = 'yes'</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#fff</CssParameter>
|
||||
<CssParameter name="stroke-width">6</CssParameter>
|
||||
|
@ -330,7 +330,7 @@
|
|||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[highway] = 'bridleway' and [newforest_pathtype] = 'narrow'
|
||||
</Filter>
|
||||
</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#00c000</CssParameter>
|
||||
<CssParameter name="stroke-width">1.0</CssParameter>
|
||||
|
@ -358,7 +358,7 @@
|
|||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[highway] = 'bridleway' and [newforest_pathtype] = 'gravel'
|
||||
</Filter>
|
||||
</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#fff</CssParameter>
|
||||
<CssParameter name="stroke-width">6</CssParameter>
|
||||
|
@ -368,7 +368,7 @@
|
|||
</LineSymbolizer>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">brown</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">6,4</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">6,4</CssParameter>
|
||||
<CssParameter name="stroke-width">2</CssParameter>
|
||||
<CssParameter name="stroke-linejoin">round</CssParameter>
|
||||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
|
@ -376,17 +376,17 @@
|
|||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[highway] = 'bridleway' and [newforest_pathtype] = 'track'
|
||||
</Filter>
|
||||
</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">brown</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">2,4</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">2,4</CssParameter>
|
||||
<CssParameter name="stroke-width">2</CssParameter>
|
||||
<CssParameter name="stroke-linejoin">round</CssParameter>
|
||||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
<Style name="footway">
|
||||
</Style>
|
||||
<Style name="footway">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'footway'</Filter>
|
||||
<LineSymbolizer>
|
||||
|
@ -421,8 +421,8 @@
|
|||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
<Style name="cycleway">
|
||||
</Style>
|
||||
<Style name="cycleway">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'cycleway'</Filter>
|
||||
<LineSymbolizer>
|
||||
|
@ -440,8 +440,8 @@
|
|||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
<Style name="byway">
|
||||
</Style>
|
||||
<Style name="byway">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'byway'</Filter>
|
||||
<LineSymbolizer>
|
||||
|
|
|
@ -5,22 +5,22 @@
|
|||
<Rule>
|
||||
<Filter>[amenity]='pub'</Filter>
|
||||
<PointSymbolizer file="/home/nick/images/pub.png" type="png"
|
||||
width="16" height="16" />
|
||||
width="16" height="16" />
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[man_made]='mast'</Filter>
|
||||
<PointSymbolizer file="/home/nick/images/mast.png" type="png"
|
||||
width="16" height="16" />
|
||||
width="16" height="16" />
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[amenity]='parking'</Filter>
|
||||
<PointSymbolizer file="/home/nick/images/carpark.png" type="png"
|
||||
width="16" height="16"/>
|
||||
width="16" height="16"/>
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[residence]='farm'</Filter>
|
||||
<PointSymbolizer file="/home/nick/images/farm.png" type="png"
|
||||
width="16" height="16"/>
|
||||
width="16" height="16"/>
|
||||
</Rule>
|
||||
</Style>
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
|||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[leisure] = 'park' or [leisure] = 'common' or
|
||||
[leisure] = 'golf_course'</Filter>
|
||||
[leisure] = 'golf_course'</Filter>
|
||||
<PolygonSymbolizer>
|
||||
<CssParameter name="fill">#d8e8d0</CssParameter>
|
||||
</PolygonSymbolizer>
|
||||
|
@ -98,12 +98,12 @@
|
|||
<Filter>[natural] = 'peak'</Filter>
|
||||
<TextSymbolizer name="name" face_name="DejaVu Sans Book" size="11" fill="#000" halo_radius="1" wrap_width="0"/>
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[natural] = 'wood' or [natural] = 'water' or [natural] = 'heath'
|
||||
or [leisure] = 'golf_course' </Filter>
|
||||
<TextSymbolizer name="name" face_name="DejaVu Sans Book"
|
||||
size="10" fill="#000" halo_radius="2" wrap_width="0" />
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[natural] = 'wood' or [natural] = 'water' or [natural] = 'heath'
|
||||
or [leisure] = 'golf_course' </Filter>
|
||||
<TextSymbolizer name="name" face_name="DejaVu Sans Book"
|
||||
size="10" fill="#000" halo_radius="2" wrap_width="0" />
|
||||
</Rule>
|
||||
</Style>
|
||||
|
||||
<Style name="river">
|
||||
|
@ -200,7 +200,7 @@
|
|||
<Filter>[highway] = 'unsurfaced' or [highway] = 'track'</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#999</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">6,4</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">6,4</CssParameter>
|
||||
<CssParameter name="stroke-width">4</CssParameter>
|
||||
<CssParameter name="stroke-linejoin">round</CssParameter>
|
||||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
|
@ -218,7 +218,7 @@
|
|||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
</Style>
|
||||
<Style name="trunk">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'trunk' or [highway] = 'trunk_link'</Filter>
|
||||
|
@ -282,7 +282,7 @@
|
|||
<Style name="residential">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'residential' or [highway] = 'service' or
|
||||
[highway] = 'unsurfaced' or [highway] = 'track'</Filter>
|
||||
[highway] = 'unsurfaced' or [highway] = 'track'</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#fff</CssParameter>
|
||||
<CssParameter name="stroke-width">2</CssParameter>
|
||||
|
@ -290,9 +290,9 @@
|
|||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style name="bridleway">
|
||||
<Style name="bridleway">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'bridleway' and [newforest_pathtype] = ''</Filter>
|
||||
<LineSymbolizer>
|
||||
|
@ -312,7 +312,7 @@
|
|||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[highway] = 'bridleway' and [foot] = 'yes' and [horse] = 'yes'
|
||||
and [bicycle] = 'yes'</Filter>
|
||||
and [bicycle] = 'yes'</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#fff</CssParameter>
|
||||
<CssParameter name="stroke-width">6</CssParameter>
|
||||
|
@ -330,7 +330,7 @@
|
|||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[highway] = 'bridleway' and [newforest_pathtype] = 'narrow'
|
||||
</Filter>
|
||||
</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#00c000</CssParameter>
|
||||
<CssParameter name="stroke-width">1.0</CssParameter>
|
||||
|
@ -358,7 +358,7 @@
|
|||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[highway] = 'bridleway' and [newforest_pathtype] = 'gravel'
|
||||
</Filter>
|
||||
</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">#fff</CssParameter>
|
||||
<CssParameter name="stroke-width">6</CssParameter>
|
||||
|
@ -368,7 +368,7 @@
|
|||
</LineSymbolizer>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">brown</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">6,4</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">6,4</CssParameter>
|
||||
<CssParameter name="stroke-width">2</CssParameter>
|
||||
<CssParameter name="stroke-linejoin">round</CssParameter>
|
||||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
|
@ -376,17 +376,17 @@
|
|||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[highway] = 'bridleway' and [newforest_pathtype] = 'track'
|
||||
</Filter>
|
||||
</Filter>
|
||||
<LineSymbolizer>
|
||||
<CssParameter name="stroke">brown</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">2,4</CssParameter>
|
||||
<CssParameter name="stroke-dasharray">2,4</CssParameter>
|
||||
<CssParameter name="stroke-width">2</CssParameter>
|
||||
<CssParameter name="stroke-linejoin">round</CssParameter>
|
||||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
<Style name="footway">
|
||||
</Style>
|
||||
<Style name="footway">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'footway'</Filter>
|
||||
<LineSymbolizer>
|
||||
|
@ -421,8 +421,8 @@
|
|||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
<Style name="cycleway">
|
||||
</Style>
|
||||
<Style name="cycleway">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'cycleway'</Filter>
|
||||
<LineSymbolizer>
|
||||
|
@ -440,8 +440,8 @@
|
|||
<CssParameter name="stroke-linecap">round</CssParameter>
|
||||
</LineSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
<Style name="byway">
|
||||
</Style>
|
||||
<Style name="byway">
|
||||
<Rule>
|
||||
<Filter>[highway] = 'byway'</Filter>
|
||||
<LineSymbolizer>
|
||||
|
|
|
@ -27,10 +27,10 @@ install_prefix = env['DESTDIR'] + '/' + prefix
|
|||
plugin_env = env.Clone()
|
||||
|
||||
postgis_src = Split(
|
||||
"""
|
||||
"""
|
||||
postgis.cpp
|
||||
postgisfs.cpp
|
||||
"""
|
||||
"""
|
||||
)
|
||||
|
||||
libraries = ['pq']
|
||||
|
|
|
@ -67,44 +67,50 @@ std::string numeric2string(const char* buf)
|
|||
|
||||
while ( i >= 0)
|
||||
{
|
||||
if (i <= weight && d < ndigits) {
|
||||
if (i <= weight && d < ndigits)
|
||||
{
|
||||
// All digits after the first must be padded to make the field 4 characters long
|
||||
if (d != 0) {
|
||||
if (d != 0)
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
int dig = digits[d];
|
||||
if (dig < 10)
|
||||
{
|
||||
ss << "000"; // 0000 - 0009
|
||||
}
|
||||
else if (dig < 100)
|
||||
{
|
||||
ss << "00"; // 0010 - 0099
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << "0"; // 0100 - 0999;
|
||||
}
|
||||
int dig = digits[d];
|
||||
if (dig < 10)
|
||||
{
|
||||
ss << "000"; // 0000 - 0009
|
||||
}
|
||||
else if (dig < 100)
|
||||
{
|
||||
ss << "00"; // 0010 - 0099
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << "0"; // 0100 - 0999;
|
||||
}
|
||||
#else
|
||||
switch(digits[d]) {
|
||||
case 0 ... 9:
|
||||
ss << "000"; // 0000 - 0009
|
||||
break;
|
||||
case 10 ... 99:
|
||||
ss << "00"; // 0010 - 0099
|
||||
break;
|
||||
case 100 ... 999:
|
||||
ss << "0"; // 0100 - 0999
|
||||
break;
|
||||
}
|
||||
switch(digits[d])
|
||||
{
|
||||
case 0 ... 9:
|
||||
ss << "000"; // 0000 - 0009
|
||||
break;
|
||||
case 10 ... 99:
|
||||
ss << "00"; // 0010 - 0099
|
||||
break;
|
||||
case 100 ... 999:
|
||||
ss << "0"; // 0100 - 0999
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
ss << digits[d++];
|
||||
} else {
|
||||
if (d == 0)
|
||||
ss << "0";
|
||||
else
|
||||
ss << "0000";
|
||||
ss << digits[d++];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d == 0)
|
||||
ss << "0";
|
||||
else
|
||||
ss << "0000";
|
||||
}
|
||||
|
||||
i--;
|
||||
}
|
||||
if (dscale > 0)
|
||||
|
@ -115,29 +121,29 @@ std::string numeric2string(const char* buf)
|
|||
{
|
||||
int value;
|
||||
if (i <= weight && d < ndigits)
|
||||
value = digits[d++];
|
||||
value = digits[d++];
|
||||
else
|
||||
value = 0;
|
||||
value = 0;
|
||||
|
||||
// Output up to 4 decimal digits for this value
|
||||
if (dscale > 0) {
|
||||
ss << (value / 1000);
|
||||
value %= 1000;
|
||||
dscale--;
|
||||
ss << (value / 1000);
|
||||
value %= 1000;
|
||||
dscale--;
|
||||
}
|
||||
if (dscale > 0) {
|
||||
ss << (value / 100);
|
||||
value %= 100;
|
||||
dscale--;
|
||||
ss << (value / 100);
|
||||
value %= 100;
|
||||
dscale--;
|
||||
}
|
||||
if (dscale > 0) {
|
||||
ss << (value / 10);
|
||||
value %= 10;
|
||||
dscale--;
|
||||
ss << (value / 10);
|
||||
value %= 10;
|
||||
dscale--;
|
||||
}
|
||||
if (dscale > 0) {
|
||||
ss << value;
|
||||
dscale--;
|
||||
ss << value;
|
||||
dscale--;
|
||||
}
|
||||
|
||||
i--;
|
||||
|
@ -166,7 +172,7 @@ feature_ptr postgis_featureset::next()
|
|||
const char *data = rs_->getValue(0);
|
||||
geometry_utils::from_wkb(*feature,data,size,multiple_geometries_);
|
||||
totalGeomSize_+=size;
|
||||
|
||||
|
||||
for (unsigned pos=1;pos<num_attrs_+1;++pos)
|
||||
{
|
||||
std::string name = rs_->getFieldName(pos);
|
||||
|
|
|
@ -27,11 +27,11 @@ install_prefix = env['DESTDIR'] + '/' + prefix
|
|||
plugin_env = env.Clone()
|
||||
|
||||
raster_src = Split(
|
||||
"""
|
||||
raster_datasource.cpp
|
||||
raster_featureset.cpp
|
||||
raster_info.cpp
|
||||
"""
|
||||
"""
|
||||
raster_datasource.cpp
|
||||
raster_featureset.cpp
|
||||
raster_info.cpp
|
||||
"""
|
||||
)
|
||||
|
||||
libraries = []
|
||||
|
|
|
@ -27,10 +27,10 @@ install_prefix = env['DESTDIR'] + '/' + prefix
|
|||
plugin_env = env.Clone()
|
||||
|
||||
rasterlite_src = Split(
|
||||
"""
|
||||
rasterlite_datasource.cpp
|
||||
rasterlite_featureset.cpp
|
||||
"""
|
||||
"""
|
||||
rasterlite_datasource.cpp
|
||||
rasterlite_featureset.cpp
|
||||
"""
|
||||
)
|
||||
|
||||
libraries = [env['PLUGINS']['rasterlite']['lib']]
|
||||
|
|
|
@ -59,7 +59,7 @@ inline void *rasterlite_datasource::open_dataset() const
|
|||
{
|
||||
std::string error (rasterliteGetLastError(dataset));
|
||||
|
||||
rasterliteClose (dataset);
|
||||
rasterliteClose (dataset);
|
||||
|
||||
throw datasource_exception(error);
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ void rasterlite_datasource::bind() const
|
|||
{
|
||||
std::string error (rasterliteGetLastError(dataset));
|
||||
|
||||
rasterliteClose (dataset);
|
||||
rasterliteClose (dataset);
|
||||
|
||||
throw datasource_exception(error);
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ void rasterlite_datasource::bind() const
|
|||
{
|
||||
std::string error (rasterliteGetLastError(dataset));
|
||||
|
||||
rasterliteClose (dataset);
|
||||
rasterliteClose (dataset);
|
||||
|
||||
throw datasource_exception(error);
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ feature_ptr rasterlite_featureset::get_feature(mapnik::query const& q)
|
|||
std::clog << "Rasterlite Plugin: View extent=" << q.get_bbox() << std::endl;
|
||||
std::clog << "Rasterlite Plugin: Intersect extent=" << intersect << std::endl;
|
||||
std::clog << "Rasterlite Plugin: Query resolution=" << boost::get<0>(q.resolution())
|
||||
<< "," << boost::get<1>(q.resolution()) << std::endl;
|
||||
<< "," << boost::get<1>(q.resolution()) << std::endl;
|
||||
std::clog << "Rasterlite Plugin: Size=" << width << " " << height << std::endl;
|
||||
std::clog << "Rasterlite Plugin: Pixel Size=" << pixel_size << std::endl;
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
|
||||
# This file is part of Mapnik (c++ mapping toolkit)
|
||||
#
|
||||
# Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
|
@ -28,13 +28,13 @@ install_prefix = env['DESTDIR'] + '/' + prefix
|
|||
plugin_env = env.Clone()
|
||||
|
||||
shape_src = Split(
|
||||
"""
|
||||
"""
|
||||
dbffile.cpp
|
||||
shape.cpp
|
||||
shape_featureset.cpp
|
||||
shape_index_featureset.cpp
|
||||
shape_io.cpp
|
||||
"""
|
||||
"""
|
||||
)
|
||||
|
||||
libraries = ['boost_iostreams%s' % env['BOOST_APPEND']]
|
||||
|
|
|
@ -46,7 +46,7 @@ int main(int argc,char** argv)
|
|||
{
|
||||
int width=dbf.descriptor(j).length_;
|
||||
string name=dbf.descriptor(j).name_;
|
||||
char type=dbf.descriptor(j).type_;
|
||||
char type=dbf.descriptor(j).type_;
|
||||
cout<<setw(width)<<name<<"("<<type<<")""|";
|
||||
}
|
||||
cout<<endl;
|
||||
|
|
|
@ -204,11 +204,11 @@ geometry_type * shape_io::read_polylinem()
|
|||
end=num_points;
|
||||
else
|
||||
end=parts[k+1];
|
||||
|
||||
|
||||
double x=record.read_double();
|
||||
double y=record.read_double();
|
||||
line->move_to(x,y);
|
||||
|
||||
|
||||
for (int j=start+1;j<end;++j)
|
||||
{
|
||||
x=record.read_double();
|
||||
|
@ -284,7 +284,7 @@ geometry_type * shape_io::read_polylinez()
|
|||
//double z1=record.read_double();
|
||||
//for (int i=0;i<num_points;++i)
|
||||
// {
|
||||
// double z=record.read_double();
|
||||
// double z=record.read_double();
|
||||
// }
|
||||
|
||||
// m-range
|
||||
|
@ -428,7 +428,7 @@ geometry_type * shape_io::read_polygonz()
|
|||
//double z1=record.read_double();
|
||||
//for (int i=0;i<num_points;++i)
|
||||
//{
|
||||
// double z=record.read_double();
|
||||
// double z=record.read_double();
|
||||
//}
|
||||
|
||||
// m-range
|
||||
|
|
|
@ -27,10 +27,10 @@ install_prefix = env['DESTDIR'] + '/' + prefix
|
|||
plugin_env = env.Clone()
|
||||
|
||||
sqlite_src = Split(
|
||||
"""
|
||||
sqlite_datasource.cpp
|
||||
sqlite_featureset.cpp
|
||||
"""
|
||||
"""
|
||||
sqlite_datasource.cpp
|
||||
sqlite_featureset.cpp
|
||||
"""
|
||||
)
|
||||
|
||||
libraries = [ 'sqlite3' ]
|
||||
|
|
|
@ -156,7 +156,7 @@ public:
|
|||
}
|
||||
|
||||
return new sqlite_resultset (stmt);
|
||||
}
|
||||
}
|
||||
|
||||
sqlite3* operator*()
|
||||
{
|
||||
|
|
|
@ -38,10 +38,10 @@ plugin_env = env.Clone()
|
|||
|
||||
# Add the cpp files that need to be compiled
|
||||
plugin_sources = Split(
|
||||
"""
|
||||
%(PLUGIN_NAME)s_datasource.cpp
|
||||
%(PLUGIN_NAME)s_featureset.cpp
|
||||
""" % locals()
|
||||
"""
|
||||
%(PLUGIN_NAME)s_datasource.cpp
|
||||
%(PLUGIN_NAME)s_featureset.cpp
|
||||
""" % locals()
|
||||
)
|
||||
|
||||
# Add any external libraries this plugin should
|
||||
|
|
Loading…
Reference in a new issue