Version: 0.6.0
format.h
1 /******************************************************************************
2  * Project: wxGIS
3  * Purpose: format clases (for format coordinates etc.).
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2011 Dmitry Baryshnikov
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  ****************************************************************************/
21 #pragma once
22 
23 #include "wxgis/core/core.h"
24 #include "wxgis/core/json/jsonval.h"
25 
26 #include <wx/xml/xml.h>
27 
31 WXDLLIMPEXP_GIS_CORE wxString DoubleToString(double dVal, bool bIsLon);
35 WXDLLIMPEXP_GIS_CORE double StringToDouble(const wxString &sVal, const wxString &sAsterisk);
36 
37 WXDLLIMPEXP_GIS_CORE void SetFloatValue(wxXmlNode* pNode, const wxString &sAttrName, double dfVal);
38 WXDLLIMPEXP_GIS_CORE void SetFloatValue(wxXmlNode* pNode, const wxString &sAttrName, float dfVal);
39 WXDLLIMPEXP_GIS_CORE double GetFloatValue(const wxXmlNode* pNode, const wxString &sAttrName, double dfDefVal);
40 WXDLLIMPEXP_GIS_CORE float GetFloatValue(const wxXmlNode* pNode, const wxString &sAttrName, float dfDefVal);
41 WXDLLIMPEXP_GIS_CORE void SetDateValue(wxXmlNode* pNode, const wxString &sAttrName, const wxDateTime &dtVal);
42 WXDLLIMPEXP_GIS_CORE wxJSONValue SetDateValue(const wxDateTime &dtVal);
43 WXDLLIMPEXP_GIS_CORE wxDateTime GetDateValue(const wxXmlNode* pNode, const wxString &sAttrName, const wxDateTime &dtDefVal);
44 WXDLLIMPEXP_GIS_CORE wxDateTime GetDateValue(const wxJSONValue &val, const wxString &sAttrName, const wxDateTime &dtDefVal);
45 WXDLLIMPEXP_GIS_CORE void SetBoolValue(wxXmlNode* pNode, const wxString &sAttrName, bool bVal);
46 WXDLLIMPEXP_GIS_CORE bool GetBoolValue(const wxXmlNode* pNode, const wxString &sAttrName, bool bDefVal);
47 WXDLLIMPEXP_GIS_CORE void SetDecimalValue(wxXmlNode* pNode, const wxString &sAttrName, long nVal);
48 WXDLLIMPEXP_GIS_CORE void SetDecimalValue(wxXmlNode* pNode, const wxString &sAttrName, int nVal);
49 WXDLLIMPEXP_GIS_CORE long GetDecimalValue(const wxXmlNode* pNode, const wxString &sAttrName, long nDefVal);
50 WXDLLIMPEXP_GIS_CORE int GetDecimalValue(const wxXmlNode* pNode, const wxString &sAttrName, int nDefVal);
51 
52 WXDLLIMPEXP_GIS_CORE void FloatStringToCLoc(wxString & str);
53 WXDLLIMPEXP_GIS_CORE void FloatStringFromCLoc(wxString & str);
54 
55 WXDLLIMPEXP_GIS_CORE int GetDecimalValue(const wxXmlNode* pNode, const wxString &sAttrName, int nDefVal);
56 
57 WXDLLIMPEXP_GIS_CORE wxString GetSubString(const wxString &sInputString, const wxString &sBegin, const wxString &sEnd, bool bAppendBegin = false);
58 WXDLLIMPEXP_GIS_CORE wxString DecodeHTMLEntities(const wxString &sSrc);
59 
60 
64 WXDLLIMPEXP_GIS_CORE wxString NumberScale(double dScaleRatio);
65 
69 class WXDLLIMPEXP_GIS_CORE wxGISCoordinatesFormat
70 {
71 public:
73  wxGISCoordinatesFormat(const wxString &sMask, bool bSwap = false);
74  virtual ~wxGISCoordinatesFormat(void);
75  virtual wxString Format(double dX, double dY);
76  virtual bool IsOk(void){return m_bIsOk;};
77  virtual void Create(const wxString &sMask, bool bSwap = false);
78  virtual wxString GetMask() const {return m_sMask;};
79 public:
80  typedef enum coord_format {
81  D,
82  DM,
83  DMS,
84  M,
85  MS,
86  S
87  } COORD_FORMAT;
88 protected:
89  wxString FormatToken(int nValHigh, int nValLow);
90  wxString FormatString(double dCoord, const wxString &sFormat, COORD_FORMAT nCoordFormat, bool bLat);
91  wxString ParseString(const wxString &sMask, COORD_FORMAT* pCoordFormat);
92 protected:
93  bool m_bIsOk;
94  bool m_bSwaped;
95  wxString m_sMask;
96  wxString m_sFormatX, m_sFormatY, m_sDivider;
97  COORD_FORMAT m_CoordFormatX, m_CoordFormatY;
98  bool m_bSign;
99 };
100 
The JSON value class implementation.
Definition: jsonval.h:91
The class to format coordinates according different masks.
Definition: format.h:69