[mapguide-commits] r9606 - in sandbox/jng/mvt_alt/Common/Renderers: . mvt
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Sat Sep 21 11:04:23 PDT 2019
Author: jng
Date: 2019-09-21 11:04:23 -0700 (Sat, 21 Sep 2019)
New Revision: 9606
Added:
sandbox/jng/mvt_alt/Common/Renderers/mvt/mvt_port.h
Modified:
sandbox/jng/mvt_alt/Common/Renderers/Renderers.vcxproj
sandbox/jng/mvt_alt/Common/Renderers/Renderers.vcxproj.filters
sandbox/jng/mvt_alt/Common/Renderers/mvt/gpb.h
sandbox/jng/mvt_alt/Common/Renderers/mvt/mvt_tile.h
Log:
Add mvt_port.h which polyfills the minimum set of typedefs and other various definitions needed for mvt_tile.cpp to build. Have all existing includes of cpl_port.h include mvt_port.h instead
Modified: sandbox/jng/mvt_alt/Common/Renderers/Renderers.vcxproj
===================================================================
--- sandbox/jng/mvt_alt/Common/Renderers/Renderers.vcxproj 2019-09-21 17:25:40 UTC (rev 9605)
+++ sandbox/jng/mvt_alt/Common/Renderers/Renderers.vcxproj 2019-09-21 18:04:23 UTC (rev 9606)
@@ -215,6 +215,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="MapQuantization.cpp" />
+ <ClCompile Include="mvt\mvt_tile.cpp" />
<ClCompile Include="SymbolTrans.cpp" />
<ClCompile Include="DWFRenderer.cpp" />
<ClCompile Include="EPlotRenderer.cpp" />
@@ -259,6 +260,9 @@
<ClInclude Include="agg_utfgrid_context.h" />
<ClInclude Include="MapQuantization.h" />
<ClInclude Include="MapUTFGrid.h" />
+ <ClInclude Include="mvt\gpb.h" />
+ <ClInclude Include="mvt\mvt_port.h" />
+ <ClInclude Include="mvt\mvt_tile.h" />
<ClInclude Include="SymbolTrans.h" />
<ClInclude Include="DWFRenderer.h" />
<ClInclude Include="DWFRSInputStream.h" />
Modified: sandbox/jng/mvt_alt/Common/Renderers/Renderers.vcxproj.filters
===================================================================
--- sandbox/jng/mvt_alt/Common/Renderers/Renderers.vcxproj.filters 2019-09-21 17:25:40 UTC (rev 9605)
+++ sandbox/jng/mvt_alt/Common/Renderers/Renderers.vcxproj.filters 2019-09-21 18:04:23 UTC (rev 9606)
@@ -25,6 +25,9 @@
<Filter Include="UTFGridRenderer">
<UniqueIdentifier>{139cab4d-e977-4ad2-8526-73e40cb9dde1}</UniqueIdentifier>
</Filter>
+ <Filter Include="MVTRenderer">
+ <UniqueIdentifier>{86e80f69-f211-4769-b8fe-549ba11f2bee}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="SymbolTrans.cpp">
@@ -111,6 +114,9 @@
<ClCompile Include="UTFGridContent.cpp">
<Filter>UTFGridRenderer</Filter>
</ClCompile>
+ <ClCompile Include="mvt\mvt_tile.cpp">
+ <Filter>MVTRenderer</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="SymbolTrans.h">
@@ -202,6 +208,15 @@
<ClInclude Include="MapUTFGrid.h">
<Filter>UTFGridRenderer</Filter>
</ClInclude>
+ <ClInclude Include="mvt\gpb.h">
+ <Filter>MVTRenderer</Filter>
+ </ClInclude>
+ <ClInclude Include="mvt\mvt_tile.h">
+ <Filter>MVTRenderer</Filter>
+ </ClInclude>
+ <ClInclude Include="mvt\mvt_port.h">
+ <Filter>MVTRenderer</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Renderers.rc" />
Modified: sandbox/jng/mvt_alt/Common/Renderers/mvt/gpb.h
===================================================================
--- sandbox/jng/mvt_alt/Common/Renderers/mvt/gpb.h 2019-09-21 17:25:40 UTC (rev 9605)
+++ sandbox/jng/mvt_alt/Common/Renderers/mvt/gpb.h 2019-09-21 18:04:23 UTC (rev 9606)
@@ -30,9 +30,7 @@
#ifndef GPB_H_INCLUDED
#define GPB_H_INCLUDED
-#include "cpl_port.h"
-#include "cpl_error.h"
-#include "cpl_string.h"
+#include "mvt_port.h"
#include <string>
#include <exception>
@@ -45,8 +43,13 @@
{
std::string m_osMessage;
public:
- explicit GPBException(int nLine): m_osMessage(
- CPLSPrintf("Parsing error occurred at line %d", nLine)) {}
+ explicit GPBException(int nLine)
+ {
+ char buf[50];
+ int r = snprintf(buf, 50, "Parsing error occurred at line %d", nLine);
+ if (r >= 0 && r < 50)
+ m_osMessage = buf;
+ }
const char* what() const noexcept override
{ return m_osMessage.c_str(); }
Added: sandbox/jng/mvt_alt/Common/Renderers/mvt/mvt_port.h
===================================================================
--- sandbox/jng/mvt_alt/Common/Renderers/mvt/mvt_port.h (rev 0)
+++ sandbox/jng/mvt_alt/Common/Renderers/mvt/mvt_port.h 2019-09-21 18:04:23 UTC (rev 9606)
@@ -0,0 +1,298 @@
+//
+// Copyright (C) 2004-2019 by Autodesk, Inc.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of version 2.1 of the GNU Lesser
+// General Public License as published by the Free Software Foundation.
+//
+// This library 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+// Contains a minimal sub-set of cpl_port.h and other CPL headers
+/******************************************************************************
+ * Copyright (c) 1998, 2005, Frank Warmerdam <warmerdam at pobox.com>
+ * Copyright (c) 2008-2013, Even Rouault <even dot rouault at spatialys.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ ****************************************************************************/
+
+#ifndef MVT_PORT_H
+#define MVT_PORT_H
+
+#include <string.h>
+#include <limits.h>
+#include <assert.h>
+
+#if UINT_MAX == 65535
+typedef long GInt32;
+typedef unsigned long GUInt32;
+#else
+/** Int32 type */
+typedef int GInt32;
+/** Unsigned int32 type */
+typedef unsigned int GUInt32;
+#endif
+
+/** Large signed integer type (generally 64-bit integer type).
+ * Use GInt64 when exactly 64 bit is needed */
+typedef long long GIntBig;
+
+/** Large unsigned integer type (generally 64-bit unsigned integer type).
+ * Use GUInt64 when exactly 64 bit is needed */
+typedef unsigned long long GUIntBig;
+
+/** Signed 64 bit integer type */
+typedef GIntBig GInt64;
+/** Unsigned 64 bit integer type */
+typedef GUIntBig GUInt64;
+
+/** Unsigned byte type */
+typedef unsigned char GByte;
+
+#define VSI_MALLOC_VERBOSE malloc
+
+#define CPLMalloc malloc
+
+#define CPLFree free
+
+#define CPLAssert assert
+
+#define FALSE 0
+
+/* -------------------------------------------------------------------- */
+/* Handle isnan() and isinf(). Note that isinf() and isnan() */
+/* are supposed to be macros according to C99, defined in math.h */
+/* Some systems (i.e. Tru64) don't have isinf() at all, so if */
+/* the macro is not defined we just assume nothing is infinite. */
+/* This may mean we have no real CPLIsInf() on systems with isinf()*/
+/* function but no corresponding macro, but I can live with */
+/* that since it isn't that important a test. */
+/* -------------------------------------------------------------------- */
+#ifdef _MSC_VER
+# include <float.h>
+# define CPLIsNan(x) _isnan(x)
+# define CPLIsInf(x) (!_isnan(x) && !_finite(x))
+# define CPLIsFinite(x) _finite(x)
+#elif defined(__GNUC__) && ( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 4 ) )
+/* When including <cmath> in C++11 the isnan() macro is undefined, so that */
+/* std::isnan() can work (#6489). This is a GCC specific workaround for now. */
+# define CPLIsNan(x) __builtin_isnan(x)
+# define CPLIsInf(x) __builtin_isinf(x)
+# define CPLIsFinite(x) __builtin_isfinite(x)
+#elif defined(__cplusplus) && defined(HAVE_STD_IS_NAN) && HAVE_STD_IS_NAN
+extern "C++" {
+#ifndef DOXYGEN_SKIP
+#include <cmath>
+#endif
+ static inline int CPLIsNan(float f) { return std::isnan(f); }
+ static inline int CPLIsNan(double f) { return std::isnan(f); }
+ static inline int CPLIsInf(float f) { return std::isinf(f); }
+ static inline int CPLIsInf(double f) { return std::isinf(f); }
+ static inline int CPLIsFinite(float f) { return std::isfinite(f); }
+ static inline int CPLIsFinite(double f) { return std::isfinite(f); }
+}
+#else
+/** Return whether a floating-pointer number is NaN */
+#if defined(__cplusplus) && defined(__GNUC__) && defined(__linux) && !defined(__ANDROID__) && !defined(CPL_SUPRESS_CPLUSPLUS)
+/* so to not get warning about conversion from double to float with */
+/* gcc -Wfloat-conversion when using isnan()/isinf() macros */
+extern "C++" {
+ static inline int CPLIsNan(float f) { return __isnanf(f); }
+ static inline int CPLIsNan(double f) { return __isnan(f); }
+ static inline int CPLIsInf(float f) { return __isinff(f); }
+ static inline int CPLIsInf(double f) { return __isinf(f); }
+ static inline int CPLIsFinite(float f) { return !__isnanf(f) && !__isinff(f); }
+ static inline int CPLIsFinite(double f) { return !__isnan(f) && !__isinf(f); }
+}
+#else
+# define CPLIsNan(x) isnan(x)
+# if defined(isinf) || defined(__FreeBSD__)
+/** Return whether a floating-pointer number is +/- infinty */
+# define CPLIsInf(x) isinf(x)
+/** Return whether a floating-pointer number is finite */
+# define CPLIsFinite(x) (!isnan(x) && !isinf(x))
+# elif defined(__sun__)
+# include <ieeefp.h>
+# define CPLIsInf(x) (!finite(x) && !isnan(x))
+# define CPLIsFinite(x) finite(x)
+# else
+# define CPLIsInf(x) (0)
+# define CPLIsFinite(x) (!isnan(x))
+# endif
+#endif
+#endif
+
+#define CPL_STATIC_ASSERT_IF_AVAILABLE(x)
+
+/*---------------------------------------------------------------------
+ * Little endian <==> big endian byte swap macros.
+ *--------------------------------------------------------------------*/
+
+ /** Byte-swap a 16bit unsigned integer */
+#define CPL_SWAP16(x) CPL_STATIC_CAST(GUInt16, (CPL_STATIC_CAST(GUInt16, x) << 8) | (CPL_STATIC_CAST(GUInt16, x) >> 8) )
+
+#if defined(HAVE_GCC_BSWAP) && (defined(__i386__) || defined(__x86_64__))
+/* Could potentially be extended to other architectures but must be checked */
+/* that the intrinsic is indeed efficient */
+/* GCC (at least 4.6 or above) need that include */
+#include <x86intrin.h>
+/** Byte-swap a 32bit unsigned integer */
+#define CPL_SWAP32(x) CPL_STATIC_CAST(GUInt32, __builtin_bswap32(CPL_STATIC_CAST(GUInt32, x)))
+/** Byte-swap a 64bit unsigned integer */
+#define CPL_SWAP64(x) CPL_STATIC_CAST(GUInt64, __builtin_bswap64(CPL_STATIC_CAST(GUInt64, x)))
+#elif defined(_MSC_VER)
+#define CPL_SWAP32(x) CPL_STATIC_CAST(GUInt32, _byteswap_ulong(CPL_STATIC_CAST(GUInt32, x)))
+#define CPL_SWAP64(x) CPL_STATIC_CAST(GUInt64, _byteswap_uint64(CPL_STATIC_CAST(GUInt64, x)))
+#else
+/** Byte-swap a 32bit unsigned integer */
+#define CPL_SWAP32(x) \
+ CPL_STATIC_CAST(GUInt32, \
+ ((CPL_STATIC_CAST(GUInt32, x) & 0x000000ffU) << 24) | \
+ ((CPL_STATIC_CAST(GUInt32, x) & 0x0000ff00U) << 8) | \
+ ((CPL_STATIC_CAST(GUInt32, x) & 0x00ff0000U) >> 8) | \
+ ((CPL_STATIC_CAST(GUInt32, x) & 0xff000000U) >> 24) )
+
+/** Byte-swap a 64bit unsigned integer */
+#define CPL_SWAP64(x) \
+ ((CPL_STATIC_CAST(GUInt64, CPL_SWAP32(CPL_STATIC_CAST(GUInt32, x))) << 32) | \
+ (CPL_STATIC_CAST(GUInt64, CPL_SWAP32(CPL_STATIC_CAST(GUInt32, CPL_STATIC_CAST(GUInt64, x) >> 32)))))
+
+#endif
+
+/** Byte-swap a 16 bit pointer */
+#define CPL_SWAP16PTR(x) \
+{ \
+ GByte byTemp, *_pabyDataT = CPL_REINTERPRET_CAST(GByte*, x); \
+ CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2); \
+ \
+ byTemp = _pabyDataT[0]; \
+ _pabyDataT[0] = _pabyDataT[1]; \
+ _pabyDataT[1] = byTemp; \
+}
+
+#if defined(MAKE_SANITIZE_HAPPY) || !(defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64))
+
+/** Byte-swap a 32 bit pointer */
+#define CPL_SWAP32PTR(x) \
+{ \
+ GByte byTemp, *_pabyDataT = CPL_REINTERPRET_CAST(GByte*, x); \
+ CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4); \
+ \
+ byTemp = _pabyDataT[0]; \
+ _pabyDataT[0] = _pabyDataT[3]; \
+ _pabyDataT[3] = byTemp; \
+ byTemp = _pabyDataT[1]; \
+ _pabyDataT[1] = _pabyDataT[2]; \
+ _pabyDataT[2] = byTemp; \
+}
+
+/** Byte-swap a 64 bit pointer */
+#define CPL_SWAP64PTR(x) \
+{ \
+ GByte byTemp, *_pabyDataT = CPL_REINTERPRET_CAST(GByte*, x); \
+ CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8); \
+ \
+ byTemp = _pabyDataT[0]; \
+ _pabyDataT[0] = _pabyDataT[7]; \
+ _pabyDataT[7] = byTemp; \
+ byTemp = _pabyDataT[1]; \
+ _pabyDataT[1] = _pabyDataT[6]; \
+ _pabyDataT[6] = byTemp; \
+ byTemp = _pabyDataT[2]; \
+ _pabyDataT[2] = _pabyDataT[5]; \
+ _pabyDataT[5] = byTemp; \
+ byTemp = _pabyDataT[3]; \
+ _pabyDataT[3] = _pabyDataT[4]; \
+ _pabyDataT[4] = byTemp; \
+}
+
+#else
+
+/** Byte-swap a 32 bit pointer */
+#define CPL_SWAP32PTR(x) \
+{ \
+ GUInt32 _n32; \
+ void* _lx = x; \
+ memcpy(&_n32, _lx, 4); \
+ CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4); \
+ _n32 = CPL_SWAP32(_n32); \
+ memcpy(_lx, &_n32, 4); \
+}
+
+/** Byte-swap a 64 bit pointer */
+#define CPL_SWAP64PTR(x) \
+{ \
+ GUInt64 _n64; \
+ void* _lx = x; \
+ memcpy(&_n64, _lx, 8); \
+ CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8); \
+ _n64 = CPL_SWAP64(_n64); \
+ memcpy(_lx, &_n64, 8); \
+}
+
+#endif
+
+/** Byte-swap a 64 bit pointer */
+#define CPL_SWAPDOUBLE(p) CPL_SWAP64PTR(p)
+
+#ifdef CPL_MSB
+# define CPL_MSBWORD16(x) (x)
+# define CPL_LSBWORD16(x) CPL_SWAP16(x)
+# define CPL_MSBWORD32(x) (x)
+# define CPL_LSBWORD32(x) CPL_SWAP32(x)
+# define CPL_MSBPTR16(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2)
+# define CPL_LSBPTR16(x) CPL_SWAP16PTR(x)
+# define CPL_MSBPTR32(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4)
+# define CPL_LSBPTR32(x) CPL_SWAP32PTR(x)
+# define CPL_MSBPTR64(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8)
+# define CPL_LSBPTR64(x) CPL_SWAP64PTR(x)
+#else
+/** Return a 16bit word from a originally LSB ordered word */
+# define CPL_LSBWORD16(x) (x)
+/** Return a 16bit word from a originally MSB ordered word */
+# define CPL_MSBWORD16(x) CPL_SWAP16(x)
+/** Return a 32bit word from a originally LSB ordered word */
+# define CPL_LSBWORD32(x) (x)
+/** Return a 32bit word from a originally MSB ordered word */
+# define CPL_MSBWORD32(x) CPL_SWAP32(x)
+/** Byte-swap if necessary a 16bit word at the location pointed from a originally LSB ordered pointer */
+# define CPL_LSBPTR16(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2)
+/** Byte-swap if necessary a 16bit word at the location pointed from a originally MSB ordered pointer */
+# define CPL_MSBPTR16(x) CPL_SWAP16PTR(x)
+/** Byte-swap if necessary a 32bit word at the location pointed from a originally LSB ordered pointer */
+# define CPL_LSBPTR32(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4)
+/** Byte-swap if necessary a 32bit word at the location pointed from a originally MSB ordered pointer */
+# define CPL_MSBPTR32(x) CPL_SWAP32PTR(x)
+/** Byte-swap if necessary a 64bit word at the location pointed from a originally LSB ordered pointer */
+# define CPL_LSBPTR64(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8)
+/** Byte-swap if necessary a 64bit word at the location pointed from a originally MSB ordered pointer */
+# define CPL_MSBPTR64(x) CPL_SWAP64PTR(x)
+#endif
+
+#define CPLError(x)
+
+#define CPLDebug(x)
+
+#endif
\ No newline at end of file
Modified: sandbox/jng/mvt_alt/Common/Renderers/mvt/mvt_tile.h
===================================================================
--- sandbox/jng/mvt_alt/Common/Renderers/mvt/mvt_tile.h 2019-09-21 17:25:40 UTC (rev 9605)
+++ sandbox/jng/mvt_alt/Common/Renderers/mvt/mvt_tile.h 2019-09-21 18:04:23 UTC (rev 9606)
@@ -29,7 +29,7 @@
#ifndef MVT_TILE_H
#define MVT_TILE_H
-#include "cpl_port.h"
+#include "mvt_port.h"
#include <memory>
#include <vector>
More information about the mapguide-commits
mailing list