add support for windows unicode paths in rapidxml loader

Conflicts:
	src/rapidxml_loader.cpp
This commit is contained in:
Dane Springmeyer 2014-08-25 14:50:58 -07:00
parent 70f71790fe
commit 8e996e10ab
7 changed files with 149 additions and 0 deletions

View file

@ -26,6 +26,8 @@
// mapnik // mapnik
#include <mapnik/config_error.hpp> #include <mapnik/config_error.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/fs.hpp>
#include <mapnik/xml_loader.hpp> #include <mapnik/xml_loader.hpp>
#include <boost/property_tree/detail/xml_parser_read_rapidxml.hpp> #include <boost/property_tree/detail/xml_parser_read_rapidxml.hpp>
#include <mapnik/xml_node.hpp> #include <mapnik/xml_node.hpp>
@ -54,8 +56,16 @@ public:
void load(std::string const& filename, xml_node &node) void load(std::string const& filename, xml_node &node)
{ {
if (!mapnik::util::exists(filename))
{
throw config_error(std::string("Could not load map file: File does not exist"), 0, filename);
}
filename_ = filename; filename_ = filename;
#ifdef _WINDOWS
std::basic_ifstream<char> stream(mapnik::utf8_to_utf16(filename));
#else
std::basic_ifstream<char> stream(filename.c_str()); std::basic_ifstream<char> stream(filename.c_str());
#endif
if (!stream) if (!stream)
{ {
throw config_error("Could not load map file", 0, filename); throw config_error("Could not load map file", 0, filename);

View file

@ -0,0 +1,74 @@
{
"keys": [
"",
"1",
"2"
],
"data": {},
"grid": [
" !! ",
" !! ",
" !! ",
" !! ",
" !! ",
" !! ",
" !! ",
" !! ",
" !! ",
" !! ",
" !! ",
" !! ",
" !! ",
" !! ",
" !! ",
" !! ",
" ## ##! ",
" #### ### #### ",
" #################### ",
" ################### ",
" ################## !!",
" #################### !!! ",
" ##################### !!! ",
" ###################### !!! ",
" ###################### !!! ",
" ###################### !!! ",
" ###################### !!! ",
" ###################### !!! ",
" ###################### !!! ",
" ################################!! ",
" #############################!! ",
" # ################### !!! # ",
" ################# !!! ",
" # !!############## !!! ",
" ###! ####### !!! ",
" #!## ######### !!! ",
" !!### ##########!! ",
" !! ############## ",
" !! ############# ",
" !! ####!#### ",
" !! ####!#### ",
" !! ######### ",
" !! ############### ",
" !! ################### ",
" !! ##################### ",
" !! !##################### ",
" !! !!##################### ",
" !! !!! ################# ",
" !! !!! ########### ",
" !! !!! ",
" !! !!! ",
" !! !!! ",
" !! !!! ",
" !! !!! ",
" !! !!! ",
" !! !!! ",
"!! !!! ",
"! !!! ",
"!!! ",
"!! ",
" ",
" ",
" ",
" "
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View file

@ -0,0 +1,65 @@
<Map background-color="#eee" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<Style name="frame" filter-mode="first">
<Rule>
<Filter>[mapnik::geometry_type]=linestring</Filter>
<LineSymbolizer
stroke="[color]"
stroke-width="[width]"
offset="abs([offset]*2.0)"/>
<LineSymbolizer
stroke="[color]"
stroke-width="[width]"
offset="-[offset]*2.0"
geometry-transform="rotate(360-(tan(-180)*10))"/>
</Rule>
<Rule>
<Filter>[mapnik::geometry_type]=point</Filter>
<MarkersSymbolizer
file="../../../[base-path]/[filetype]/[filename].[filetype]"
width="exp([width])"
/>
</Rule>
</Style>
<Layer name="frame" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<StyleName>frame</StyleName>
<Datasource>
<Parameter name="type">ogr</Parameter>
<Parameter name="layer_by_index">0</Parameter>
<Parameter name="inline"><![CDATA[
{
"type" : "FeatureCollection",
"features" : [
{
"properties" : {
"width":"5",
"color" : "red",
"offset": 10
},
"geometry" : {
"coordinates" : [[-10,-10],[10,10]],
"type" : "LineString"
},
"type" : "Feature",
},
{
"geometry" : {
"coordinates" : [ 0,0 ],
"type" : "Point"
},
"properties" : {
"base-path":"./tests/data",
"filetype":"svg",
"filename":"octocat",
"width":"5",
"color" : "#ace"
},
"type" : "Feature",
}
]
}
]]></Parameter>
</Datasource>
</Layer>
</Map>