[mapguide-commits] r8815 - in sandbox/jng/simplify: Common/Geometry Desktop/DesktopUnmanagedApi/DotNet Desktop/DesktopUnmanagedApi/JavaApiEx Desktop/MgDesktop Desktop/UnitTest Server/src/UnitTesting UnitTest/Acceptance Web/src/DotNetUnmanagedApi/Geometry Web/src/MapGuideApi
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Sat Nov 7 07:35:03 PST 2015
Author: jng
Date: 2015-11-07 07:35:03 -0800 (Sat, 07 Nov 2015)
New Revision: 8815
Added:
sandbox/jng/simplify/Common/Geometry/GeometrySimplificationAlgorithmType.h
sandbox/jng/simplify/Common/Geometry/GeometrySimplifier.cpp
sandbox/jng/simplify/Common/Geometry/GeometrySimplifier.h
Modified:
sandbox/jng/simplify/Common/Geometry/Geometry.vcxproj
sandbox/jng/simplify/Common/Geometry/Geometry.vcxproj.filters
sandbox/jng/simplify/Common/Geometry/GeometryBuild.cpp
sandbox/jng/simplify/Common/Geometry/GeometryClassId.h
sandbox/jng/simplify/Common/Geometry/GeometryCommon.h
sandbox/jng/simplify/Common/Geometry/Makefile.am
sandbox/jng/simplify/Desktop/DesktopUnmanagedApi/DotNet/DesktopApi.vcxproj
sandbox/jng/simplify/Desktop/DesktopUnmanagedApi/DotNet/DesktopDotNetApi.vcxproj
sandbox/jng/simplify/Desktop/DesktopUnmanagedApi/JavaApiEx/JavaApiEx.vcxproj
sandbox/jng/simplify/Desktop/MgDesktop/MgDesktop.vcxproj
sandbox/jng/simplify/Desktop/UnitTest/UnitTest.vcxproj
sandbox/jng/simplify/Server/src/UnitTesting/TestGeometry.cpp
sandbox/jng/simplify/Server/src/UnitTesting/TestGeometry.h
sandbox/jng/simplify/UnitTest/Acceptance/nightwatch.json
sandbox/jng/simplify/Web/src/DotNetUnmanagedApi/Geometry/GeometryApi.vcxproj
sandbox/jng/simplify/Web/src/DotNetUnmanagedApi/Geometry/GeometryApiGen.xml
sandbox/jng/simplify/Web/src/DotNetUnmanagedApi/Geometry/GeometryConstants.xml
sandbox/jng/simplify/Web/src/MapGuideApi/Constants.xml
sandbox/jng/simplify/Web/src/MapGuideApi/MapGuideApiGen.xml
Log:
Add a new MgGeometrySimplifier class. This wraps the underlying GEOS geometry simplification APIs and provides geometry simplification services to the MapGuide API.
Modified: sandbox/jng/simplify/Common/Geometry/Geometry.vcxproj
===================================================================
--- sandbox/jng/simplify/Common/Geometry/Geometry.vcxproj 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Common/Geometry/Geometry.vcxproj 2015-11-07 15:35:03 UTC (rev 8815)
@@ -450,6 +450,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
+ <ClCompile Include="GeometrySimplifier.cpp">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+ </ClCompile>
<ClCompile Include="Parse\ArrayHelper.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -892,6 +898,8 @@
<ClInclude Include="Exception\InvalidCoordinateSystemException.h" />
<ClInclude Include="Exception\InvalidCoordinateSystemTypeException.h" />
<ClInclude Include="Exception\InvalidCoordinateSystemUnitsException.h" />
+ <ClInclude Include="GeometrySimplifier.h" />
+ <ClInclude Include="GeometrySimplificationAlgorithmType.h" />
<ClInclude Include="Parse\Array.h" />
<ClInclude Include="Parse\ArrayHelper.h" />
<ClInclude Include="Parse\LexAwkt.h" />
Modified: sandbox/jng/simplify/Common/Geometry/Geometry.vcxproj.filters
===================================================================
--- sandbox/jng/simplify/Common/Geometry/Geometry.vcxproj.filters 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Common/Geometry/Geometry.vcxproj.filters 2015-11-07 15:35:03 UTC (rev 8815)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Buffer">
@@ -372,6 +372,7 @@
<ClCompile Include="Region.cpp" />
<ClCompile Include="Ring.cpp" />
<ClCompile Include="WktReaderWriter.cpp" />
+ <ClCompile Include="GeometrySimplifier.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Buffer\BorderWalker.h">
@@ -970,8 +971,10 @@
<ClInclude Include="Ring.h" />
<ClInclude Include="Transform.h" />
<ClInclude Include="WktReaderWriter.h" />
+ <ClInclude Include="GeometrySimplifier.h" />
+ <ClInclude Include="GeometrySimplificationAlgorithmType.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Geometry.rc" />
</ItemGroup>
-</Project>
+</Project>
\ No newline at end of file
Modified: sandbox/jng/simplify/Common/Geometry/GeometryBuild.cpp
===================================================================
--- sandbox/jng/simplify/Common/Geometry/GeometryBuild.cpp 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Common/Geometry/GeometryBuild.cpp 2015-11-07 15:35:03 UTC (rev 8815)
@@ -39,6 +39,7 @@
#include "Geometry.cpp"
#include "GeometryCollection.cpp"
#include "GeometryFactory.cpp"
+#include "GeometrySimplifier.cpp"
#include "GeometryUtil.cpp"
#include "LinearRing.cpp"
#include "LinearRingCollection.cpp"
Modified: sandbox/jng/simplify/Common/Geometry/GeometryClassId.h
===================================================================
--- sandbox/jng/simplify/Common/Geometry/GeometryClassId.h 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Common/Geometry/GeometryClassId.h 2015-11-07 15:35:03 UTC (rev 8815)
@@ -76,6 +76,9 @@
#define Geometry_CurveRingCollection GEOMETRY_ID+52
#define Geometry_LinearRingCollection GEOMETRY_ID+53
+// Simplifier
+#define Geometry_GeometrySimplifier GEOMETRY_ID+54
+
// CoordinateSystem API
#define CoordinateSystem_CoordinateSystem GEOMETRY_COORDINATE_SYSTEM_ID+0
#define CoordinateSystem_CoordinateSystemFactory GEOMETRY_COORDINATE_SYSTEM_ID+1
Modified: sandbox/jng/simplify/Common/Geometry/GeometryCommon.h
===================================================================
--- sandbox/jng/simplify/Common/Geometry/GeometryCommon.h 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Common/Geometry/GeometryCommon.h 2015-11-07 15:35:03 UTC (rev 8815)
@@ -105,6 +105,8 @@
#include "GeometryFactory.h"
#include "GeometryUtil.h"
+#include "GeometrySimplifier.h"
+#include "GeometrySimplificationAlgorithmType.h"
#include "CoordinateSystem/CoordinateSystem.h"
#include "CoordinateSystem/CoordinateSystemDatum.h"
Added: sandbox/jng/simplify/Common/Geometry/GeometrySimplificationAlgorithmType.h
===================================================================
--- sandbox/jng/simplify/Common/Geometry/GeometrySimplificationAlgorithmType.h (rev 0)
+++ sandbox/jng/simplify/Common/Geometry/GeometrySimplificationAlgorithmType.h 2015-11-07 15:35:03 UTC (rev 8815)
@@ -0,0 +1,45 @@
+//
+// Copyright (C) 2004-2011 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
+//
+
+#ifndef _MGGEOMETRYSIMPLIFICATIONALGORITHMTYPE_H_
+#define _MGGEOMETRYSIMPLIFICATIONALGORITHMTYPE_H_
+
+/// \cond INTERNAL
+////////////////////////////////////////////////////////////
+/// \brief
+/// MgGeometrySimplificationAlgorithmType defines constants indicating
+/// the various simplification algorithms available for simplifying
+/// geometry instances
+///
+class MgGeometrySimplificationAlgorithmType
+{
+PUBLISHED_API:
+ /////////////////////////////////////////////////////////////////
+ /// \brief
+ /// Specifies that the Douglas-Peucker algorithm be used for simplification.
+ ///
+ static const INT32 DouglasPeucker = 0;
+
+ ///////////////////////////////////////////////////////
+ /// \brief
+ /// Specifies that the Topology Preserving algorithm be used for simplification
+ ///
+ static const INT32 TopologyPreserving = 1;
+};
+/// \endcond
+
+#endif //_MGGEOMETRYSIMPLIFICATIONALGORITHMTYPE_H_
\ No newline at end of file
Added: sandbox/jng/simplify/Common/Geometry/GeometrySimplifier.cpp
===================================================================
--- sandbox/jng/simplify/Common/Geometry/GeometrySimplifier.cpp (rev 0)
+++ sandbox/jng/simplify/Common/Geometry/GeometrySimplifier.cpp 2015-11-07 15:35:03 UTC (rev 8815)
@@ -0,0 +1,92 @@
+//
+// Copyright (C) 2004-2015 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
+//
+
+#include "geos.h"
+#include "geos/simplify/DouglasPeuckerSimplifier.h"
+#include "geos/simplify/TopologyPreservingSimplifier.h"
+
+#include "GeometryCommon.h"
+#include "GeosUtil.h"
+#include "GeometryExceptionDef.h"
+
+///////////////////////////////////////////////////////////////////////////
+// Creates an MgGeometrySimplifier object
+//
+MgGeometrySimplifier::MgGeometrySimplifier()
+{
+}
+
+MgGeometry* MgGeometrySimplifier::Simplify(MgGeometry* geom, double tolerance, INT32 algorithm)
+{
+ Ptr<MgGeometry> simplified;
+ Geometry* gInput = NULL;
+ std::auto_ptr<Geometry> gOutput;
+ MG_GEOMETRY_TRY()
+
+ CHECKARGUMENTNULL(geom, L"MgGeometrySimplifier.Simplify");
+ if (algorithm != MgGeometrySimplificationAlgorithmType::DouglasPeucker &&
+ algorithm != MgGeometrySimplificationAlgorithmType::TopologyPreserving)
+ {
+ throw new MgInvalidArgumentException(L"MgGeometrySimplifier.Simplify", __LINE__, __WFILE__, NULL, L"MgInvalidGeometrySimplficationAlgorithm", NULL);
+ }
+
+ STRING inputWKt = geom->ToAwkt(true);
+ PrecisionModel pm;
+ GeometryFactory gf(&pm, 10);
+ WKTReader r(&gf);
+ WKTWriter w;
+
+ gInput = r.read(MgUtil::WideCharToMultiByte(inputWKt));
+
+ switch (algorithm)
+ {
+ case MgGeometrySimplificationAlgorithmType::DouglasPeucker:
+ gOutput = geos::simplify::DouglasPeuckerSimplifier::simplify(gInput, tolerance);
+ break;
+ case MgGeometrySimplificationAlgorithmType::TopologyPreserving:
+ gOutput = geos::simplify::TopologyPreservingSimplifier::simplify(gInput, tolerance);
+ break;
+ }
+
+ Geometry* gSimp = gOutput.get();
+ std::string mbSimpWkt = w.write(gSimp);
+
+ if (mbSimpWkt.find("EMPTY", 0) == string::npos)
+ {
+ MgWktReaderWriter rdrWrt;
+ simplified = rdrWrt.Read(MgUtil::MultiByteToWideChar(mbSimpWkt));
+ }
+
+ MG_GEOMETRY_CATCH_AND_THROW(L"MgGeometrySimplifier.Simplify")
+ return simplified.Detach();
+}
+
+//////////////////////////////////////////////
+// Dispose this object.
+//
+void MgGeometrySimplifier::Dispose()
+{
+ delete this;
+}
+
+//////////////////////////////////////////////////////////////////
+// Get the unique identifier for the class
+//
+INT32 MgGeometrySimplifier::GetClassId()
+{
+ return m_cls_id;
+}
\ No newline at end of file
Added: sandbox/jng/simplify/Common/Geometry/GeometrySimplifier.h
===================================================================
--- sandbox/jng/simplify/Common/Geometry/GeometrySimplifier.h (rev 0)
+++ sandbox/jng/simplify/Common/Geometry/GeometrySimplifier.h 2015-11-07 15:35:03 UTC (rev 8815)
@@ -0,0 +1,138 @@
+//
+// Copyright (C) 2004-2015 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
+//
+
+#ifndef _MGGEOMETRYSIMPLIFIER_H_
+#define _MGGEOMETRYSIMPLIFIER_H_
+
+/// \defgroup MgAgfReaderWriter MgAgfReaderWriter
+/// \ingroup Geometry_Module_classes
+/// \{
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// The MgGeometrySimplifier class provides the ability to simplify MgGeometry instances.
+///
+/// <!-- Example (PHP) -->
+/// \htmlinclude PHPExampleTop.html
+/// \code
+/// $wktRw = new MgWktReaderWriter();
+/// $geom = $wktRw->Read("LINESTRING (0 5, 1 5, 2 5, 5 5)");
+/// $simp = new MgGeometrySimplifier();
+/// $simplified = $simp->Simplify($geom, 10.0, MgGeometrySimplificationAlgorithmType::DouglasPeucker);
+/// \endcode
+/// \htmlinclude ExampleBottom.html
+///
+/// <!-- Example (C#) -->
+/// \htmlinclude CSharpExampleTop.html
+/// \code
+/// using OSGeo.MapGuide;
+/// ...
+/// MgWktReaderWriter wktRw = new MgWktReaderWriter();
+/// MgGeometry geom = wktRw.Read("LINESTRING (0 5, 1 5, 2 5, 5 5)");
+/// MgGeometrySimplifier simp = new MgGeometrySimplifier();
+/// MgGeometry simplified = simp.Simplify(geom, 10.0, MgGeometrySimplificationAlgorithmType.DouglasPeucker);
+/// \endcode
+/// \htmlinclude ExampleBottom.html
+///
+/// <!-- Example (Java) -->
+/// \htmlinclude JavaExampleTop.html
+/// \code
+/// import org.osgeo.mapguide;
+/// ...
+/// MgWktReaderWriter wktRw = new MgWktReaderWriter();
+/// MgGeometry geom = wktRw.Read("LINESTRING (0 5, 1 5, 2 5, 5 5)");
+/// MgGeometrySimplifier simp = new MgGeometrySimplifier();
+/// MgGeometry simplified = simp.Simplify(geom, 10.0, MgGeometrySimplificationAlgorithmType.DouglasPeucker);
+/// \endcode
+/// \htmlinclude ExampleBottom.html
+///
+class MG_GEOMETRY_API MgGeometrySimplifier : public MgGuardDisposable
+{
+ DECLARE_CLASSNAME(MgGeometrySimplifier)
+
+PUBLISHED_API:
+ ///////////////////////////////////////////////////////////////////////////
+ /// \brief
+ /// Creates an MgGeometrySimplifier object
+ ///
+ /// <!-- Syntax in .Net, Java, and PHP -->
+ /// \htmlinclude DotNetSyntaxTop.html
+ /// MgGeometrySimplifier();
+ /// \htmlinclude SyntaxBottom.html
+ /// \htmlinclude JavaSyntaxTop.html
+ /// MgGeometrySimplifier();
+ /// \htmlinclude SyntaxBottom.html
+ /// \htmlinclude PHPSyntaxTop.html
+ /// MgGeometrySimplifier();
+ /// \htmlinclude SyntaxBottom.html
+ ///
+ MgGeometrySimplifier();
+
+ ///////////////////////////////////////////////////////////////////////////
+ /// \brief
+ /// Simplifies the given geometry using the specified algorithm and tolerance
+ ///
+ /// <!-- Syntax in .Net, Java, and PHP -->
+ /// \htmlinclude DotNetSyntaxTop.html
+ /// virtual MgGeometry Simplify(MgGeometry geom, double tolerance, int algorithm);
+ /// \htmlinclude SyntaxBottom.html
+ /// \htmlinclude JavaSyntaxTop.html
+ /// virtual MgGeometry Simplify(MgGeometry geom, double tolerance, int algorithm);
+ /// \htmlinclude SyntaxBottom.html
+ /// \htmlinclude PHPSyntaxTop.html
+ /// virtual MgGeometry Simplify(MgGeometry geom, double tolerance, int algorithm);
+ /// \htmlinclude SyntaxBottom.html
+ ///
+ /// \param geom (MgGeometry)
+ /// The geometry instance to be simplified
+ ///
+ /// \param tolerance (double)
+ /// The tolerance factor to simplify by
+ ///
+ /// \param algorithm (int)
+ /// The simplification algorithm to use. Use any value from MgGeometrySimplificationAlgorithmType
+ ///
+ /// \return
+ /// A simplified MgGeometry instance or null if simpification results in an empty geometry
+ ///
+ MgGeometry* Simplify(MgGeometry* geom, double tolerance, INT32 algorithm);
+
+INTERNAL_API:
+
+ //////////////////////////////////////////////////////////////////
+ /// \brief
+ /// Get the unique identifier for the class
+ ///
+ /// \return
+ /// Class Identifider.
+ ///
+ virtual INT32 GetClassId();
+
+protected:
+
+ //////////////////////////////////////////////
+ /// \brief
+ /// Dispose this object.
+ ///
+ virtual void Dispose();
+
+CLASS_ID:
+ static const INT32 m_cls_id = Geometry_GeometrySimplifier;
+};
+/// \}
+
+#endif //_MGGEOMETRYSIMPLIFIER_H_
Modified: sandbox/jng/simplify/Common/Geometry/Makefile.am
===================================================================
--- sandbox/jng/simplify/Common/Geometry/Makefile.am 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Common/Geometry/Makefile.am 2015-11-07 15:35:03 UTC (rev 8815)
@@ -83,6 +83,7 @@
GeometryCollection.cpp \
GeometryFactory.cpp \
GeometryUtil.cpp \
+ GeometrySimplifier.cpp \
GeosUtil.cpp \
LinearRing.cpp \
LinearRingCollection.cpp \
@@ -244,6 +245,8 @@
GeometryExceptionDef.h \
GeometryFactory.h \
GeometryType.h \
+ GeometrySimplifier.h \
+ GeometrySimplificationAlgorithmType.h \
GeometryUtil.h \
GeosUtil.h \
LinearRing.h \
Modified: sandbox/jng/simplify/Desktop/DesktopUnmanagedApi/DotNet/DesktopApi.vcxproj
===================================================================
--- sandbox/jng/simplify/Desktop/DesktopUnmanagedApi/DotNet/DesktopApi.vcxproj 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Desktop/DesktopUnmanagedApi/DotNet/DesktopApi.vcxproj 2015-11-07 15:35:03 UTC (rev 8815)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@@ -28,23 +28,23 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Modified: sandbox/jng/simplify/Desktop/DesktopUnmanagedApi/DotNet/DesktopDotNetApi.vcxproj
===================================================================
--- sandbox/jng/simplify/Desktop/DesktopUnmanagedApi/DotNet/DesktopDotNetApi.vcxproj 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Desktop/DesktopUnmanagedApi/DotNet/DesktopDotNetApi.vcxproj 2015-11-07 15:35:03 UTC (rev 8815)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@@ -31,28 +31,28 @@
<UseDebugLibraries>true</UseDebugLibraries>
<OutDir>..\..\bin\debug</OutDir>
<IntDir>..\..\obj\debug</IntDir>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<OutDir>..\..\bin\debug64</OutDir>
<IntDir>..\..\obj\debug64</IntDir>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<OutDir>..\..\bin\release</OutDir>
<IntDir>..\..\obj\release</IntDir>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<OutDir>..\..\bin\release64</OutDir>
<IntDir>..\..\obj\release64</IntDir>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Modified: sandbox/jng/simplify/Desktop/DesktopUnmanagedApi/JavaApiEx/JavaApiEx.vcxproj
===================================================================
--- sandbox/jng/simplify/Desktop/DesktopUnmanagedApi/JavaApiEx/JavaApiEx.vcxproj 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Desktop/DesktopUnmanagedApi/JavaApiEx/JavaApiEx.vcxproj 2015-11-07 15:35:03 UTC (rev 8815)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@@ -27,22 +27,22 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Modified: sandbox/jng/simplify/Desktop/MgDesktop/MgDesktop.vcxproj
===================================================================
--- sandbox/jng/simplify/Desktop/MgDesktop/MgDesktop.vcxproj 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Desktop/MgDesktop/MgDesktop.vcxproj 2015-11-07 15:35:03 UTC (rev 8815)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@@ -27,25 +27,25 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Modified: sandbox/jng/simplify/Desktop/UnitTest/UnitTest.vcxproj
===================================================================
--- sandbox/jng/simplify/Desktop/UnitTest/UnitTest.vcxproj 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Desktop/UnitTest/UnitTest.vcxproj 2015-11-07 15:35:03 UTC (rev 8815)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@@ -27,23 +27,23 @@
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Modified: sandbox/jng/simplify/Server/src/UnitTesting/TestGeometry.cpp
===================================================================
--- sandbox/jng/simplify/Server/src/UnitTesting/TestGeometry.cpp 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Server/src/UnitTesting/TestGeometry.cpp 2015-11-07 15:35:03 UTC (rev 8815)
@@ -2370,7 +2370,6 @@
}
}
-
void TestGeometry::TestCase_CoordinateIterator()
{
try
@@ -2424,3 +2423,294 @@
throw;
}
}
+
+void TestGeometry::TestCase_Simplify_BadParams()
+{
+ try
+ {
+ Ptr<MgGeometrySimplifier> simp = new MgGeometrySimplifier();
+ Ptr<MgWktReaderWriter> wktRw = new MgWktReaderWriter();
+ Ptr<MgGeometry> geom = wktRw->Read(L"POINT (1 1)");
+
+ CPPUNIT_ASSERT_THROW_MG(simp->Simplify(NULL, 1.0, MgGeometrySimplificationAlgorithmType::DouglasPeucker), MgNullArgumentException*);
+ CPPUNIT_ASSERT_THROW_MG(simp->Simplify(geom, 1.0, -1), MgInvalidArgumentException*);
+ CPPUNIT_ASSERT_THROW_MG(simp->Simplify(geom, 1.0, 2), MgInvalidArgumentException*);
+ }
+ catch (MgException* e)
+ {
+ STRING message = e->GetDetails(TEST_LOCALE);
+ SAFE_RELEASE(e);
+ CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ }
+ catch (...)
+ {
+ throw;
+ }
+}
+
+void TestGeometry::TestCase_Simplify_DP()
+{
+ try
+ {
+ Ptr<MgGeometrySimplifier> simp = new MgGeometrySimplifier();
+ INT32 algo = MgGeometrySimplificationAlgorithmType::DouglasPeucker;
+ Ptr<MgWktReaderWriter> wktRw = new MgWktReaderWriter();
+
+ //1 - PolygonNoReduction
+ STRING wkt;
+ wkt = L"POLYGON((20 220, 40 220, 60 220, 80 220, 100 220, \
+ 120 220, 140 220, 140 180, 100 180, 60 180, 20 180, 20 220))";
+ Ptr<MgGeometry> gTest = wktRw->Read(wkt);
+
+ Ptr<MgGeometry> gInput = wktRw->Read(wkt);
+ Ptr<MgGeometry> gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // 2 - PolygonReductionWithSplit
+ gTest = wktRw->Read(L"MULTIPOLYGON (((40.0 240.0, 160.0 240.0, 40.0 140.0, 40.0 240.0)), \
+ ((160.0 240.0, 280.0 240.0, 280.0 160.0, 160.0 240.0)))");
+ gInput = wktRw->Read(L"POLYGON ((40 240, 160 241, 280 240, 280 160, \
+ 160 240, 40 140, 40 240))");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // 3 - PolygonReduction
+ gTest = wktRw->Read(L"POLYGON ((120 120, 140 199, 160 200, 180 199, 220 120, 120 120))");
+ gInput = wktRw->Read(L"POLYGON ((120 120, 121 121, 122 122, 220 120, \
+ 180 199, 160 200, 140 199, 120 120))");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // 4 - PolygonWithTouchingHole
+ gTest = wktRw->Read(L"POLYGON ((80 200, 160 200, 240 200, 240 60, 80 60, 80 200), \
+ (160 200, 140 199, 120 120, 220 120, 180 199, 160 200)))");
+ gInput = wktRw->Read(L"POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200), \
+ (120 120, 220 120, 180 199, 160 200, 140 199, 120 120))");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // 5 - FlattishPolygon
+ gInput = wktRw->Read(L"POLYGON ((0 0, 50 0, 53 0, 55 0, 100 0, 70 1, 60 1, 50 1, 40 1, 0 0))");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ //Unlike GEOS, we don't support "POLYGON EMPTY", so we should be expecting NULL instead
+ CPPUNIT_ASSERT(NULL == gOutput.p);
+
+ // 6 - TinySquare
+ gInput = wktRw->Read(L"POLYGON ((0 5, 5 5, 5 0, 0 0, 0 1, 0 5))");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ //Unlike GEOS, we don't support "POLYGON EMPTY", so we should be expecting NULL instead
+ CPPUNIT_ASSERT(NULL == gOutput.p);
+
+ // 7 - TinyLineString
+ gTest = wktRw->Read(L"LINESTRING (0 5, 5 5)");
+ gInput = wktRw->Read(L"LINESTRING (0 5, 1 5, 2 5, 5 5)");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // 8 - MultiPoint
+ gTest = wktRw->Read(L"MULTIPOINT(80 200, 240 200, 240 60, 80 60, 80 200, 140 199, 120 120)");
+ gInput = wktRw->Read(L"MULTIPOINT(80 200, 240 200, 240 60, 80 60, 80 200, 140 199, 120 120)");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // 9 - MultiLineString
+ gTest = wktRw->Read(L"MULTILINESTRING( (0 0, 100 0), (0 0, 100 0) )");
+ gInput = wktRw->Read(L"MULTILINESTRING( (0 0, 50 0, 70 0, 80 0, 100 0), \
+ (0 0, 50 1, 60 1, 100 0) )");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // 10 - GeometryCollection
+ gTest = wktRw->Read(L"MULTILINESTRING( (0 0, 100 0), (0 0, 100 0) )");
+ gInput = wktRw->Read(L"GEOMETRYCOLLECTION ( \
+ MULTIPOINT (80 200, 240 200, 240 60, 80 60, 80 200, 140 199, 120 120), \
+ POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200)), \
+ LINESTRING (80 200, 240 200, 240 60, 80 60, 80 200, 140 199, 120 120) )");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ //STRING sTest = gTest->ToAwkt(true);
+ //STRING sOutput = gOutput->ToAwkt(true);
+ //CPPUNIT_ASSERT(gTest->Equals(gOutput));
+ }
+ catch (MgException* e)
+ {
+ STRING message = e->GetDetails(TEST_LOCALE);
+ SAFE_RELEASE(e);
+ CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ }
+ catch (...)
+ {
+ throw;
+ }
+}
+
+void TestGeometry::TestCase_Simplify_TP()
+{
+ try
+ {
+ Ptr<MgGeometrySimplifier> simp = new MgGeometrySimplifier();
+ INT32 algo = MgGeometrySimplificationAlgorithmType::TopologyPreserving;
+ Ptr<MgWktReaderWriter> wktRw = new MgWktReaderWriter();
+
+ //Point
+ Ptr<MgGeometry> gTest = wktRw->Read(L"POINT (10 10)");
+ Ptr<MgGeometry> gInput = wktRw->Read(L"POINT (10 10)");
+ Ptr<MgGeometry> gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // PolygonWithSpike
+ gTest = wktRw->Read(L"POLYGON (( \
+ 3312459.605 6646878.353, \
+ 3312460.524 6646875.969, \
+ 3312459.427 6646878.421, \
+ 3312460.014 6646886.391, \
+ 3312465.889 6646887.398, \
+ 3312470.827 6646884.839, \
+ 3312477.289 6646871.694, \
+ 3312472.748 6646869.547, \
+ 3312459.605 6646878.353))");
+ gInput = wktRw->Read(L"POLYGON ((3312459.605 6646878.353, \
+ 3312460.524 6646875.969, 3312459.427 6646878.421, \
+ 3312460.014 6646886.391, 3312465.889 6646887.398, \
+ 3312470.827 6646884.839, 3312475.4 6646878.027, \
+ 3312477.289 6646871.694, 3312472.748 6646869.547, \
+ 3312468.253 6646874.01, 3312463.52 6646875.779, \
+ 3312459.605 6646878.353))");
+ gOutput = simp->Simplify(gInput, 2.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+
+ // PolygonNoReduction
+ gTest = wktRw->Read(L"POLYGON((20 220, 40 220, 60 220, 80 220, \
+ 100 220, 120 220, 140 220, 140 180, 100 180, \
+ 60 180, 20 180, 20 220))");
+ gInput = wktRw->Read(L"POLYGON((20 220, 40 220, 60 220, 80 220, \
+ 100 220, 120 220, 140 220, 140 180, 100 180, \
+ 60 180, 20 180, 20 220))");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // PolygonNoReductionWithConflicts
+ gTest = wktRw->Read(L"POLYGON ((40 240, 160 241, 280 240, 280 160, \
+ 160 240, 40 140, 40 240))");
+ gInput = wktRw->Read(L"POLYGON ((40 240, 160 241, 280 240, 280 160, \
+ 160 240, 40 140, 40 240))");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // PolygonWithTouchingHole
+ gTest = wktRw->Read(L"POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200), \
+ (120 120, 220 120, 180 199, 160 200, 140 199, 120 120))");
+ gInput = wktRw->Read(L"POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200), \
+ (120 120, 220 120, 180 199, 160 200, 140 199, 120 120))");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // FlattishPolygon
+ gTest = wktRw->Read(L"POLYGON ((0 0, 50 0, 53 0, 55 0, 100 0, \
+ 70 1, 60 1, 50 1, 40 1, 0 0))");
+ gInput = wktRw->Read(L"POLYGON ((0 0, 50 0, 53 0, 55 0, 100 0, \
+ 70 1, 60 1, 50 1, 40 1, 0 0))");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ //STRING sTest = gTest->ToAwkt(true);
+ //STRING sOutput = gOutput->ToAwkt(true);
+ //CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // PolygonWithFlattishHole
+ gTest = wktRw->Read(L"POLYGON ((0 0, 0 200, 200 200, 200 0, 0 0), \
+ (140 40, 90 95, 40 160, 95 100, 140 40))");
+ gInput = wktRw->Read(L"POLYGON ((0 0, 0 200, 200 200, 200 0, 0 0), \
+ (140 40, 90 95, 40 160, 95 100, 140 40))");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // Tiny square
+ gTest = wktRw->Read(L"POLYGON ((0 5, 5 5, 5 0, 0 0, 0 1, 0 5))");
+ gInput = wktRw->Read(L"POLYGON ((0 5, 5 5, 5 0, 0 0, 0 1, 0 5))");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // TinyClosedLineString
+ gTest = wktRw->Read(L"LINESTRING (0 0, 5 0, 5 5, 0 0)");
+ gInput = wktRw->Read(L"LINESTRING (0 0, 5 0, 5 5, 0 0)");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // MultiPoint
+ gTest = wktRw->Read(L"MULTIPOINT(80 200, 240 200, 240 60, \
+ 80 60, 80 200, 140 199, 120 120)");
+ gInput = wktRw->Read(L"MULTIPOINT(80 200, 240 200, 240 60, \
+ 80 60, 80 200, 140 199, 120 120)");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // MultiLineString
+ gTest = wktRw->Read(L"MULTILINESTRING((0 0, 50 0, 70 0, 80 0, 100 0), \
+ (0 0, 50 1, 60 1, 100 0))");
+ gInput = wktRw->Read(L"MULTILINESTRING((0 0, 50 0, 70 0, 80 0, 100 0), \
+ (0 0, 50 1, 60 1, 100 0))");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ //STRING sTest = gTest->ToAwkt(true);
+ //STRING sOutput = gOutput->ToAwkt(true);
+ //CPPUNIT_ASSERT(gTest->Equals(gOutput));
+
+ // GeometryCollection
+ gTest = wktRw->Read(L"GEOMETRYCOLLECTION ( \
+ MULTIPOINT (80 200, 240 200, 240 60, 80 60, 80 200, 140 199, 120 120), \
+ POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200)), \
+ LINESTRING (80 200, 240 200, 240 60, 80 60, 80 200, 140 199, 120 120))");
+ gInput = wktRw->Read(L"GEOMETRYCOLLECTION ( \
+ MULTIPOINT (80 200, 240 200, 240 60, 80 60, 80 200, 140 199, 120 120), \
+ POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200)), \
+ LINESTRING (80 200, 240 200, 240 60, 80 60, 80 200, 140 199, 120 120))");
+ gOutput = simp->Simplify(gInput, 10.0, algo);
+ CPPUNIT_ASSERT(NULL != gOutput.p);
+ CPPUNIT_ASSERT(gOutput->IsValid());
+ CPPUNIT_ASSERT(gTest->Equals(gOutput));
+ }
+ catch (MgException* e)
+ {
+ STRING message = e->GetDetails(TEST_LOCALE);
+ SAFE_RELEASE(e);
+ CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ }
+ catch (...)
+ {
+ throw;
+ }
+}
\ No newline at end of file
Modified: sandbox/jng/simplify/Server/src/UnitTesting/TestGeometry.h
===================================================================
--- sandbox/jng/simplify/Server/src/UnitTesting/TestGeometry.h 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Server/src/UnitTesting/TestGeometry.h 2015-11-07 15:35:03 UTC (rev 8815)
@@ -64,6 +64,10 @@
CPPUNIT_TEST(TestCase_GetInteriorPoint);
CPPUNIT_TEST(TestCase_CoordinateIterator);
+ CPPUNIT_TEST(TestCase_Simplify_BadParams);
+ CPPUNIT_TEST(TestCase_Simplify_DP);
+ CPPUNIT_TEST(TestCase_Simplify_TP);
+
CPPUNIT_TEST(TestEnd); // This must be the very last unit test
CPPUNIT_TEST_SUITE_END();
@@ -108,6 +112,10 @@
void TestCase_GetInteriorPoint();
void TestCase_CoordinateIterator();
+ void TestCase_Simplify_BadParams();
+ void TestCase_Simplify_DP();
+ void TestCase_Simplify_TP();
+
MgPoint* CreatePoint();
MgLineString* CreateLineString();
MgLinearRing* CreateLinearRing();
Modified: sandbox/jng/simplify/UnitTest/Acceptance/nightwatch.json
===================================================================
--- sandbox/jng/simplify/UnitTest/Acceptance/nightwatch.json 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/UnitTest/Acceptance/nightwatch.json 2015-11-07 15:35:03 UTC (rev 8815)
@@ -3,7 +3,7 @@
"tests"
],
"output_folder": "reports",
- "custom_commands_path": "",
+ "custom_commands_path": "./commands",
"custom_assertions_path": "",
"page_objects_path": "",
"globals_path": "",
Modified: sandbox/jng/simplify/Web/src/DotNetUnmanagedApi/Geometry/GeometryApi.vcxproj
===================================================================
--- sandbox/jng/simplify/Web/src/DotNetUnmanagedApi/Geometry/GeometryApi.vcxproj 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Web/src/DotNetUnmanagedApi/Geometry/GeometryApi.vcxproj 2015-11-07 15:35:03 UTC (rev 8815)
@@ -245,7 +245,9 @@
<None Include="..\catchall.code" />
<None Include="..\dotnet.i" />
<None Include="GeometryApiGen.xml" />
- <None Include="GeometryConstants.xml" />
+ <None Include="GeometryConstants.xml">
+ <SubType>Designer</SubType>
+ </None>
<None Include="..\getclassid.code" />
</ItemGroup>
<ItemGroup>
Modified: sandbox/jng/simplify/Web/src/DotNetUnmanagedApi/Geometry/GeometryApiGen.xml
===================================================================
--- sandbox/jng/simplify/Web/src/DotNetUnmanagedApi/Geometry/GeometryApiGen.xml 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Web/src/DotNetUnmanagedApi/Geometry/GeometryApiGen.xml 2015-11-07 15:35:03 UTC (rev 8815)
@@ -132,6 +132,8 @@
<Header path="../../../../Common/Geometry/PolygonCollection.h" />
<Header path="../../../../Common/Geometry/Transform.h" />
<Header path="../../../../Common/Geometry/WktReaderWriter.h" />
+
+ <Header path="../../../../Common/Geometry/GeometrySimplifier.h" />
<Header path="../../../../Common/Geometry/CoordinateSystem/CoordinateSystem.h" />
<Header path="../../../../Common/Geometry/CoordinateSystem/CoordinateSystemDictionaryBase.h" />
Modified: sandbox/jng/simplify/Web/src/DotNetUnmanagedApi/Geometry/GeometryConstants.xml
===================================================================
--- sandbox/jng/simplify/Web/src/DotNetUnmanagedApi/Geometry/GeometryConstants.xml 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Web/src/DotNetUnmanagedApi/Geometry/GeometryConstants.xml 2015-11-07 15:35:03 UTC (rev 8815)
@@ -70,6 +70,7 @@
<Class name="MgGeometricPathInstructionType" />
<Class name="MgGeometryType" />
<Class name="MgGeometryComponentType" />
+ <Class name="MgGeometrySimplificationAlgorithmType" />
<Class name="MgCoordinateSystemCodeFormat" />
<Class name="MgCoordinateSystemErrorCode" />
<Class name="MgCoordinateSystemGeodeticTransformationMethod" />
@@ -106,6 +107,7 @@
<Header path="../../../../Common/Geometry/GeometricPathInstructionType.h" />
<Header path="../../../../Common/Geometry/GeometryComponentType.h" />
<Header path="../../../../Common/Geometry/GeometryType.h" />
+ <Header path="../../../../Common/Geometry/GeometrySimplificationAlgorithmType.h" />
<Header path="../../../../Common/Geometry/CoordinateSystem/CoordinateSystemCodeFormat.h" />
<Header path="../../../../Common/Geometry/CoordinateSystem/CoordinateSystemErrorCode.h" />
<Header path="../../../../Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformationMethod.h" />
Modified: sandbox/jng/simplify/Web/src/MapGuideApi/Constants.xml
===================================================================
--- sandbox/jng/simplify/Web/src/MapGuideApi/Constants.xml 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Web/src/MapGuideApi/Constants.xml 2015-11-07 15:35:03 UTC (rev 8815)
@@ -85,6 +85,7 @@
<Class name="MgGeometricPathInstructionType" />
<Class name="MgGeometryType" />
<Class name="MgGeometryComponentType" />
+ <Class name="MgGeometrySimplificationAlgorithmType" />
<Class name="MgLayerGroupType" />
<Class name="MgLayerType" />
<Class name="MgFeatureGeometricType" />
@@ -162,6 +163,7 @@
<Header path="../../../Common/Geometry/GeometricPathInstructionType.h" />
<Header path="../../../Common/Geometry/GeometryComponentType.h" />
<Header path="../../../Common/Geometry/GeometryType.h" />
+ <Header path="../../../Common/Geometry/GeometrySimplificationAlgorithmType.h" />
<Header path="../../../Common/Geometry/CoordinateSystem/CoordinateSystemCodeFormat.h" />
<Header path="../../../Common/Geometry/CoordinateSystem/CoordinateSystemErrorCode.h" />
<Header path="../../../Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformationMethod.h" />
Modified: sandbox/jng/simplify/Web/src/MapGuideApi/MapGuideApiGen.xml
===================================================================
--- sandbox/jng/simplify/Web/src/MapGuideApi/MapGuideApiGen.xml 2015-11-06 11:50:55 UTC (rev 8814)
+++ sandbox/jng/simplify/Web/src/MapGuideApi/MapGuideApiGen.xml 2015-11-07 15:35:03 UTC (rev 8815)
@@ -215,6 +215,8 @@
<Header path="../../../Common/Geometry/PolygonCollection.h" />
<Header path="../../../Common/Geometry/Transform.h" />
<Header path="../../../Common/Geometry/WktReaderWriter.h" />
+
+ <Header path="../../../Common/Geometry/GeometrySimplifier.h" />
<Header path="../../../Common/Geometry/CoordinateSystem/CoordinateSystem.h" />
<Header path="../../../Common/Geometry/CoordinateSystem/CoordinateSystemDictionaryBase.h" />
More information about the mapguide-commits
mailing list