Merge branch 'offset' of github.com:mapnik/mapnik into offset
This commit is contained in:
commit
eb5ca2af87
31 changed files with 170 additions and 5110 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -18,6 +18,7 @@ bindings/python/mapnik/paths.py
|
|||
config.cache
|
||||
config.log
|
||||
config.py
|
||||
mapnik-settings.env
|
||||
mason_packages/
|
||||
.mason/
|
||||
.sconf_temp/
|
||||
|
|
2
Makefile
2
Makefile
|
@ -13,7 +13,7 @@ install:
|
|||
$(PYTHON) scons/scons.py -j$(JOBS) --config=cache --implicit-cache --max-drift=1 install
|
||||
|
||||
python:
|
||||
if [[ ! -d ./bindings/python ]]; then git clone git@github.com:mapnik/python-mapnik.git --recursive ./bindings/python; else (cd bindings/python && git pull && git submodule update --init); fi;
|
||||
if [ ! -d ./bindings/python ]; then git clone git@github.com:mapnik/python-mapnik.git --recursive ./bindings/python; else (cd bindings/python && git pull && git submodule update --init); fi;
|
||||
make
|
||||
python bindings/python/test/visual.py -q
|
||||
|
||||
|
|
|
@ -1593,7 +1593,6 @@ if not preconfigured:
|
|||
# prepend to make sure we link locally
|
||||
env.Prepend(CPPPATH = '#deps/agg/include')
|
||||
env.Prepend(LIBPATH = '#deps/agg')
|
||||
env.Prepend(CPPPATH = '#deps/clipper/include')
|
||||
# prepend deps dir for auxillary headers
|
||||
env.Prepend(CPPPATH = '#deps')
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
// agg
|
||||
#include "agg_conv_clip_polygon.h"
|
||||
// clipper
|
||||
#include "clipper.hpp"
|
||||
#include "agg_path_storage.h"
|
||||
// rendering
|
||||
#include "agg_basics.h"
|
||||
|
@ -307,6 +306,8 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Commented out section because clipper moved out of mapnik core.
|
||||
inline void process_polynode_branch(ClipperLib::PolyNode* polynode,
|
||||
mapnik::geometry::multi_polygon<double> & mp)
|
||||
{
|
||||
|
@ -491,6 +492,7 @@ public:
|
|||
return valid;
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
@ -518,9 +520,11 @@ int main(int argc, char** argv)
|
|||
test3 test_runner(params,wkt_in,clipping_box);
|
||||
run(test_runner,"clipping polygon with boost");
|
||||
}
|
||||
/*
|
||||
{
|
||||
test4 test_runner(params,wkt_in,clipping_box);
|
||||
run(test_runner,"clipping polygon with clipper_tree");
|
||||
}
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
|
26
deps/clipper/build.py
vendored
26
deps/clipper/build.py
vendored
|
@ -1,26 +0,0 @@
|
|||
# This file is part of Mapnik (c++ mapping toolkit)
|
||||
# Copyright (C) 2013 Artem Pavlenko
|
||||
#
|
||||
# Mapnik is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
#
|
||||
|
||||
import os
|
||||
from glob import glob
|
||||
|
||||
Import('env')
|
||||
lib_env = env.Clone()
|
||||
lib_env.Append(CXXFLAGS='-fPIC')
|
||||
lib_env.StaticLibrary('clipper', ['./src/clipper.cpp',], LIBS=[])
|
411
deps/clipper/include/clipper.hpp
vendored
411
deps/clipper/include/clipper.hpp
vendored
|
@ -1,411 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* *
|
||||
* Author : Angus Johnson *
|
||||
* Version : 6.2.9 *
|
||||
* Date : 16 February 2015 *
|
||||
* Website : http://www.angusj.com *
|
||||
* Copyright : Angus Johnson 2010-2015 *
|
||||
* *
|
||||
* License: *
|
||||
* Use, modification & distribution is subject to Boost Software License Ver 1. *
|
||||
* http://www.boost.org/LICENSE_1_0.txt *
|
||||
* *
|
||||
* Attributions: *
|
||||
* The code in this library is an extension of Bala Vatti's clipping algorithm: *
|
||||
* "A generic solution to polygon clipping" *
|
||||
* Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63. *
|
||||
* http://portal.acm.org/citation.cfm?id=129906 *
|
||||
* *
|
||||
* Computer graphics and geometric modeling: implementation and algorithms *
|
||||
* By Max K. Agoston *
|
||||
* Springer; 1 edition (January 4, 2005) *
|
||||
* http://books.google.com/books?q=vatti+clipping+agoston *
|
||||
* *
|
||||
* See also: *
|
||||
* "Polygon Offsetting by Computing Winding Numbers" *
|
||||
* Paper no. DETC2005-85513 pp. 565-575 *
|
||||
* ASME 2005 International Design Engineering Technical Conferences *
|
||||
* and Computers and Information in Engineering Conference (IDETC/CIE2005) *
|
||||
* September 24-28, 2005 , Long Beach, California, USA *
|
||||
* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef clipper_hpp
|
||||
#define clipper_hpp
|
||||
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
||||
#define CLIPPER_VERSION "6.2.6"
|
||||
|
||||
//use_int32: When enabled 32bit ints are used instead of 64bit ints. This
|
||||
//improve performance but coordinate values are limited to the range +/- 46340
|
||||
//#define use_int32
|
||||
|
||||
//use_xyz: adds a Z member to IntPoint. Adds a minor cost to perfomance.
|
||||
//#define use_xyz
|
||||
|
||||
//use_lines: Enables line clipping. Adds a very minor cost to performance.
|
||||
#define use_lines
|
||||
|
||||
//use_deprecated: Enables temporary support for the obsolete functions
|
||||
//#define use_deprecated
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <ostream>
|
||||
#include <functional>
|
||||
#include <queue>
|
||||
|
||||
namespace ClipperLib {
|
||||
|
||||
enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor };
|
||||
enum PolyType { ptSubject, ptClip };
|
||||
//By far the most widely used winding rules for polygon filling are
|
||||
//EvenOdd & NonZero (GDI, GDI+, XLib, OpenGL, Cairo, AGG, Quartz, SVG, Gr32)
|
||||
//Others rules include Positive, Negative and ABS_GTR_EQ_TWO (only in OpenGL)
|
||||
//see http://glprogramming.com/red/chapter11.html
|
||||
enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative };
|
||||
|
||||
#ifdef use_int32
|
||||
typedef int cInt;
|
||||
static cInt const loRange = 0x7FFF;
|
||||
static cInt const hiRange = 0x7FFF;
|
||||
#else
|
||||
typedef std::int64_t cInt;
|
||||
static cInt const loRange = 0x3FFFFFFF;
|
||||
static cInt const hiRange = 0x3FFFFFFFFFFFFFFFLL;
|
||||
typedef std::int64_t long64; //used by Int128 class
|
||||
typedef std::uint64_t ulong64;
|
||||
|
||||
#endif
|
||||
/*
|
||||
struct IntPoint {
|
||||
cInt x;
|
||||
cInt y;
|
||||
#ifdef use_xyz
|
||||
cInt z;
|
||||
IntPoint(cInt x = 0, cInt y = 0, cInt z = 0): X(x), Y(y), Z(z) {};
|
||||
#else
|
||||
IntPoint(cInt x_ = 0, cInt y_ = 0): x(x_), y(y_) {};
|
||||
#endif
|
||||
|
||||
friend inline bool operator== (const IntPoint& a, const IntPoint& b)
|
||||
{
|
||||
return a.x == b.x && a.y == b.y;
|
||||
}
|
||||
friend inline bool operator!= (const IntPoint& a, const IntPoint& b)
|
||||
{
|
||||
return a.x != b.x || a.y != b.y;
|
||||
}
|
||||
};*/
|
||||
|
||||
typedef mapnik::geometry::point<cInt> IntPoint;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//typedef std::vector< IntPoint > Path;
|
||||
typedef mapnik::geometry::line_string<cInt> Path;
|
||||
typedef mapnik::geometry::multi_line_string<cInt> Paths;
|
||||
|
||||
inline Path& operator <<(Path& poly, const IntPoint& p) {poly.push_back(p); return poly;}
|
||||
inline Paths& operator <<(Paths& polys, const Path& p) {polys.push_back(p); return polys;}
|
||||
|
||||
std::ostream& operator <<(std::ostream &s, const IntPoint &p);
|
||||
std::ostream& operator <<(std::ostream &s, const Path &p);
|
||||
std::ostream& operator <<(std::ostream &s, const Paths &p);
|
||||
|
||||
struct DoublePoint
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
DoublePoint(double x_ = 0, double y_ = 0) : x(x_), y(y_) {}
|
||||
DoublePoint(IntPoint ip) : x((double)ip.x), y((double)ip.y) {}
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifdef use_xyz
|
||||
typedef void (*ZFillCallback)(IntPoint& e1bot, IntPoint& e1top, IntPoint& e2bot, IntPoint& e2top, IntPoint& pt);
|
||||
#endif
|
||||
|
||||
enum InitOptions {ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4};
|
||||
enum JoinType {jtSquare, jtRound, jtMiter};
|
||||
enum EndType {etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound};
|
||||
|
||||
class PolyNode;
|
||||
typedef std::vector< PolyNode* > PolyNodes;
|
||||
|
||||
class MAPNIK_DECL PolyNode
|
||||
{
|
||||
public:
|
||||
PolyNode();
|
||||
virtual ~PolyNode(){};
|
||||
Path Contour;
|
||||
PolyNodes Childs;
|
||||
PolyNode* Parent;
|
||||
PolyNode* GetNext() const;
|
||||
bool IsHole() const;
|
||||
bool IsOpen() const;
|
||||
int ChildCount() const;
|
||||
private:
|
||||
unsigned Index; //node index in Parent.Childs
|
||||
bool m_IsOpen;
|
||||
JoinType m_jointype;
|
||||
EndType m_endtype;
|
||||
PolyNode* GetNextSiblingUp() const;
|
||||
void AddChild(PolyNode& child);
|
||||
friend class MAPNIK_DECL Clipper; //to access Index
|
||||
friend class MAPNIK_DECL ClipperOffset;
|
||||
};
|
||||
|
||||
class MAPNIK_DECL PolyTree: public PolyNode
|
||||
{
|
||||
public:
|
||||
~PolyTree(){Clear();};
|
||||
PolyNode* GetFirst() const;
|
||||
void Clear();
|
||||
int Total() const;
|
||||
private:
|
||||
PolyNodes AllNodes;
|
||||
friend class MAPNIK_DECL Clipper; //to access AllNodes
|
||||
};
|
||||
|
||||
MAPNIK_DECL bool Orientation(const Path &poly);
|
||||
MAPNIK_DECL double Area(const Path &poly);
|
||||
MAPNIK_DECL int PointInPolygon(const IntPoint &pt, const Path &path);
|
||||
|
||||
MAPNIK_DECL void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
|
||||
MAPNIK_DECL void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
|
||||
MAPNIK_DECL void SimplifyPolygons(Paths &polys, PolyFillType fillType = pftEvenOdd);
|
||||
|
||||
MAPNIK_DECL void CleanPolygon(const Path& in_poly, Path& out_poly, double distance = 1.415);
|
||||
MAPNIK_DECL void CleanPolygon(Path& poly, double distance = 1.415);
|
||||
MAPNIK_DECL void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance = 1.415);
|
||||
MAPNIK_DECL void CleanPolygons(Paths& polys, double distance = 1.415);
|
||||
|
||||
void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool pathIsClosed);
|
||||
void MinkowskiSum(const Path& pattern, const Paths& paths, Paths& solution, bool pathIsClosed);
|
||||
void MinkowskiDiff(const Path& poly1, const Path& poly2, Paths& solution);
|
||||
|
||||
void PolyTreeToPaths(const PolyTree& polytree, Paths& paths);
|
||||
void ClosedPathsFromPolyTree(const PolyTree& polytree, Paths& paths);
|
||||
MAPNIK_DECL void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths);
|
||||
|
||||
void ReversePath(Path& p);
|
||||
void ReversePaths(Paths& p);
|
||||
|
||||
struct IntRect { cInt left; cInt top; cInt right; cInt bottom; };
|
||||
|
||||
//enums that are used internally ...
|
||||
enum EdgeSide { esLeft = 1, esRight = 2};
|
||||
|
||||
//forward declarations (for stuff used internally) ...
|
||||
struct TEdge;
|
||||
struct IntersectNode;
|
||||
struct LocalMinimum;
|
||||
struct OutPt;
|
||||
struct OutRec;
|
||||
struct Join;
|
||||
|
||||
typedef std::vector < OutRec* > PolyOutList;
|
||||
typedef std::vector < TEdge* > EdgeList;
|
||||
typedef std::vector < Join* > JoinList;
|
||||
typedef std::vector < IntersectNode* > IntersectList;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//ClipperBase is the ancestor to the Clipper class. It should not be
|
||||
//instantiated directly. This class simply abstracts the conversion of sets of
|
||||
//polygon coordinates into edge objects that are stored in a LocalMinima list.
|
||||
class MAPNIK_DECL ClipperBase
|
||||
{
|
||||
public:
|
||||
ClipperBase();
|
||||
virtual ~ClipperBase();
|
||||
bool AddPath(const Path &pg, PolyType PolyTyp, bool Closed);
|
||||
bool AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed);
|
||||
virtual void Clear();
|
||||
IntRect GetBounds();
|
||||
bool PreserveCollinear() {return m_PreserveCollinear;};
|
||||
void PreserveCollinear(bool value) {m_PreserveCollinear = value;};
|
||||
protected:
|
||||
void DisposeLocalMinimaList();
|
||||
TEdge* AddBoundsToLML(TEdge *e, bool IsClosed);
|
||||
void PopLocalMinima();
|
||||
virtual void Reset();
|
||||
TEdge* ProcessBound(TEdge* E, bool IsClockwise);
|
||||
TEdge* DescendToMin(TEdge *&E);
|
||||
void AscendToMax(TEdge *&E, bool Appending, bool IsClosed);
|
||||
|
||||
typedef std::vector<LocalMinimum> MinimaList;
|
||||
MinimaList::iterator m_CurrentLM;
|
||||
MinimaList m_MinimaList;
|
||||
|
||||
bool m_UseFullRange;
|
||||
EdgeList m_edges;
|
||||
bool m_PreserveCollinear;
|
||||
bool m_HasOpenPaths;
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class MAPNIK_DECL Clipper : public virtual ClipperBase
|
||||
{
|
||||
public:
|
||||
Clipper(int initOptions = 0);
|
||||
~Clipper();
|
||||
bool Execute(ClipType clipType,
|
||||
Paths &solution,
|
||||
PolyFillType fillType = pftEvenOdd);
|
||||
bool Execute(ClipType clipType,
|
||||
Paths &solution,
|
||||
PolyFillType subjFillType,
|
||||
PolyFillType clipFillType);
|
||||
bool Execute(ClipType clipType,
|
||||
PolyTree &polytree,
|
||||
PolyFillType fillType = pftEvenOdd);
|
||||
bool Execute(ClipType clipType,
|
||||
PolyTree &polytree,
|
||||
PolyFillType subjFillType,
|
||||
PolyFillType clipFillType);
|
||||
bool ReverseSolution() { return m_ReverseOutput; };
|
||||
void ReverseSolution(bool value) {m_ReverseOutput = value;};
|
||||
bool StrictlySimple() {return m_StrictSimple;};
|
||||
void StrictlySimple(bool value) {m_StrictSimple = value;};
|
||||
//set the callback function for z value filling on intersections (otherwise Z is 0)
|
||||
#ifdef use_xyz
|
||||
void ZFillFunction(ZFillCallback zFillFunc);
|
||||
#endif
|
||||
protected:
|
||||
void Reset();
|
||||
virtual bool ExecuteInternal();
|
||||
private:
|
||||
PolyOutList m_PolyOuts;
|
||||
JoinList m_Joins;
|
||||
JoinList m_GhostJoins;
|
||||
IntersectList m_IntersectList;
|
||||
ClipType m_ClipType;
|
||||
typedef std::priority_queue<cInt> ScanbeamList;
|
||||
ScanbeamList m_Scanbeam;
|
||||
typedef std::list<cInt> MaximaList;
|
||||
MaximaList m_Maxima;
|
||||
TEdge *m_ActiveEdges;
|
||||
TEdge *m_SortedEdges;
|
||||
bool m_ExecuteLocked;
|
||||
PolyFillType m_ClipFillType;
|
||||
PolyFillType m_SubjFillType;
|
||||
bool m_ReverseOutput;
|
||||
bool m_UsingPolyTree;
|
||||
bool m_StrictSimple;
|
||||
#ifdef use_xyz
|
||||
ZFillCallback m_ZFill; //custom callback
|
||||
#endif
|
||||
void SetWindingCount(TEdge& edge);
|
||||
bool IsEvenOddFillType(const TEdge& edge) const;
|
||||
bool IsEvenOddAltFillType(const TEdge& edge) const;
|
||||
void InsertScanbeam(const cInt Y);
|
||||
cInt PopScanbeam();
|
||||
void InsertLocalMinimaIntoAEL(const cInt botY);
|
||||
void InsertEdgeIntoAEL(TEdge *edge, TEdge* startEdge);
|
||||
void AddEdgeToSEL(TEdge *edge);
|
||||
void CopyAELToSEL();
|
||||
void DeleteFromSEL(TEdge *e);
|
||||
void DeleteFromAEL(TEdge *e);
|
||||
void UpdateEdgeIntoAEL(TEdge *&e);
|
||||
void SwapPositionsInSEL(TEdge *edge1, TEdge *edge2);
|
||||
bool IsContributing(const TEdge& edge) const;
|
||||
bool IsTopHorz(const cInt XPos);
|
||||
void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2);
|
||||
void DoMaxima(TEdge *e);
|
||||
void ProcessHorizontals();
|
||||
void ProcessHorizontal(TEdge *horzEdge);
|
||||
void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
|
||||
OutPt* AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
|
||||
OutRec* GetOutRec(int idx);
|
||||
void AppendPolygon(TEdge *e1, TEdge *e2);
|
||||
void IntersectEdges(TEdge *e1, TEdge *e2, IntPoint &pt);
|
||||
OutRec* CreateOutRec();
|
||||
OutPt* AddOutPt(TEdge *e, const IntPoint &pt);
|
||||
OutPt* GetLastOutPt(TEdge *e);
|
||||
void DisposeAllOutRecs();
|
||||
void DisposeOutRec(PolyOutList::size_type index);
|
||||
bool ProcessIntersections(const cInt topY);
|
||||
void BuildIntersectList(const cInt topY);
|
||||
void ProcessIntersectList();
|
||||
void ProcessEdgesAtTopOfScanbeam(const cInt topY);
|
||||
void BuildResult(Paths& polys);
|
||||
void BuildResult2(PolyTree& polytree);
|
||||
void SetHoleState(TEdge *e, OutRec *outrec);
|
||||
void DisposeIntersectNodes();
|
||||
bool FixupIntersectionOrder();
|
||||
void FixupOutPolygon(OutRec &outrec);
|
||||
void FixupOutPolyline(OutRec &outrec);
|
||||
bool IsHole(TEdge *e);
|
||||
bool FindOwnerFromSplitRecs(OutRec &outRec, OutRec *&currOrfl);
|
||||
void FixHoleLinkage(OutRec &outrec);
|
||||
void AddJoin(OutPt *op1, OutPt *op2, const IntPoint offPt);
|
||||
void ClearJoins();
|
||||
void ClearGhostJoins();
|
||||
void AddGhostJoin(OutPt *op, const IntPoint offPt);
|
||||
bool JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2);
|
||||
void JoinCommonEdges();
|
||||
void DoSimplePolygons();
|
||||
void FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec);
|
||||
void FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec);
|
||||
#ifdef use_xyz
|
||||
void SetZ(IntPoint& pt, TEdge& e1, TEdge& e2);
|
||||
#endif
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class MAPNIK_DECL ClipperOffset
|
||||
{
|
||||
public:
|
||||
ClipperOffset(double miterLimit = 2.0, double roundPrecision = 0.25);
|
||||
~ClipperOffset();
|
||||
void AddPath(const Path& path, JoinType joinType, EndType endType);
|
||||
void AddPaths(const Paths& paths, JoinType joinType, EndType endType);
|
||||
void Execute(Paths& solution, double delta);
|
||||
void Execute(PolyTree& solution, double delta);
|
||||
void Clear();
|
||||
double MiterLimit;
|
||||
double ArcTolerance;
|
||||
private:
|
||||
Paths m_destPolys;
|
||||
Path m_srcPoly;
|
||||
Path m_destPoly;
|
||||
std::vector<DoublePoint> m_normals;
|
||||
double m_delta, m_sinA, m_sin, m_cos;
|
||||
double m_miterLim, m_StepsPerRad;
|
||||
IntPoint m_lowest;
|
||||
PolyNode m_polyNodes;
|
||||
|
||||
void FixOrientations();
|
||||
void DoOffset(double delta);
|
||||
void OffsetPoint(int j, int& k, JoinType jointype);
|
||||
void DoSquare(int j, int k);
|
||||
void DoMiter(int j, int k, double r);
|
||||
void DoRound(int j, int k);
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class clipperException : public std::exception
|
||||
{
|
||||
public:
|
||||
clipperException(const char* description): m_descr(description) {}
|
||||
virtual ~clipperException() throw() {}
|
||||
virtual const char* what() const throw() {return m_descr.c_str();}
|
||||
private:
|
||||
std::string m_descr;
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
} //ClipperLib namespace
|
||||
|
||||
#endif //clipper_hpp
|
||||
|
||||
|
4571
deps/clipper/src/clipper.cpp
vendored
4571
deps/clipper/src/clipper.cpp
vendored
File diff suppressed because it is too large
Load diff
1
deps/mapnik/build.py
vendored
1
deps/mapnik/build.py
vendored
|
@ -7,7 +7,6 @@ subdirs = {
|
|||
'sparsehash':'sparsehash',
|
||||
'sparsehash/internal':'sparsehash/internal',
|
||||
'../agg/include':'agg',
|
||||
'../clipper/include':'agg'
|
||||
}
|
||||
|
||||
if 'install' in COMMAND_LINE_TARGETS:
|
||||
|
|
|
@ -361,7 +361,7 @@ void feature_style_processor<Processor>::prepare_layer(layer_rendering_material
|
|||
boost::optional<feature_type_style const&> style=m_.find_style(style_name);
|
||||
if (!style)
|
||||
{
|
||||
MAPNIK_LOG_DEBUG(feature_style_processor)
|
||||
MAPNIK_LOG_ERROR(feature_style_processor)
|
||||
<< "feature_style_processor: Style=" << style_name
|
||||
<< " required for layer=" << lay.name() << " does not exist.";
|
||||
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
#ifndef DUMP_XML_HPP
|
||||
#define DUMP_XML_HPP
|
||||
#include <mapnik/xml_node.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
// Debug dump ptree XML representation.
|
||||
|
||||
void dump_xml(xml_node const& xml, unsigned level=0)
|
||||
{
|
||||
std::string indent;
|
||||
unsigned i;
|
||||
for (i=0; i<level; i++)
|
||||
{
|
||||
indent += " ";
|
||||
}
|
||||
xml_node::attribute_map const& attr_map = xml.get_attributes();
|
||||
std::cerr << indent <<"[" << xml.name();
|
||||
for (auto const& attr : attr_map)
|
||||
{
|
||||
std::cerr << " (" << attr.first << ", " << attr.second.value << ", " << attr.second.processed << ")";
|
||||
}
|
||||
std::cerr << "]" << "\n";
|
||||
if (xml.is_text()) std::cerr << indent << "text: '" << xml.text() << "'\n";
|
||||
for (auto const& child : xml)
|
||||
{
|
||||
dump_xml(child, level+1);
|
||||
}
|
||||
std::cerr << indent << "[/" << xml.name() << "]" << "\n";
|
||||
}
|
||||
|
||||
}
|
||||
#endif // DUMP_XML_HPP
|
|
@ -24,12 +24,11 @@
|
|||
#define MAPNIK_MARKER_HELPERS_HPP
|
||||
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/color.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/geometry_type.hpp>
|
||||
#include <mapnik/geometry_centroid.hpp>
|
||||
#include <mapnik/symbolizer.hpp>
|
||||
#include <mapnik/svg/svg_converter.hpp>
|
||||
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||
#include <mapnik/marker.hpp> // for svg_storage_type
|
||||
#include <mapnik/markers_placement.hpp>
|
||||
#include <mapnik/attribute.hpp>
|
||||
|
@ -47,8 +46,6 @@ namespace mapnik {
|
|||
|
||||
struct clip_poly_tag;
|
||||
|
||||
namespace svg { struct path_attributes; }
|
||||
|
||||
using svg_attribute_type = agg::pod_bvector<svg::path_attributes>;
|
||||
|
||||
template <typename Detector>
|
||||
|
|
|
@ -47,8 +47,6 @@
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
class proj_transform;
|
||||
struct glyph_info;
|
||||
class text_symbolizer_helper;
|
||||
|
||||
using svg::svg_path_adapter;
|
||||
|
@ -95,7 +93,7 @@ struct virtual_renderer_common : private util::noncopyable
|
|||
// This should allow us to re-use as much as possible of the
|
||||
// existing symbolizer layout and rendering code while still
|
||||
// being able to interpose our own decisions about whether
|
||||
// a collision has occured or not.
|
||||
// a collision has occurred or not.
|
||||
|
||||
// Thunk for rendering a particular instance of a point - this
|
||||
// stores all the arguments necessary to re-render this point
|
||||
|
@ -117,13 +115,7 @@ struct vector_marker_render_thunk : util::noncopyable
|
|||
composite_mode_e comp_op,
|
||||
bool snap_to_pixels);
|
||||
|
||||
vector_marker_render_thunk(vector_marker_render_thunk && rhs)
|
||||
: src_(std::move(rhs.src_)),
|
||||
attrs_(std::move(rhs.attrs_)),
|
||||
tr_(std::move(rhs.tr_)),
|
||||
opacity_(std::move(rhs.opacity_)),
|
||||
comp_op_(std::move(rhs.comp_op_)),
|
||||
snap_to_pixels_(std::move(rhs.snap_to_pixels_)) {}
|
||||
vector_marker_render_thunk(vector_marker_render_thunk && rhs);
|
||||
};
|
||||
|
||||
struct raster_marker_render_thunk : util::noncopyable
|
||||
|
@ -140,12 +132,7 @@ struct raster_marker_render_thunk : util::noncopyable
|
|||
composite_mode_e comp_op,
|
||||
bool snap_to_pixels);
|
||||
|
||||
raster_marker_render_thunk(raster_marker_render_thunk && rhs)
|
||||
: src_(rhs.src_),
|
||||
tr_(std::move(rhs.tr_)),
|
||||
opacity_(std::move(rhs.opacity_)),
|
||||
comp_op_(std::move(rhs.comp_op_)),
|
||||
snap_to_pixels_(std::move(rhs.snap_to_pixels_)) {}
|
||||
raster_marker_render_thunk(raster_marker_render_thunk && rhs);
|
||||
};
|
||||
|
||||
using helper_ptr = std::unique_ptr<text_symbolizer_helper>;
|
||||
|
@ -164,12 +151,7 @@ struct text_render_thunk : util::noncopyable
|
|||
double opacity, composite_mode_e comp_op,
|
||||
halo_rasterizer_enum halo_rasterizer);
|
||||
|
||||
text_render_thunk(text_render_thunk && rhs)
|
||||
: helper_(std::move(rhs.helper_)),
|
||||
placements_(std::move(rhs.placements_)),
|
||||
opacity_(std::move(rhs.opacity_)),
|
||||
comp_op_(std::move(rhs.comp_op_)),
|
||||
halo_rasterizer_(std::move(rhs.halo_rasterizer_)) {}
|
||||
text_render_thunk(text_render_thunk && rhs);
|
||||
|
||||
};
|
||||
|
||||
|
@ -395,7 +377,7 @@ void render_group_symbolizer(group_symbolizer const& sym,
|
|||
rpt_key_expr = get<expression_ptr>(sym, keys::repeat_key);
|
||||
}
|
||||
|
||||
// evalute the repeat key with the matched sub feature if we have one
|
||||
// evaluate the repeat key with the matched sub feature if we have one
|
||||
if (rpt_key_expr)
|
||||
{
|
||||
rpt_key_value = util::apply_visitor(evaluate<Feature,value_type,attributes>(*match_feature,common.vars_),
|
||||
|
|
|
@ -69,17 +69,25 @@ void render_point_symbolizer(point_symbolizer const &sym,
|
|||
|
||||
mapnik::geometry::geometry<double> const& geometry = feature.get_geometry();
|
||||
mapnik::geometry::point<double> pt;
|
||||
if (placement == CENTROID_POINT_PLACEMENT)
|
||||
geometry::geometry_types type = geometry::geometry_type(geometry);
|
||||
if (placement == CENTROID_POINT_PLACEMENT ||
|
||||
type == geometry::geometry_types::Point ||
|
||||
type == geometry::geometry_types::MultiPoint)
|
||||
{
|
||||
if (!geometry::centroid(geometry, pt)) return;
|
||||
}
|
||||
else if (mapnik::geometry::geometry_type(geometry) == mapnik::geometry::geometry_types::Polygon)
|
||||
else if (type == mapnik::geometry::geometry_types::Polygon)
|
||||
{
|
||||
auto const& poly = mapnik::util::get<geometry::polygon<double> >(geometry);
|
||||
geometry::polygon_vertex_adapter<double> va(poly);
|
||||
if (!label::interior_position(va ,pt.x, pt.y))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
MAPNIK_LOG_WARN(point_symbolizer) << "TODO: unhandled geometry type for point symbolizer";
|
||||
return;
|
||||
}
|
||||
double x = pt.x;
|
||||
double y = pt.y;
|
||||
double z = 0;
|
||||
|
|
|
@ -23,14 +23,17 @@
|
|||
#ifndef MAPNIK_LIBXML2_LOADER_HPP
|
||||
#define MAPNIK_LIBXML2_LOADER_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/config.hpp> // for MAPNIK_DECL
|
||||
|
||||
// stl
|
||||
#include <string>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
class xml_node;
|
||||
void read_xml(std::string const & filename, xml_node &node);
|
||||
void read_xml_string(std::string const & str, xml_node &node, std::string const & base_path="");
|
||||
class MAPNIK_DECL xml_node;
|
||||
MAPNIK_DECL void read_xml(std::string const & filename, xml_node &node);
|
||||
MAPNIK_DECL void read_xml_string(std::string const & str, xml_node &node, std::string const & base_path="");
|
||||
}
|
||||
|
||||
#endif // MAPNIK_LIBXML2_LOADER_HPP
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
#ifndef MAPNIK_XML_NODE_H
|
||||
#define MAPNIK_XML_NODE_H
|
||||
|
||||
//mapnik
|
||||
#include <mapnik/config.hpp> // for MAPNIK_DECL
|
||||
|
||||
//boost
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
|
@ -34,9 +37,9 @@
|
|||
|
||||
namespace mapnik
|
||||
{
|
||||
class xml_tree;
|
||||
class MAPNIK_DECL xml_tree;
|
||||
|
||||
class xml_attribute
|
||||
class MAPNIK_DECL xml_attribute
|
||||
{
|
||||
public:
|
||||
xml_attribute(const char * value_);
|
||||
|
@ -44,7 +47,7 @@ public:
|
|||
mutable bool processed;
|
||||
};
|
||||
|
||||
class node_not_found: public std::exception
|
||||
class MAPNIK_DECL node_not_found: public std::exception
|
||||
{
|
||||
public:
|
||||
node_not_found(std::string const& node_name);
|
||||
|
@ -56,7 +59,7 @@ protected:
|
|||
mutable std::string msg_;
|
||||
};
|
||||
|
||||
class attribute_not_found: public std::exception
|
||||
class MAPNIK_DECL attribute_not_found: public std::exception
|
||||
{
|
||||
public:
|
||||
attribute_not_found(std::string const& node_name, std::string const& attribute_name);
|
||||
|
@ -69,7 +72,7 @@ protected:
|
|||
mutable std::string msg_;
|
||||
};
|
||||
|
||||
class more_than_one_child: public std::exception
|
||||
class MAPNIK_DECL more_than_one_child: public std::exception
|
||||
{
|
||||
public:
|
||||
more_than_one_child(std::string const& node_name);
|
||||
|
@ -81,7 +84,7 @@ protected:
|
|||
mutable std::string msg_;
|
||||
};
|
||||
|
||||
class xml_node
|
||||
class MAPNIK_DECL xml_node
|
||||
{
|
||||
public:
|
||||
using const_iterator = std::list<xml_node>::const_iterator;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
namespace mapnik
|
||||
{
|
||||
|
||||
class xml_tree
|
||||
class MAPNIK_DECL xml_tree
|
||||
{
|
||||
public:
|
||||
xml_tree(std::string const& encoding="utf8");
|
||||
|
|
|
@ -36,9 +36,7 @@
|
|||
#include <mapnik/util/conversions.hpp>
|
||||
#include <mapnik/util/trim.hpp>
|
||||
#include <mapnik/box2d.hpp> // for box2d
|
||||
|
||||
// boost
|
||||
#include <boost/bind.hpp>
|
||||
#include <functional>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
@ -229,27 +227,27 @@ mapnik::raster_ptr pgraster_wkb_reader::read_indexed(mapnik::box2d<double> const
|
|||
// mapnik does not support signed anyway
|
||||
case PT_8BUI:
|
||||
return read_data_band(bbox, width_, height_, hasnodata,
|
||||
boost::bind(read_uint8, &ptr_));
|
||||
std::bind(read_uint8, &ptr_));
|
||||
break;
|
||||
case PT_16BSI:
|
||||
// mapnik does not support signed anyway
|
||||
case PT_16BUI:
|
||||
return read_data_band(bbox, width_, height_, hasnodata,
|
||||
boost::bind(read_uint16, &ptr_, endian_));
|
||||
std::bind(read_uint16, &ptr_, endian_));
|
||||
break;
|
||||
case PT_32BSI:
|
||||
// mapnik does not support signed anyway
|
||||
case PT_32BUI:
|
||||
return read_data_band(bbox, width_, height_, hasnodata,
|
||||
boost::bind(read_uint32, &ptr_, endian_));
|
||||
std::bind(read_uint32, &ptr_, endian_));
|
||||
break;
|
||||
case PT_32BF:
|
||||
return read_data_band(bbox, width_, height_, hasnodata,
|
||||
boost::bind(read_float32, &ptr_, endian_));
|
||||
std::bind(read_float32, &ptr_, endian_));
|
||||
break;
|
||||
case PT_64BF:
|
||||
return read_data_band(bbox, width_, height_, hasnodata,
|
||||
boost::bind(read_float64, &ptr_, endian_));
|
||||
std::bind(read_float64, &ptr_, endian_));
|
||||
break;
|
||||
default:
|
||||
std::ostringstream err;
|
||||
|
@ -320,19 +318,19 @@ mapnik::raster_ptr pgraster_wkb_reader::read_grayscale(mapnik::box2d<double> con
|
|||
// mapnik does not support signed anyway
|
||||
case PT_8BUI:
|
||||
return read_grayscale_band(bbox, width_, height_, hasnodata,
|
||||
boost::bind(read_uint8, &ptr_));
|
||||
std::bind(read_uint8, &ptr_));
|
||||
break;
|
||||
case PT_16BSI:
|
||||
// mapnik does not support signed anyway
|
||||
case PT_16BUI:
|
||||
return read_grayscale_band(bbox, width_, height_, hasnodata,
|
||||
boost::bind(read_uint16, &ptr_, endian_));
|
||||
std::bind(read_uint16, &ptr_, endian_));
|
||||
break;
|
||||
case PT_32BSI:
|
||||
// mapnik does not support signed anyway
|
||||
case PT_32BUI:
|
||||
return read_grayscale_band(bbox, width_, height_, hasnodata,
|
||||
boost::bind(read_uint32, &ptr_, endian_));
|
||||
std::bind(read_uint32, &ptr_, endian_));
|
||||
break;
|
||||
default:
|
||||
std::ostringstream err;
|
||||
|
|
|
@ -340,12 +340,6 @@ source += Split(
|
|||
"""
|
||||
)
|
||||
|
||||
# clipper
|
||||
source += Split(
|
||||
"""
|
||||
../deps/clipper/src/clipper.cpp
|
||||
""")
|
||||
|
||||
if env['RUNTIME_LINK'] == "static":
|
||||
source += glob.glob('../deps/agg/src/' + '*.cpp')
|
||||
|
||||
|
|
|
@ -129,6 +129,7 @@ private:
|
|||
void find_unused_nodes_recursive(xml_node const& node, std::string & error_text);
|
||||
std::string ensure_relative_to_xml(boost::optional<std::string> const& opt_path);
|
||||
void ensure_exists(std::string const& file_path);
|
||||
void check_styles(Map const & map) const throw (config_error);
|
||||
boost::optional<color> get_opt_color_attr(boost::property_tree::ptree const& node,
|
||||
std::string const& name);
|
||||
|
||||
|
@ -143,7 +144,7 @@ private:
|
|||
std::string xml_base_path_;
|
||||
};
|
||||
|
||||
//#include <mapnik/internal/dump_xml.hpp>
|
||||
|
||||
void load_map(Map & map, std::string const& filename, bool strict, std::string base_path)
|
||||
{
|
||||
// TODO - use xml encoding?
|
||||
|
@ -152,7 +153,6 @@ void load_map(Map & map, std::string const& filename, bool strict, std::string b
|
|||
read_xml(filename, tree.root());
|
||||
map_parser parser(map, strict, filename);
|
||||
parser.parse_map(map, tree.root(), base_path);
|
||||
//dump_xml(tree.root());
|
||||
}
|
||||
|
||||
void load_map_string(Map & map, std::string const& str, bool strict, std::string base_path)
|
||||
|
@ -328,6 +328,10 @@ void map_parser::parse_map(Map & map, xml_node const& node, std::string const& b
|
|||
throw config_error("Not a map file. Node 'Map' not found.");
|
||||
}
|
||||
find_unused_nodes(node);
|
||||
if (strict_)
|
||||
{
|
||||
check_styles(map);
|
||||
}
|
||||
}
|
||||
|
||||
void map_parser::parse_map_include(Map & map, xml_node const& node)
|
||||
|
@ -1685,4 +1689,19 @@ void map_parser::find_unused_nodes_recursive(xml_node const& node, std::string &
|
|||
}
|
||||
}
|
||||
|
||||
void map_parser::check_styles(Map const & map) const throw (config_error)
|
||||
{
|
||||
for (auto const & layer : map.layers())
|
||||
{
|
||||
for (auto const & style : layer.styles())
|
||||
{
|
||||
if (!map.find_style(style))
|
||||
{
|
||||
throw config_error("Unable to process some data while parsing '" + filename_ +
|
||||
"': Style '" + style + "' required for layer '" + layer.name() + "'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // end of namespace mapnik
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/marker_helpers.hpp>
|
||||
#include <mapnik/svg/svg_converter.hpp>
|
||||
|
||||
#include "agg_ellipse.h"
|
||||
#include "agg_color_rgba.h"
|
||||
|
|
|
@ -138,7 +138,11 @@ private:
|
|||
{
|
||||
if (cur_node->value_size() > 0) // Don't add empty text nodes
|
||||
{
|
||||
node.add_child(cur_node->value(), 0, true);
|
||||
// parsed text values should have leading and trailing
|
||||
// whitespace trimmed.
|
||||
std::string trimmed = cur_node->value();
|
||||
mapnik::util::trim(trimmed);
|
||||
node.add_child(trimmed.c_str(), 0, true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -37,6 +37,15 @@ vector_marker_render_thunk::vector_marker_render_thunk(svg_path_ptr const& src,
|
|||
comp_op_(comp_op), snap_to_pixels_(snap_to_pixels)
|
||||
{}
|
||||
|
||||
vector_marker_render_thunk::vector_marker_render_thunk(vector_marker_render_thunk && rhs)
|
||||
: src_(std::move(rhs.src_)),
|
||||
attrs_(std::move(rhs.attrs_)),
|
||||
tr_(std::move(rhs.tr_)),
|
||||
opacity_(std::move(rhs.opacity_)),
|
||||
comp_op_(std::move(rhs.comp_op_)),
|
||||
snap_to_pixels_(std::move(rhs.snap_to_pixels_)) {}
|
||||
|
||||
|
||||
raster_marker_render_thunk::raster_marker_render_thunk(image_rgba8 const& src,
|
||||
agg::trans_affine const& marker_trans,
|
||||
double opacity,
|
||||
|
@ -46,6 +55,14 @@ raster_marker_render_thunk::raster_marker_render_thunk(image_rgba8 const& src,
|
|||
snap_to_pixels_(snap_to_pixels)
|
||||
{}
|
||||
|
||||
raster_marker_render_thunk::raster_marker_render_thunk(raster_marker_render_thunk && rhs)
|
||||
: src_(rhs.src_),
|
||||
tr_(std::move(rhs.tr_)),
|
||||
opacity_(std::move(rhs.opacity_)),
|
||||
comp_op_(std::move(rhs.comp_op_)),
|
||||
snap_to_pixels_(std::move(rhs.snap_to_pixels_)) {}
|
||||
|
||||
|
||||
text_render_thunk::text_render_thunk(helper_ptr && helper,
|
||||
double opacity, composite_mode_e comp_op,
|
||||
halo_rasterizer_enum halo_rasterizer)
|
||||
|
@ -56,6 +73,13 @@ text_render_thunk::text_render_thunk(helper_ptr && helper,
|
|||
halo_rasterizer_(halo_rasterizer)
|
||||
{}
|
||||
|
||||
text_render_thunk::text_render_thunk(text_render_thunk && rhs)
|
||||
: helper_(std::move(rhs.helper_)),
|
||||
placements_(std::move(rhs.placements_)),
|
||||
opacity_(std::move(rhs.opacity_)),
|
||||
comp_op_(std::move(rhs.comp_op_)),
|
||||
halo_rasterizer_(std::move(rhs.halo_rasterizer_)) {}
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename Detector, typename RendererContext>
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 419f955634dec99fe1417b6e7092d608803e0f90
|
||||
Subproject commit 977c6fc1efd8bf44e9d15862a067f1406e39e29d
|
|
@ -1 +1 @@
|
|||
Subproject commit 698026c007507590ebc4d04fedc8dbe4242fc990
|
||||
Subproject commit 5489590d3aeaba749aec8b38cbfa9cf6318209a6
|
|
@ -1,5 +1,8 @@
|
|||
|
||||
#if defined(HAVE_TIFF)
|
||||
// disabled on windows due to https://github.com/mapnik/mapnik/issues/2838
|
||||
// TODO - get to the bottom of why including `tiff_reader.cpp` breaks windows
|
||||
// or re-write image_readers to allow `#include tiff_reader.hpp`
|
||||
#if !defined(_MSC_VER) && defined(HAVE_TIFF)
|
||||
|
||||
#include "catch.hpp"
|
||||
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
#include "catch.hpp"
|
||||
|
||||
#include <libxml/parser.h> // for xmlInitParser(), xmlCleanupParser()
|
||||
|
||||
#if defined(HAVE_CAIRO)
|
||||
#include <cairo.h>
|
||||
#endif
|
||||
#include <unicode/uclean.h>
|
||||
|
||||
#ifdef MAPNIK_USE_PROJ4
|
||||
|
@ -17,8 +20,10 @@ int main (int argc, char* const argv[])
|
|||
// http://xmlsoft.org/xmlmem.html
|
||||
xmlCleanupParser();
|
||||
|
||||
#if defined(HAVE_CAIRO)
|
||||
// http://cairographics.org/manual/cairo-Error-handling.html#cairo-debug-reset-static-data
|
||||
cairo_debug_reset_static_data();
|
||||
#endif
|
||||
|
||||
// http://icu-project.org/apiref/icu4c/uclean_8h.html#a93f27d0ddc7c196a1da864763f2d8920
|
||||
u_cleanup();
|
||||
|
|
45
test/unit/serialization/xml_parser_trim.cpp
Normal file
45
test/unit/serialization/xml_parser_trim.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include "catch.hpp"
|
||||
|
||||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/xml_tree.hpp>
|
||||
#include <mapnik/xml_loader.hpp>
|
||||
#include <mapnik/attribute.hpp>
|
||||
|
||||
TEST_CASE("xml parser") {
|
||||
|
||||
SECTION("trims whitespace") {
|
||||
|
||||
// simple and non-valid mapnik XML reduced from the empty_parameter2.xml
|
||||
// test case. this is to check that the xml parsing routine is trimming
|
||||
// whitespace from text nodes as part of the parsing operation.
|
||||
const std::string xml("<Map>"
|
||||
" <Layer>"
|
||||
" <Datasource>"
|
||||
" <Parameter name=\"empty\"><![CDATA[ ]]></Parameter>"
|
||||
" </Datasource>"
|
||||
" </Layer>"
|
||||
"</Map>");
|
||||
|
||||
mapnik::xml_tree tree("utf8");
|
||||
tree.set_filename("xml_datasource_parameter_trim.cpp");
|
||||
REQUIRE_NOTHROW(read_xml_string(xml, tree.root(), ""));
|
||||
|
||||
REQUIRE(tree.root().has_child("Map"));
|
||||
mapnik::xml_node const &map = tree.root().get_child("Map");
|
||||
|
||||
REQUIRE(map.has_child("Layer"));
|
||||
mapnik::xml_node const &layer = map.get_child("Layer");
|
||||
|
||||
REQUIRE(layer.has_child("Datasource"));
|
||||
mapnik::xml_node const &datasource = layer.get_child("Datasource");
|
||||
|
||||
REQUIRE(datasource.has_child("Parameter"));
|
||||
mapnik::xml_node const ¶meter = datasource.get_child("Parameter");
|
||||
|
||||
// parser should call mapnik::util::trim on the text content and
|
||||
// this should result in an empty text string in the parameter.
|
||||
REQUIRE(parameter.get_text() == "");
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,9 @@
|
|||
// mapnik
|
||||
#include <mapnik/map.hpp>
|
||||
#include <mapnik/agg_renderer.hpp>
|
||||
#if defined(GRID_RENDERER)
|
||||
#include <mapnik/grid/grid_renderer.hpp>
|
||||
#endif
|
||||
#if defined(HAVE_CAIRO)
|
||||
#include <mapnik/cairo/cairo_renderer.hpp>
|
||||
#include <mapnik/cairo/cairo_image_util.hpp>
|
||||
|
@ -140,6 +142,7 @@ struct svg_renderer : renderer_base<std::string>
|
|||
};
|
||||
#endif
|
||||
|
||||
#if defined(GRID_RENDERER)
|
||||
struct grid_renderer : renderer_base<mapnik::image_rgba8>
|
||||
{
|
||||
static constexpr const char * name = "grid";
|
||||
|
@ -186,6 +189,7 @@ struct grid_renderer : renderer_base<mapnik::image_rgba8>
|
|||
return image;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
template <typename Renderer>
|
||||
class renderer
|
||||
|
|
|
@ -30,7 +30,9 @@
|
|||
#include <boost/program_options.hpp>
|
||||
|
||||
#include <libxml/parser.h> // for xmlInitParser(), xmlCleanupParser()
|
||||
#if defined(HAVE_CAIRO)
|
||||
#include <cairo.h>
|
||||
#endif
|
||||
#include <unicode/uclean.h>
|
||||
|
||||
#ifdef MAPNIK_USE_PROJ4
|
||||
|
@ -116,8 +118,10 @@ int main(int argc, char** argv)
|
|||
// http://xmlsoft.org/xmlmem.html
|
||||
xmlCleanupParser();
|
||||
|
||||
#if defined(HAVE_CAIRO)
|
||||
// http://cairographics.org/manual/cairo-Error-handling.html#cairo-debug-reset-static-data
|
||||
cairo_debug_reset_static_data();
|
||||
#endif
|
||||
|
||||
// http://icu-project.org/apiref/icu4c/uclean_8h.html#a93f27d0ddc7c196a1da864763f2d8920
|
||||
u_cleanup();
|
||||
|
|
|
@ -67,7 +67,9 @@ runner::runner(runner::path_type const & styles_dir,
|
|||
#if defined(SVG_RENDERER)
|
||||
,renderer<svg_renderer>(output_dir_, reference_dir_, overwrite)
|
||||
#endif
|
||||
#if defined(GRID_RENDERER)
|
||||
,renderer<grid_renderer>(output_dir_, reference_dir_, overwrite)
|
||||
#endif
|
||||
}
|
||||
{
|
||||
}
|
||||
|
|
|
@ -42,7 +42,10 @@ class runner
|
|||
#if defined(SVG_RENDERER)
|
||||
,renderer<svg_renderer>
|
||||
#endif
|
||||
,renderer<grid_renderer>>;
|
||||
#if defined(GRID_RENDERER)
|
||||
,renderer<grid_renderer>
|
||||
#endif
|
||||
>;
|
||||
using path_type = boost::filesystem::path;
|
||||
using files_iterator = std::vector<path_type>::const_iterator;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue