23 #include "wxgis/display/display.h"
25 #include <wx/xml/xml.h>
29 WXDLLIMPEXP_GIS_DSP
void SetColorValue(wxXmlNode* pNode,
const wxString &sAttrName,
const wxGISColor &oColor);
30 WXDLLIMPEXP_GIS_DSP
wxGISColor GetColorValue(
const wxXmlNode* pNode,
const wxString &sAttrName,
const wxGISColor &oDefaultColor);
32 WXDLLIMPEXP_GIS_DSP
void RotateEnvelope(OGREnvelope &Env,
double dAngle,
double dX,
double dY);
33 WXDLLIMPEXP_GIS_DSP
void ClipGeometryByEnvelope(OGRRawPoint* pOGRRawPoints,
int *pnPointCount,
const OGREnvelope &Env,
bool shapeOpen);
36 inline bool IsInsideEnvelope(
const OGRRawPoint &pt, wxGISEnumPointPosition nPos,
const OGREnvelope &Env)
40 case enumGISPtPosLeft:
41 return (pt.x > Env.MinX);
42 case enumGISPtPosRight:
43 return (pt.x < Env.MaxX);
44 case enumGISPtPosBottom:
45 return (pt.y > Env.MinY);
47 return (pt.y < Env.MaxY);
52 inline OGRRawPoint SolveIntersection(
const OGRRawPoint &pt1,
const OGRRawPoint &pt2, wxGISEnumPointPosition nPos,
const OGREnvelope &Env)
55 double r_n = EPSILON, r_d = EPSILON;
59 case enumGISPtPosRight:
60 r_n = -( pt1.x - Env.MaxX ) * ( Env.MaxY - Env.MinY );
61 r_d = ( pt2.x - pt1.x ) * ( Env.MaxY - Env.MinY );
63 case enumGISPtPosLeft:
64 r_n = -( pt1.x - Env.MinX ) * ( Env.MaxY - Env.MinY );
65 r_d = ( pt2.x - pt1.x ) * ( Env.MaxY - Env.MinY );
68 r_n = ( pt1.y - Env.MaxY ) * ( Env.MaxX - Env.MinX );
69 r_d = -( pt2.y - pt1.y ) * ( Env.MaxX - Env.MinX );
71 case enumGISPtPosBottom:
72 r_n = ( pt1.y - Env.MinY ) * ( Env.MaxX - Env.MinX );
73 r_d = -( pt2.y - pt1.y ) * ( Env.MaxX - Env.MinX );
77 if ( fabs( r_d ) > EPSILON && fabs( r_n ) > EPSILON )
80 out.x = pt1.x + r * ( pt2.x - pt1.x );
81 out.y = pt1.y + r * ( pt2.y - pt1.y );
87 wxASSERT( fabs( r_d ) > EPSILON && fabs( r_n ) > EPSILON );
93 inline void TrimFeatureToBoundary(OGRRawPoint* pOGRRawPointsIn,
int nPointCountIn, OGRRawPoint** pOGRRawPointsOut,
int *pnPointCountOut, wxGISEnumPointPosition nPos,
const OGREnvelope &Env,
bool shapeOpen )
99 unsigned int i1 = nPointCountIn - 1;
102 for (
int i2 = 0; i2 < nPointCountIn; ++i2 )
104 if ( IsInsideEnvelope( pOGRRawPointsIn[i2], nPos, Env ) )
106 if ( IsInsideEnvelope( pOGRRawPointsIn[i1], nPos, Env) )
107 (*pOGRRawPointsOut)[(*pnPointCountOut)++] = pOGRRawPointsIn[i2];
112 if ( !( i2 == 0 && shapeOpen ) )
113 (*pOGRRawPointsOut)[(*pnPointCountOut)++] = SolveIntersection( pOGRRawPointsIn[i1], pOGRRawPointsIn[i2], nPos, Env );
114 (*pOGRRawPointsOut)[(*pnPointCountOut)++] = pOGRRawPointsIn[i2];
120 if ( IsInsideEnvelope( pOGRRawPointsIn[i1], nPos, Env) )
122 if ( !( i2 == 0 && shapeOpen ) )
123 (*pOGRRawPointsOut)[(*pnPointCountOut)++] = SolveIntersection( pOGRRawPointsIn[i1], pOGRRawPointsIn[i2], nPos, Env );