[fdo-commits] r681 - in trunk/Fdo/Unmanaged: . Src/Geometry/Fgf
Src/Spatial
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Mon Jan 29 14:43:27 EST 2007
Author: gavincramer
Date: 2007-01-29 14:43:26 -0500 (Mon, 29 Jan 2007)
New Revision: 681
Modified:
trunk/Fdo/Unmanaged/Fdo.vcproj
trunk/Fdo/Unmanaged/FileToHdr.vcproj
trunk/Fdo/Unmanaged/Geometry.vcproj
trunk/Fdo/Unmanaged/McToMsf.vcproj
trunk/Fdo/Unmanaged/Nls.vcproj
trunk/Fdo/Unmanaged/Spatial.vcproj
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/CurvePolygon.cpp
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/CurvePolygon.h
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/CurveString.cpp
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/CurveString.h
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/GeometryFactory.cpp
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/GeometryFactory2.h
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/LineString.cpp
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/LineString.h
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/LinearRing.cpp
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiCurvePolygon.cpp
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiCurvePolygon.h
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiCurveString.cpp
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiCurveString.h
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiGeometry.cpp
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiGeometry.h
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiLineString.cpp
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiLineString.h
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiPoint.cpp
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiPoint.h
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiPolygon.cpp
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiPolygon.h
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Point.cpp
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Point.h
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Polygon.cpp
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Polygon.h
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Pool.h
trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Util.cpp
trunk/Fdo/Unmanaged/Src/Spatial/SpatialUtility.cpp
Log:
Port FDO200, FDO261, FDO262, FDO300, FDO319 from 3.2.x to trunk
Modified: trunk/Fdo/Unmanaged/Fdo.vcproj
===================================================================
--- trunk/Fdo/Unmanaged/Fdo.vcproj 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Fdo.vcproj 2007-01-29 19:43:26 UTC (rev 681)
@@ -555,6 +555,14 @@
</FileConfiguration>
</File>
<File
+ RelativePath=".\Src\Fdo\Schema\SchemaInternal.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Src\Fdo\Schema\SchemaInternal.h"
+ >
+ </File>
+ <File
RelativePath="Src\Fdo\Schema\TopoFeaturePropertyDefinition.cpp"
>
</File>
@@ -2148,6 +2156,10 @@
Name="Raster"
>
<File
+ RelativePath="Inc\Fdo\Raster\DataValueCollection.h"
+ >
+ </File>
+ <File
RelativePath="Inc\Fdo\Raster\IRaster.h"
>
</File>
Modified: trunk/Fdo/Unmanaged/FileToHdr.vcproj
===================================================================
--- trunk/Fdo/Unmanaged/FileToHdr.vcproj 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/FileToHdr.vcproj 2007-01-29 19:43:26 UTC (rev 681)
@@ -42,12 +42,12 @@
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
- BasicRuntimeChecks="3"
+ BasicRuntimeChecks="0"
RuntimeLibrary="1"
UsePrecompiledHeader="1"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
- DebugInformationFormat="4"
+ DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -60,8 +60,9 @@
/>
<Tool
Name="VCLinkerTool"
+ AdditionalOptions="/fixed:no"
OutputFile="$(OutDir)/FileToHdr.exe"
- LinkIncremental="2"
+ LinkIncremental="1"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/FileToHdr.pdb"
SubSystem="1"
Modified: trunk/Fdo/Unmanaged/Geometry.vcproj
===================================================================
--- trunk/Fdo/Unmanaged/Geometry.vcproj 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Geometry.vcproj 2007-01-29 19:43:26 UTC (rev 681)
@@ -139,7 +139,7 @@
PrecompiledHeaderFile=""
WarningLevel="3"
SuppressStartupBanner="true"
- DebugInformationFormat="1"
+ DebugInformationFormat="3"
CompileAs="0"
/>
<Tool
@@ -153,6 +153,7 @@
/>
<Tool
Name="VCLinkerTool"
+ AdditionalOptions="/fixed:no"
AdditionalDependencies="FDOCommon.lib"
OutputFile="$(OutDir)/FDOGeometry.dll"
LinkIncremental="1"
@@ -249,11 +250,11 @@
>
</File>
<File
- RelativePath="Src\Geometry\GeometryImpl.h"
+ RelativePath="Src\Geometry\Fgf\GeometryImpl.h"
>
</File>
<File
- RelativePath="Src\Geometry\Fgf\GeometryImpl.h"
+ RelativePath="Src\Geometry\GeometryImpl.h"
>
</File>
<File
Modified: trunk/Fdo/Unmanaged/McToMsf.vcproj
===================================================================
--- trunk/Fdo/Unmanaged/McToMsf.vcproj 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/McToMsf.vcproj 2007-01-29 19:43:26 UTC (rev 681)
@@ -42,12 +42,12 @@
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
- BasicRuntimeChecks="3"
+ BasicRuntimeChecks="0"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
- DebugInformationFormat="4"
+ DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -60,8 +60,9 @@
/>
<Tool
Name="VCLinkerTool"
+ AdditionalOptions="/fixed:no"
OutputFile="$(OutDir)/McToMsf.exe"
- LinkIncremental="2"
+ LinkIncremental="1"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/McToMsf.pdb"
SubSystem="1"
Modified: trunk/Fdo/Unmanaged/Nls.vcproj
===================================================================
--- trunk/Fdo/Unmanaged/Nls.vcproj 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Nls.vcproj 2007-01-29 19:43:26 UTC (rev 681)
@@ -117,7 +117,7 @@
PrecompiledHeaderFile=""
WarningLevel="3"
SuppressStartupBanner="true"
- DebugInformationFormat="1"
+ DebugInformationFormat="3"
CompileAs="0"
/>
<Tool
Modified: trunk/Fdo/Unmanaged/Spatial.vcproj
===================================================================
--- trunk/Fdo/Unmanaged/Spatial.vcproj 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Spatial.vcproj 2007-01-29 19:43:26 UTC (rev 681)
@@ -139,7 +139,7 @@
PrecompiledHeaderFile=""
WarningLevel="3"
SuppressStartupBanner="true"
- DebugInformationFormat="1"
+ DebugInformationFormat="3"
CompileAs="0"
/>
<Tool
@@ -153,6 +153,7 @@
/>
<Tool
Name="VCLinkerTool"
+ AdditionalOptions="/fixed:no"
AdditionalDependencies="FDOCommon.lib FDOGeometry.lib"
OutputFile="$(OutDir)/FDOSpatial.dll"
LinkIncremental="1"
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/CurvePolygon.cpp
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/CurvePolygon.cpp 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/CurvePolygon.cpp 2007-01-29 19:43:26 UTC (rev 681)
@@ -72,11 +72,21 @@
const FdoByte * data,
FdoInt32 count
)
- : FdoFgfGeometryImpl<FdoICurvePolygon>(factory, byteArray, data, count)
+ : FdoFgfGeometryImpl<FdoICurvePolygon>(factory)
{
+ Reset(byteArray, data, count);
}
+void FdoFgfCurvePolygon::Reset(
+ FdoByteArray * byteArray,
+ const FdoByte * data,
+ FdoInt32 count
+ )
+{
+ SetFgf(byteArray, data, count);
+}
+
/************************************************************************/
/* Destructor */
/************************************************************************/
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/CurvePolygon.h
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/CurvePolygon.h 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/CurvePolygon.h 2007-01-29 19:43:26 UTC (rev 681)
@@ -42,6 +42,9 @@
FdoFgfCurvePolygon(FdoFgfGeometryFactory * factory, FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+ // Support object re-use, matching the constructor.
+ void Reset(FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+
virtual ~FdoFgfCurvePolygon();
// FdoIGeometry
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/CurveString.cpp
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/CurveString.cpp 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/CurveString.cpp 2007-01-29 19:43:26 UTC (rev 681)
@@ -78,11 +78,21 @@
const FdoByte * data,
FdoInt32 count
)
- : FdoFgfGeometryImpl<FdoICurveString>(factory, byteArray, data, count)
+ : FdoFgfGeometryImpl<FdoICurveString>(factory)
{
+ Reset(byteArray, data, count);
}
+void FdoFgfCurveString::Reset(
+ FdoByteArray * byteArray,
+ const FdoByte * data,
+ FdoInt32 count
+ )
+{
+ SetFgf(byteArray, data, count);
+}
+
/************************************************************************/
/* Destructor */
/************************************************************************/
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/CurveString.h
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/CurveString.h 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/CurveString.h 2007-01-29 19:43:26 UTC (rev 681)
@@ -41,6 +41,9 @@
FdoFgfCurveString(FdoFgfGeometryFactory * factory, FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+ // Support object re-use, matching the constructor.
+ void Reset(FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+
virtual ~FdoFgfCurveString();
// From FdoIGeometry
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/GeometryFactory.cpp
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/GeometryFactory.cpp 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/GeometryFactory.cpp 2007-01-29 19:43:26 UTC (rev 681)
@@ -32,11 +32,6 @@
#define WKB_LITTLE_ENDIAN (1)
-#ifdef EXTRA_DEBUG
- FILE * FdoDebugFile = NULL;
-#endif
-
-
FdoFgfGeometryFactory* FdoFgfGeometryFactory::GetInstance()
{
FdoGeometryThreadData * threadData = FdoGeometryThreadData::GetValue();
@@ -52,12 +47,6 @@
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
}
-#ifdef EXTRA_DEBUG
- if (NULL == FdoDebugFile)
- {
- FdoDebugFile = fopen("D:\\temp\\FdoDebugFile.log", "w+");
- }
-#endif
return FDO_SAFE_ADDREF((threadData->geometryFactory).p);
}
@@ -68,13 +57,23 @@
FdoInt32 numCurveSegments,
FdoInt32 numRings)
{
- throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_3_NOTIMPLEMENTED)));
+ // Only a limited implementation is available, which uses defaults for
+ // the pool sizes. The returned object is, however, a private one,
+ // i.e. not in thread-local storage.
+ FdoFgfGeometryFactory * gf = new FdoFgfGeometryFactory();
+ return gf;
}
// Constructor
FdoFgfGeometryFactory::FdoFgfGeometryFactory()
{
+#ifdef EXTRA_DEBUG
+ char fileName[1000];
+ sprintf(fileName, "D:\\temp\\FdoDebugFile0x%lx.log", (long)(this));
+ m_private->m_fdoDebugFile = fopen(fileName, "w+");
+#endif
+
m_private = new FdoFgfGeometryFactory2();
if (NULL == m_private)
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
@@ -84,125 +83,100 @@
// Destructor
FdoFgfGeometryFactory::~FdoFgfGeometryFactory()
{
- delete m_private;
-
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "FdoFgfGeometryFactory::~FdoFgfGeometryFactory()\n");
- fflush(FdoDebugFile);
- PrintStats();
+ fprintf(m_private->m_fdoDebugFile, "FdoFgfGeometryFactory::~FdoFgfGeometryFactory()\n");
+ fflush(m_private->m_fdoDebugFile);
+ m_private->PrintStats(m_private->m_fdoDebugFile);
+ fclose(m_private->m_fdoDebugFile);
}
#endif
+
+ delete m_private;
}
#ifdef EXTRA_DEBUG
-void FdoFgfGeometryFactory2::PrintStats()
+void FdoFgfGeometryFactory2::PrintStats(FILE * fileHandle)
{
- if (NULL != FdoDebugFile)
+ if (NULL != fileHandle)
{
FdoInt32 ehits=0, rhits=0, misses=0;
- fprintf(FdoDebugFile, " FdoFgfGeometryFactory::PrintStats():\n");
- fprintf(FdoDebugFile, " %d LinearRings created.\n", m_private->m_numLinearRingsCreated);
- if (m_private->m_linearRingPool != NULL)
+ fprintf(fileHandle, " FdoFgfGeometryFactory::PrintStats():\n");
+ int debugFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
+ fprintf(fileHandle, " memory debug flag = 0x%lx.\n", debugFlag);
+ fprintf(fileHandle, " %d ByteArrays created.\n", m_numByteArraysCreated);
+ if (m_byteArrayPool != NULL)
{
- this->m_private->m_linearRingPool->GetStats(&ehits, &rhits, &misses);
- fprintf(FdoDebugFile,
- " Pool stats: %d empty hits, %d reusable hits, %d misses\n",
+ m_byteArrayPool->GetStats(&ehits, &rhits, &misses);
+ fprintf(fileHandle,
+ " ByteArray Pool stats: %d empty hits, %d reusable hits, %d misses\n",
ehits, rhits, misses);
}
- fflush(FdoDebugFile);
+ if (this->m_PoolLineString != NULL)
+ {
+ m_PoolLineString->GetStats(&ehits, &rhits, &misses);
+ fprintf(fileHandle,
+ " LineString Pool stats: %d empty hits, %d reusable hits, %d misses\n",
+ ehits, rhits, misses);
+ }
+ if (m_linearRingPool != NULL)
+ {
+ m_linearRingPool->GetStats(&ehits, &rhits, &misses);
+ fprintf(fileHandle,
+ " LinearRing Pool stats: %d empty hits, %d reusable hits, %d misses\n",
+ ehits, rhits, misses);
+ }
+ fflush(fileHandle);
}
}
#endif
FdoILineString* FdoFgfGeometryFactory::CreateLineString(FdoDirectPositionCollection * positions)
{
-#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
- {
- fprintf(FdoDebugFile, "CreateLineString() IN\n");
- fflush(FdoDebugFile);
- }
-#endif
- if ( (NULL == positions) ||
- ( 0 == positions->GetCount()) )
- throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_INVALID_INPUT_ON_CLASS_CREATION),
- L"FdoILineString",
- L"positions"));
-
- FdoPtr<FdoILineString> lineString = new FdoFgfLineString(this, positions);
-
- if (lineString == NULL)
- throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
-
-#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
- {
- fprintf(FdoDebugFile, "CreateLineString() OUT\n");
- fflush(FdoDebugFile);
- }
-#endif
- return FDO_SAFE_ADDREF(lineString.p);
+ FDOPOOL_CREATE_OBJECT(
+ m_private->m_PoolLineString, FdoPoolFgfLineString, 4,
+ FdoFgfLineString,
+ FdoFgfLineString(this, positions),
+ Reset(positions) );
}
FdoILineString* FdoFgfGeometryFactory::CreateLineString(FdoInt32 dimensionType, FdoInt32 numOrdinates, double* ordinates)
{
-#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
- {
- fprintf(FdoDebugFile, "CreateLineString() IN\n");
- fflush(FdoDebugFile);
- }
-#endif
- if ( (numOrdinates <= 0) ||
- (NULL == ordinates) )
- throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_INVALID_INPUT_ON_CLASS_CREATION),
- L"FdoILineString",
- L"ordinates/numOrdinates"));
-
- FdoPtr<FdoILineString> geometry = new FdoFgfLineString(this, dimensionType, numOrdinates, ordinates);
-
- if (geometry == NULL)
- throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
-
-#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
- {
- fprintf(FdoDebugFile, "CreateLineString() OUT\n");
- fflush(FdoDebugFile);
- }
-#endif
- return FDO_SAFE_ADDREF(geometry.p);
+ FDOPOOL_CREATE_OBJECT(
+ m_private->m_PoolLineString, FdoPoolFgfLineString, 4,
+ FdoFgfLineString,
+ FdoFgfLineString(this, dimensionType, numOrdinates, ordinates),
+ Reset(dimensionType, numOrdinates, ordinates) );
}
// Pseudo copy constructor; this method can convert between implementations.
FdoIGeometry * FdoFgfGeometryFactory::CreateGeometry(FdoIGeometry * geometry)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateGeometry(geometry=0x%lx) type=%d IN\n",
+ fprintf(m_private->m_fdoDebugFile, "CreateGeometry(geometry=0x%lx) type=%d IN\n",
(long)geometry, (int)(geometry->GetDerivedType()));
- fflush(FdoDebugFile);
+ fflush(m_private->m_fdoDebugFile);
try
{
//if (geometry->GetDerivedType() == FdoGeometryType_LineString)
{
FdoString * fgftString = geometry->GetText();
- fprintf(FdoDebugFile, " fgft='%S'\n", fgftString);
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, " fgft='%S'\n", fgftString);
+ fflush(m_private->m_fdoDebugFile);
}
}
catch ( FdoException* e )
{
- fprintf(FdoDebugFile, " Caught FdoException from GetText(): <<%S>>\n", e->GetExceptionMessage());
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, " Caught FdoException from GetText(): <<%S>>\n", e->GetExceptionMessage());
+ fflush(m_private->m_fdoDebugFile);
}
catch (...)
{
- fprintf(FdoDebugFile, " Caught unknown exception from GetText().\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, " Caught unknown exception from GetText().\n");
+ fflush(m_private->m_fdoDebugFile);
}
}
@@ -218,11 +192,11 @@
newByteArray = NULL;
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateGeometry() OUT\n",
+ fprintf(m_private->m_fdoDebugFile, "CreateGeometry() OUT\n",
(long)geometry);
- fflush(FdoDebugFile);
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(newGeometry.p);
@@ -244,20 +218,15 @@
L"byteArray/byteArrayData/count"));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateGeometryFromFgf(0x%lx, 0x%lx, count=%d) IN\n",
+ fprintf(m_private->m_fdoDebugFile, "CreateGeometryFromFgf(0x%lx, 0x%lx, count=%d) IN\n",
(long)byteArray, (long)byteArrayData, count);
- fflush(FdoDebugFile);
+ fflush(m_private->m_fdoDebugFile);
}
#endif
FdoPtr<FdoIGeometry> newGeometry;
- if (m_private->m_geometryPool2 == NULL)
- {
- m_private->m_geometryPool2 = FdoGeometryCollection::Create();
- }
-
const FdoByte * streamPtr = NULL;
const FdoByte * streamEnd = NULL;
if (NULL != byteArray)
@@ -272,118 +241,46 @@
}
FdoGeometryType geometryType = (FdoGeometryType) FgfUtil::ReadInt32(&streamPtr, streamEnd);
-
- FdoInt32 pooledGeometryToReplaceIndex = -1;
- FdoInt32 pooledGeometryToReassignIndex = -1;
- bool done = false;
-
- for (FdoInt32 i = 0; !done && i < m_private->m_geometryPool2->GetCount(); i++)
+#ifdef EXTRA_DEBUG
+ if (NULL != m_private->m_fdoDebugFile)
{
- FdoPtr<FdoIGeometry> pooledGeometry = m_private->m_geometryPool2->GetItem(i);
-
- if (pooledGeometry != NULL)
- {
- FdoGeometryType pooledGeometryType = pooledGeometry->GetDerivedType();
- if (pooledGeometryType == geometryType)
- {
- // New FGF is the same type as the pooled geometry.
- FdoInt32 refCount = GET_REFCOUNT(pooledGeometry.p);
- if (2 == refCount) // 2 == local variable pointer + pool pointer
- {
- // This factory is the exclusive owner of this pooled geometry. Just re-assign its FGF.
- pooledGeometryToReassignIndex = i;
- }
- else
- {
- // We found a geometry of the correct type, but we aren't the excusive owner.
- pooledGeometryToReplaceIndex = i;
- }
- done = true; // Done, whether we re-used the geometry or not (only pool 1 of each type)
- }
- }
+ fprintf(m_private->m_fdoDebugFile, "FdoFgfGeometryFactory::CreateGeometryFromFgf GeometryType=%d\n", (int) geometryType);
+ fflush(m_private->m_fdoDebugFile);
}
+#endif
-#define CASE_REASSIGN_FGF(type) \
+#define CASE_CREATE_POOLED_GEOMETRY(type) \
case FdoGeometryType_##type: \
- { \
- newGeometry = m_private->m_geometryPool2->GetItem(pooledGeometryToReassignIndex); \
- FdoFgf##type * derivedGeom = (FdoFgf##type *)(newGeometry.p); \
- derivedGeom->SetFgf(byteArray, byteArrayData, count); \
- } \
+ newGeometry = m_private->Create##type(this, byteArray, byteArrayData, count); \
break;
-#define CASE_CREATE_GEOMETRY(type) \
- case FdoGeometryType_##type: \
- newGeometry = new FdoFgf##type(this, byteArray, byteArrayData, count); \
- break;
-
- if (pooledGeometryToReassignIndex >= 0)
+ // Call SetFgf() on the appropriate type. Unfortunately, we cannot call it
+ // directly on the base FdoFgfGeometryImpl type because it's a template on an
+ // abstract type (FdoIGeometry).
+ switch ( geometryType )
{
- // Call SetFgf() on the appropriate type. Unfortunately, we cannot call it
- // directly on the base FdoFgfGeometryImpl type because it's a template on an
- // abstract type (FdoIGeometry).
- switch ( geometryType )
- {
- CASE_REASSIGN_FGF(LineString);
- CASE_REASSIGN_FGF(Point);
- CASE_REASSIGN_FGF(Polygon);
- CASE_REASSIGN_FGF(MultiPoint);
- CASE_REASSIGN_FGF(MultiGeometry);
- CASE_REASSIGN_FGF(MultiLineString);
- CASE_REASSIGN_FGF(MultiPolygon);
- CASE_REASSIGN_FGF(CurveString);
- CASE_REASSIGN_FGF(MultiCurveString);
- CASE_REASSIGN_FGF(CurvePolygon);
- CASE_REASSIGN_FGF(MultiCurvePolygon);
- default:
- throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_UNKNOWN_GEOMETRY_TYPE),
- L"FdoFgfGeometryFactory::CreateGeometryFromFgf",
- geometryType));
- }
+ CASE_CREATE_POOLED_GEOMETRY(LineString);
+ CASE_CREATE_POOLED_GEOMETRY(Point);
+ CASE_CREATE_POOLED_GEOMETRY(Polygon);
+ CASE_CREATE_POOLED_GEOMETRY(MultiPoint);
+ CASE_CREATE_POOLED_GEOMETRY(MultiGeometry);
+ CASE_CREATE_POOLED_GEOMETRY(MultiLineString);
+ CASE_CREATE_POOLED_GEOMETRY(MultiPolygon);
+ CASE_CREATE_POOLED_GEOMETRY(CurveString);
+ CASE_CREATE_POOLED_GEOMETRY(MultiCurveString);
+ CASE_CREATE_POOLED_GEOMETRY(CurvePolygon);
+ CASE_CREATE_POOLED_GEOMETRY(MultiCurvePolygon);
+ default:
+ throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_UNKNOWN_GEOMETRY_TYPE),
+ L"FdoFgfGeometryFactory::CreateGeometryFromFgf",
+ geometryType));
}
- else
- {
- // We did not get anything from the pool. Really create a new geometry.
- switch ( geometryType )
- {
- CASE_CREATE_GEOMETRY(LineString);
- CASE_CREATE_GEOMETRY(Point);
- CASE_CREATE_GEOMETRY(Polygon);
- CASE_CREATE_GEOMETRY(MultiPoint);
- CASE_CREATE_GEOMETRY(MultiGeometry);
- CASE_CREATE_GEOMETRY(MultiLineString);
- CASE_CREATE_GEOMETRY(MultiPolygon);
- CASE_CREATE_GEOMETRY(CurveString);
- CASE_CREATE_GEOMETRY(MultiCurveString);
- CASE_CREATE_GEOMETRY(CurvePolygon);
- CASE_CREATE_GEOMETRY(MultiCurvePolygon);
- default:
- throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_UNKNOWN_GEOMETRY_TYPE),
- L"FdoFgfGeometryFactory::CreateGeometryFromFgf",
- geometryType));
- }
-
- // Update the pool.
- if (pooledGeometryToReplaceIndex >= 0)
- {
- m_private->m_geometryPool2->SetItem(pooledGeometryToReplaceIndex, newGeometry);
- }
- else
- {
- (void) m_private->m_geometryPool2->Add(newGeometry);
- }
- } // end creation of new geometry
-
- if (newGeometry == NULL)
- throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
-
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateGeometryFromFgf() OUT\n",
- (long)byteArray, (long)byteArrayData, count);
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateGeometryFromFgf() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(newGeometry.p);
@@ -407,10 +304,10 @@
FdoByteArray * FdoFgfGeometryFactory::GetFgf(FdoIGeometry * geometry)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "FdoFgfGeometryFactory::GetFgf() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "FdoFgfGeometryFactory::GetFgf() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
FdoPtr<FdoByteArray> array = 0;
@@ -473,10 +370,10 @@
}
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "FdoFgfGeometryFactory::GetFgf() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "FdoFgfGeometryFactory::GetFgf() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(array.p);
@@ -484,13 +381,6 @@
static FdoByteArray * CreateFgfFromWkb(FdoInt32 geometryType, FdoByte * byteArray, FdoInt32 byteArraySize, FdoInt32 * numBytesRead)
{
-#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
- {
- fprintf(FdoDebugFile, "CreateFgfFromWkb() IN\n");
- fflush(FdoDebugFile);
- }
-#endif
// Assume that byteArray points to WKB data immediately after the geometry type.
// We'll use the available WKB data to create FGF data and then create a geometry object.
@@ -589,23 +479,16 @@
if (NULL != numBytesRead)
*numBytesRead = byteArraySize - numBytes;
-#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
- {
- fprintf(FdoDebugFile, "CreateFgfFromWkb() OUT\n");
- fflush(FdoDebugFile);
- }
-#endif
return fgfByteArray;
}
FdoIGeometry * FdoFgfGeometryFactory::CreateGeometryFromWkb(FdoByteArray * byteArray)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateGeometryFromWkb() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateGeometryFromWkb() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
#define MIN_WKB_SIZE (sizeof(FdoByte)+sizeof(FdoInt32)+sizeof(FdoInt32)) // endian byte, geometry type, at least an integer of data
@@ -636,10 +519,10 @@
FdoPtr<FdoIGeometry> geometry = this->CreateGeometryFromFgf(fgfByteArray);
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateGeometryFromWkb() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateGeometryFromWkb() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(geometry.p);
@@ -649,10 +532,10 @@
FdoByteArray * FdoFgfGeometryFactory::GetWkb(FdoIGeometry * geometry)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "FdoFgfGeometryFactory::GetWkb() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "FdoFgfGeometryFactory::GetWkb() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if (NULL == geometry)
@@ -727,10 +610,10 @@
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_10_UNSUPPORTEDGEOMETRYTYPE)));
}
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "FdoFgfGeometryFactory::GetWkb() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "FdoFgfGeometryFactory::GetWkb() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return wkb;
@@ -744,10 +627,10 @@
FdoIPoint* FdoFgfGeometryFactory::CreatePoint(FdoIDirectPosition* position)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreatePoint() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreatePoint() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if (NULL == position)
@@ -759,10 +642,10 @@
if (point == NULL)
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreatePoint() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreatePoint() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(point.p);
@@ -775,10 +658,10 @@
FdoIPoint* FdoFgfGeometryFactory::CreatePoint(FdoInt32 dimensionality, double* ordinates)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreatePoint() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreatePoint() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if (NULL == ordinates)
@@ -789,10 +672,10 @@
if (point == NULL)
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreatePoint() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreatePoint() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(point.p);
@@ -804,41 +687,11 @@
/************************************************************************/
FdoILinearRing* FdoFgfGeometryFactory::CreateLinearRing(FdoDirectPositionCollection * positions)
{
-#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
- {
- fprintf(FdoDebugFile, "CreateLinearRing() IN\n");
- fflush(FdoDebugFile);
- }
-#endif
-
- if (m_private->m_linearRingPool == NULL)
- m_private->m_linearRingPool = FdoFgfLinearRingCache::Create(4);
-
- FdoPtr<FdoFgfLinearRing> lineRing = m_private->m_linearRingPool->FindReusableItem();
-
- if (lineRing == NULL)
- {
- lineRing = new FdoFgfLinearRing(this, positions);
- if (lineRing == NULL)
- throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
- }
- else
- {
- lineRing->Reset(positions);
- }
-
- m_private->m_linearRingPool->AddItem(lineRing);
-
-#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
- {
- fprintf(FdoDebugFile, "CreateLinearRing() OUT\n");
- fflush(FdoDebugFile);
- PrintStats();
- }
-#endif
- return FDO_SAFE_ADDREF(lineRing.p);
+ FDOPOOL_CREATE_OBJECT(
+ m_private->m_linearRingPool, FdoFgfLinearRingPool, 4,
+ FdoFgfLinearRing,
+ FdoFgfLinearRing(this, positions),
+ Reset(positions) );
}
@@ -847,46 +700,11 @@
/************************************************************************/
FdoILinearRing* FdoFgfGeometryFactory::CreateLinearRing(FdoInt32 dimtype, FdoInt32 numOrdinates, double* ordinates)
{
-#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
- {
- fprintf(FdoDebugFile, "CreateLinearRing() IN\n");
- fflush(FdoDebugFile);
- }
-#endif
- if ( (NULL == ordinates) ||
- (numOrdinates <= 0) )
- throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_INVALID_INPUT_ON_CLASS_CREATION),
- L"FdoILinearRing",
- L"ordinates/numOrdinates"));
-
- if (m_private->m_linearRingPool == NULL)
- m_private->m_linearRingPool = FdoFgfLinearRingCache::Create(4);
-
- FdoPtr<FdoFgfLinearRing> lineRing = m_private->m_linearRingPool->FindReusableItem();
-
- if (lineRing == NULL)
- {
- lineRing = new FdoFgfLinearRing(this, dimtype, numOrdinates, ordinates);
- if (lineRing == NULL)
- throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
- }
- else
- {
- lineRing->Reset(dimtype, numOrdinates, ordinates);
- }
-
- m_private->m_linearRingPool->AddItem(lineRing);
-
-#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
- {
- fprintf(FdoDebugFile, "CreateLinearRing() OUT\n");
- fflush(FdoDebugFile);
- PrintStats();
- }
-#endif
- return FDO_SAFE_ADDREF(lineRing.p);
+ FDOPOOL_CREATE_OBJECT(
+ m_private->m_linearRingPool, FdoFgfLinearRingPool, 4,
+ FdoFgfLinearRing,
+ FdoFgfLinearRing(this, dimtype, numOrdinates, ordinates),
+ Reset(dimtype, numOrdinates, ordinates) );
}
//LineStringSegment
@@ -897,10 +715,10 @@
FdoILineStringSegment* FdoFgfGeometryFactory::CreateLineStringSegment(FdoDirectPositionCollection * positions)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateLineStringSegment() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateLineStringSegment() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if ( (NULL == positions) ||
@@ -915,10 +733,10 @@
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateLineStringSegment() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateLineStringSegment() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(lineSegment.p);
@@ -932,10 +750,10 @@
FdoILineStringSegment* FdoFgfGeometryFactory::CreateLineStringSegment(FdoInt32 dimensionality, FdoInt32 numOrdinates, double* ordinates)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateLineStringSegment() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateLineStringSegment() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if ( (NULL == ordinates) ||
@@ -950,10 +768,10 @@
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateLineStringSegment() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateLineStringSegment() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(lineSegment.p);
@@ -966,10 +784,10 @@
FdoIPolygon* FdoFgfGeometryFactory::CreatePolygon(FdoILinearRing* exteriorRing, FdoLinearRingCollection* interiorRings)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreatePolygon() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreatePolygon() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if (NULL == exteriorRing)
@@ -983,10 +801,10 @@
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreatePolygon() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreatePolygon() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(polygon.p);
@@ -1000,10 +818,10 @@
FdoIMultiPoint* FdoFgfGeometryFactory::CreateMultiPoint(FdoPointCollection* points)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateMultiPoint() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateMultiPoint() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if ( (NULL == points) ||
@@ -1018,10 +836,10 @@
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateMultiPoint() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateMultiPoint() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(multiPoint.p);
@@ -1035,10 +853,10 @@
FdoIMultiPoint* FdoFgfGeometryFactory::CreateMultiPoint(FdoInt32 dimensionality, FdoInt32 numOrdinates, double* ordinates)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateMultiPoint() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateMultiPoint() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if ( (NULL == ordinates) ||
@@ -1053,10 +871,10 @@
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateMultiPoint() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateMultiPoint() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(multiPoint.p);
@@ -1070,10 +888,10 @@
FdoIMultiGeometry* FdoFgfGeometryFactory::CreateMultiGeometry(FdoGeometryCollection* geometries)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateMultiGeometry() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateMultiGeometry() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if ( (NULL == geometries) ||
@@ -1088,10 +906,10 @@
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateMultiGeometry() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateMultiGeometry() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(multiGeometry.p);
@@ -1105,10 +923,10 @@
FdoIMultiLineString* FdoFgfGeometryFactory::CreateMultiLineString(FdoLineStringCollection* lineStrings)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateMultiLineString() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateMultiLineString() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if ( (NULL == lineStrings) ||
@@ -1123,10 +941,10 @@
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateMultiLineString() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateMultiLineString() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(multiLineString.p);
@@ -1141,10 +959,10 @@
FdoIMultiPolygon* FdoFgfGeometryFactory::CreateMultiPolygon(FdoPolygonCollection* polygons)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateMultiPolygon() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateMultiPolygon() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if ( (NULL == polygons) ||
@@ -1159,10 +977,10 @@
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateMultiPolygon() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateMultiPolygon() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(multiPolygon.p);
@@ -1175,10 +993,10 @@
FdoICircularArcSegment* FdoFgfGeometryFactory::CreateCircularArcSegment(FdoIDirectPosition* startPoint, FdoIDirectPosition* midPoint, FdoIDirectPosition* endPoint)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateCircularArcSegment() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateCircularArcSegment() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if ( (NULL == startPoint) ||
@@ -1194,10 +1012,10 @@
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateCircularArcSegment() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateCircularArcSegment() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(circArcSegment.p);
@@ -1211,10 +1029,10 @@
FdoICurveString* FdoFgfGeometryFactory::CreateCurveString(FdoCurveSegmentCollection* curveSegments)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateCurveString() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateCurveString() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if ( (NULL == curveSegments) ||
@@ -1229,10 +1047,10 @@
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateCurveString() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateCurveString() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(curveString.p);
@@ -1246,10 +1064,10 @@
FdoIMultiCurveString* FdoFgfGeometryFactory::CreateMultiCurveString(FdoCurveStringCollection* curveStrings)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateMultiCurveString() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateMultiCurveString() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if ( (NULL == curveStrings) || (0 == curveStrings->GetCount()) )
@@ -1263,10 +1081,10 @@
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateMultiCurveString() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateMultiCurveString() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(multiCurveString.p);
@@ -1280,10 +1098,10 @@
FdoIRing* FdoFgfGeometryFactory::CreateRing(FdoCurveSegmentCollection* curveSegments)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateRing() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateRing() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if ( (NULL == curveSegments) ||
@@ -1298,10 +1116,10 @@
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateRing() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateRing() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(ring.p);
@@ -1316,10 +1134,10 @@
FdoICurvePolygon* FdoFgfGeometryFactory::CreateCurvePolygon(FdoIRing* exteriorRing, FdoRingCollection* interiorRings)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateCurvePolygon() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateCurvePolygon() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if (NULL == exteriorRing)
@@ -1333,10 +1151,10 @@
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateCurvePolygon() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateCurvePolygon() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(curvePolygon.p);
@@ -1351,10 +1169,10 @@
FdoIMultiCurvePolygon* FdoFgfGeometryFactory::CreateMultiCurvePolygon(FdoCurvePolygonCollection* curvePolygons)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateMultiCurvePolygon() IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateMultiCurvePolygon() IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
if ( (NULL == curvePolygons) || 0 == curvePolygons->GetCount() )
@@ -1368,10 +1186,10 @@
throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC)));
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateMultiCurvePolygon() OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateMultiCurvePolygon() OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(multiCurvePolygon.p);
@@ -1382,10 +1200,10 @@
FdoIGeometry * FdoFgfGeometryFactory::CreateGeometry(FdoIEnvelope * envelope)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateGeometry(envelope) IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateGeometry(envelope) IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
int dimensionality = FdoDimensionality_XY;
@@ -1428,10 +1246,10 @@
FdoPtr<FdoIPolygon> geometry = CreatePolygon(ring, NULL);
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateGeometry(envelope) OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateGeometry(envelope) OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(geometry.p);
@@ -1440,10 +1258,10 @@
FdoIGeometry* FdoFgfGeometryFactory::CreateGeometry(FdoString* fgft)
{
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateGeometry(fgft) IN\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateGeometry(fgft) IN\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
FdoPtr<FdoIGeometry> geometry;
@@ -1462,10 +1280,10 @@
delete parse;
}
#ifdef EXTRA_DEBUG
- if (NULL != FdoDebugFile)
+ if (NULL != m_private->m_fdoDebugFile)
{
- fprintf(FdoDebugFile, "CreateGeometry(fgft) OUT\n");
- fflush(FdoDebugFile);
+ fprintf(m_private->m_fdoDebugFile, "CreateGeometry(fgft) OUT\n");
+ fflush(m_private->m_fdoDebugFile);
}
#endif
return FDO_SAFE_ADDREF(geometry.p);
@@ -1474,7 +1292,7 @@
FdoByteArray * FdoFgfGeometryFactory::GetByteArray()
{
if (m_private->m_byteArrayPool == NULL)
- m_private->m_byteArrayPool = FdoByteArrayCache::Create(10);
+ m_private->m_byteArrayPool = FdoByteArrayPool::Create(10);
// Acquire or create a byte array, whose ownership we'll hand completely
// over to the writer. Updateable FdoArray types cannot have shared ownership,
@@ -1482,13 +1300,14 @@
// updateable FdoArray types for the same reason.
FdoByteArray * byteArray = NULL;
-#ifdef POOL_BYTEARRAYS
byteArray = m_private->m_byteArrayPool->FindReusableItem();
-#endif
if (byteArray == NULL)
{
byteArray = FdoByteArray::Create(172); // A guess: endian+type+dim+20ordinates
+#ifdef EXTRA_DEBUG
+ m_private->m_numByteArraysCreated++;
+#endif
}
else
{
@@ -1507,11 +1326,9 @@
L"byteArray"));
if (m_private->m_byteArrayPool == NULL)
- m_private->m_byteArrayPool = FdoByteArrayCache::Create(10);
+ m_private->m_byteArrayPool = FdoByteArrayPool::Create(10);
-#ifdef POOL_BYTEARRAYS
m_private->m_byteArrayPool->AddItem(byteArray);
-#endif
}
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/GeometryFactory2.h
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/GeometryFactory2.h 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/GeometryFactory2.h 2007-01-29 19:43:26 UTC (rev 681)
@@ -45,30 +45,104 @@
#include "MultiCurvePolygon.h"
-FDOPOOL_DEFINE(FdoByteArrayCache, FdoByteArray)
-FDOPOOL_DEFINE(FdoFgfLinearRingCache, FdoFgfLinearRing)
+FDOPOOL_DEFINE(FdoByteArrayPool, FdoByteArray)
+FDOPOOL_DEFINE(FdoFgfLinearRingPool, FdoFgfLinearRing)
+FDOPOOL_DEFINE(FdoPoolFgfLineString, FdoFgfLineString)
+FDOPOOL_DEFINE(FdoPoolFgfPoint, FdoFgfPoint)
+FDOPOOL_DEFINE(FdoPoolFgfPolygon, FdoFgfPolygon)
+FDOPOOL_DEFINE(FdoPoolFgfMultiPoint, FdoFgfMultiPoint)
+FDOPOOL_DEFINE(FdoPoolFgfMultiGeometry, FdoFgfMultiGeometry)
+FDOPOOL_DEFINE(FdoPoolFgfMultiLineString, FdoFgfMultiLineString)
+FDOPOOL_DEFINE(FdoPoolFgfMultiPolygon, FdoFgfMultiPolygon)
+FDOPOOL_DEFINE(FdoPoolFgfCurveString, FdoFgfCurveString)
+FDOPOOL_DEFINE(FdoPoolFgfMultiCurveString, FdoFgfMultiCurveString)
+FDOPOOL_DEFINE(FdoPoolFgfCurvePolygon, FdoFgfCurvePolygon)
+FDOPOOL_DEFINE(FdoPoolFgfMultiCurvePolygon, FdoFgfMultiCurvePolygon)
+#define FDO_GEOM_POOL_DECLARE(type) FdoPtr<FdoPoolFgf##type> m_Pool##type;
+#define FDO_GEOM_POOL_NULLIFY(type) m_Pool##type = NULL;
/// <summary>This defines private data for the FdoFgfGeometryFactory class.
/// Changes can be made here without affecting the public interface.
/// </summary>
struct FdoFgfGeometryFactory2
{
- FdoPtr<FdoGeometryCollection> m_geometryPool2; // A few previous Geometries created; For fast re-creation.
- FdoPtr<FdoByteArrayCache> m_byteArrayPool; // For fast re-creation.
- FdoPtr<FdoFgfLinearRingCache> m_linearRingPool; // For fast re-creation.
+ FdoPtr<FdoByteArrayPool> m_byteArrayPool; // For fast re-creation.
+ FdoPtr<FdoFgfLinearRingPool> m_linearRingPool; // For fast re-creation.
+ FDO_GEOM_POOL_DECLARE(LineString);
+ FDO_GEOM_POOL_DECLARE(Point);
+ FDO_GEOM_POOL_DECLARE(Polygon);
+ FDO_GEOM_POOL_DECLARE(MultiPoint);
+ FDO_GEOM_POOL_DECLARE(MultiGeometry);
+ FDO_GEOM_POOL_DECLARE(MultiLineString);
+ FDO_GEOM_POOL_DECLARE(MultiPolygon);
+ FDO_GEOM_POOL_DECLARE(CurveString);
+ FDO_GEOM_POOL_DECLARE(MultiCurveString);
+ FDO_GEOM_POOL_DECLARE(CurvePolygon);
+ FDO_GEOM_POOL_DECLARE(MultiCurvePolygon);
#ifdef EXTRA_DEBUG
- FdoInt32 m_numLinearRingsCreated;
- void PrintStats();
+ FdoInt32 m_numByteArraysCreated;
+ void PrintStats(FILE * fileHandle);
+ FILE * m_fdoDebugFile;
#endif
FdoFgfGeometryFactory2()
#ifdef EXTRA_DEBUG
- : m_numLinearRingsCreated(0)
+ : m_numByteArraysCreated(0),
+ m_fdoDebugFile(NULL)
#endif
{
};
- ~FdoFgfGeometryFactory2() {};
+ ~FdoFgfGeometryFactory2()
+ {
+ // Geometry object destructors may try to hand back byte arrays
+ // to the factory. Rather than let automatic destruction do this
+ // in an undefined order, we'll do it manually here to ensure that
+ // the byte array pool is still defined until the last step.
+ m_linearRingPool = NULL;
+ FDO_GEOM_POOL_NULLIFY(LineString);
+ FDO_GEOM_POOL_NULLIFY(Point);
+ FDO_GEOM_POOL_NULLIFY(Polygon);
+ FDO_GEOM_POOL_NULLIFY(MultiPoint);
+ FDO_GEOM_POOL_NULLIFY(MultiGeometry);
+ FDO_GEOM_POOL_NULLIFY(MultiLineString);
+ FDO_GEOM_POOL_NULLIFY(MultiPolygon);
+ FDO_GEOM_POOL_NULLIFY(CurveString);
+ FDO_GEOM_POOL_NULLIFY(MultiCurveString);
+ FDO_GEOM_POOL_NULLIFY(CurvePolygon);
+ FDO_GEOM_POOL_NULLIFY(MultiCurvePolygon);
+ m_byteArrayPool = NULL;
+ };
+
+ // Internal methods for FdoFgfGeometryFactory's use.
+
+#define DEFINE_CREATE_POOLED_GEOMETRY(type) \
+ FdoI##type * Create##type( \
+ FdoFgfGeometryFactory * factory, \
+ FdoByteArray * byteArray, \
+ const FdoByte * data, \
+ FdoInt32 count \
+ ) \
+ { \
+ FDOPOOL_CREATE_OBJECT( \
+ m_Pool##type, FdoPoolFgf##type, 4, \
+ FdoFgf##type, \
+ FdoFgf##type(factory, byteArray, data, count), \
+ Reset(byteArray, data, count) ); \
+ }
+
+ DEFINE_CREATE_POOLED_GEOMETRY(LineString);
+ DEFINE_CREATE_POOLED_GEOMETRY(Point);
+ DEFINE_CREATE_POOLED_GEOMETRY(Polygon);
+ DEFINE_CREATE_POOLED_GEOMETRY(MultiPoint);
+ DEFINE_CREATE_POOLED_GEOMETRY(MultiGeometry);
+ DEFINE_CREATE_POOLED_GEOMETRY(MultiLineString);
+ DEFINE_CREATE_POOLED_GEOMETRY(MultiPolygon);
+ DEFINE_CREATE_POOLED_GEOMETRY(CurveString);
+ DEFINE_CREATE_POOLED_GEOMETRY(MultiCurveString);
+ DEFINE_CREATE_POOLED_GEOMETRY(CurvePolygon);
+ DEFINE_CREATE_POOLED_GEOMETRY(MultiCurvePolygon);
+
};
#endif
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/LineString.cpp
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/LineString.cpp 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/LineString.cpp 2007-01-29 19:43:26 UTC (rev 681)
@@ -71,7 +71,6 @@
}
-
/************************************************************************/
/* Constructor */
/************************************************************************/
@@ -88,6 +87,10 @@
void FdoFgfLineString::Reset(FdoInt32 dimensionType, FdoInt32 numOrdinates, double* ordinates)
{
+ if ( (numOrdinates <= 0) ||
+ (NULL == ordinates) )
+ throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_2_BADPARAMETER)));
+
FdoByteArray * newByteArray = m_factory->GetByteArray();
m_previousPositionIndex = -1;
@@ -105,6 +108,7 @@
FDO_SAFE_RELEASE(newByteArray);
}
+
/************************************************************************/
/* Constructor */
/************************************************************************/
@@ -114,11 +118,22 @@
const FdoByte * data,
FdoInt32 count
)
- : FdoFgfGeometryImpl<FdoILineString>(factory, byteArray, data, count), m_previousPositionIndex(-1)
+ : FdoFgfGeometryImpl<FdoILineString>(factory), m_previousPositionIndex(-1)
{
+ Reset(byteArray, data, count);
}
+void FdoFgfLineString::Reset(
+ FdoByteArray * byteArray,
+ const FdoByte * data,
+ FdoInt32 count
+ )
+{
+ m_previousPositionIndex = -1;
+ SetFgf(byteArray, data, count);
+}
+
/************************************************************************/
/* Destructor */
/************************************************************************/
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/LineString.h
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/LineString.h 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/LineString.h 2007-01-29 19:43:26 UTC (rev 681)
@@ -40,21 +40,16 @@
// Copy the positions. Dimensionality is taken from the first position.
FdoFgfLineString(FdoFgfGeometryFactory * factory, FdoDirectPositionCollection* positions);
- // Copying the ordinates.
+ // Copy the ordinates.
FdoFgfLineString(FdoFgfGeometryFactory * factory, FdoInt32 dimensionType, FdoInt32 numOrdinates, double* ordinates);
- /*
- * Constructors supporting internal needs of this package.
- */
-
- // Just latch onto the data stream.
+ // (internal use) Just latch onto the data stream.
FdoFgfLineString(FdoFgfGeometryFactory * factory, FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
- virtual ~FdoFgfLineString();
-
// Support object re-use, matching the constructors.
- virtual void Reset(FdoDirectPositionCollection* positions);
- virtual void Reset(FdoInt32 dimensionType, FdoInt32 numOrdinates, double* ordinates);
+ void Reset(FdoDirectPositionCollection* positions);
+ void Reset(FdoInt32 dimensionType, FdoInt32 numOrdinates, double* ordinates);
+ void Reset(FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
// From FdoIGeometry
virtual FdoIEnvelope* GetEnvelope() const;
@@ -80,6 +75,8 @@
FdoFgfLineString() {}; // Default constructor to satisfy FdoPtr on Linux
+ virtual ~FdoFgfLineString();
+
mutable FdoInt32 m_previousPositionIndex;
FdoEnvelopeImpl* ComputeEnvelope() const;
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/LinearRing.cpp
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/LinearRing.cpp 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/LinearRing.cpp 2007-01-29 19:43:26 UTC (rev 681)
@@ -268,10 +268,9 @@
}
// Note: no tolerance here -- being topological, start and end positions must
- // be identical, not just close.
+ // be identical, not just close. Ignore Z ordinate checking.
return ( (x1 == x2) &&
- (y1 == y2) &&
- (z1 == z2) );
+ (y1 == y2) );
}
/************************************************************************/
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiCurvePolygon.cpp
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiCurvePolygon.cpp 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiCurvePolygon.cpp 2007-01-29 19:43:26 UTC (rev 681)
@@ -64,11 +64,21 @@
const FdoByte * data,
FdoInt32 count
)
- : FdoFgfGeometryImpl<FdoIMultiCurvePolygon>(factory, byteArray, data, count)
+ : FdoFgfGeometryImpl<FdoIMultiCurvePolygon>(factory)
{
+ Reset(byteArray, data, count);
}
+void FdoFgfMultiCurvePolygon::Reset(
+ FdoByteArray * byteArray,
+ const FdoByte * data,
+ FdoInt32 count
+ )
+{
+ SetFgf(byteArray, data, count);
+}
+
/************************************************************************/
/* Destructor */
/************************************************************************/
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiCurvePolygon.h
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiCurvePolygon.h 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiCurvePolygon.h 2007-01-29 19:43:26 UTC (rev 681)
@@ -41,6 +41,9 @@
FdoFgfMultiCurvePolygon(FdoFgfGeometryFactory * factory, FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+ // Support object re-use, matching the constructor.
+ void Reset(FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+
~FdoFgfMultiCurvePolygon();
// From FdoIGeometry
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiCurveString.cpp
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiCurveString.cpp 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiCurveString.cpp 2007-01-29 19:43:26 UTC (rev 681)
@@ -65,11 +65,21 @@
const FdoByte * data,
FdoInt32 count
)
- : FdoFgfGeometryImpl<FdoIMultiCurveString>(factory, byteArray, data, count)
+ : FdoFgfGeometryImpl<FdoIMultiCurveString>(factory)
{
+ Reset(byteArray, data, count);
}
+void FdoFgfMultiCurveString::Reset(
+ FdoByteArray * byteArray,
+ const FdoByte * data,
+ FdoInt32 count
+ )
+{
+ SetFgf(byteArray, data, count);
+}
+
/************************************************************************/
/* Destructor */
/************************************************************************/
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiCurveString.h
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiCurveString.h 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiCurveString.h 2007-01-29 19:43:26 UTC (rev 681)
@@ -41,6 +41,9 @@
FdoFgfMultiCurveString(FdoFgfGeometryFactory * factory, FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+ // Support object re-use, matching the constructor.
+ void Reset(FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+
~FdoFgfMultiCurveString();
// From FdoIGeometry
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiGeometry.cpp
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiGeometry.cpp 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiGeometry.cpp 2007-01-29 19:43:26 UTC (rev 681)
@@ -78,11 +78,21 @@
const FdoByte * data,
FdoInt32 count
)
- : FdoFgfGeometryImpl<FdoIMultiGeometry>(factory, byteArray, data, count)
+ : FdoFgfGeometryImpl<FdoIMultiGeometry>(factory)
{
+ Reset(byteArray, data, count);
}
+void FdoFgfMultiGeometry::Reset(
+ FdoByteArray * byteArray,
+ const FdoByte * data,
+ FdoInt32 count
+ )
+{
+ SetFgf(byteArray, data, count);
+}
+
/************************************************************************/
/* Destructor */
/************************************************************************/
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiGeometry.h
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiGeometry.h 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiGeometry.h 2007-01-29 19:43:26 UTC (rev 681)
@@ -41,6 +41,9 @@
FdoFgfMultiGeometry(FdoFgfGeometryFactory * factory, FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+ // Support object re-use, matching the constructor.
+ void Reset(FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+
~FdoFgfMultiGeometry();
// From FdoIGeometry
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiLineString.cpp
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiLineString.cpp 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiLineString.cpp 2007-01-29 19:43:26 UTC (rev 681)
@@ -65,11 +65,21 @@
const FdoByte * data,
FdoInt32 count
)
- : FdoFgfGeometryImpl<FdoIMultiLineString>(factory, byteArray, data, count)
+ : FdoFgfGeometryImpl<FdoIMultiLineString>(factory)
{
+ Reset(byteArray, data, count);
}
+void FdoFgfMultiLineString::Reset(
+ FdoByteArray * byteArray,
+ const FdoByte * data,
+ FdoInt32 count
+ )
+{
+ SetFgf(byteArray, data, count);
+}
+
/************************************************************************/
/* Destructor */
/************************************************************************/
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiLineString.h
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiLineString.h 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiLineString.h 2007-01-29 19:43:26 UTC (rev 681)
@@ -42,6 +42,9 @@
FdoFgfMultiLineString(FdoFgfGeometryFactory * factory, FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+ // Support object re-use, matching the constructor.
+ void Reset(FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+
~FdoFgfMultiLineString();
// From FdoIGeometry
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiPoint.cpp
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiPoint.cpp 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiPoint.cpp 2007-01-29 19:43:26 UTC (rev 681)
@@ -118,12 +118,22 @@
const FdoByte * data,
FdoInt32 count
)
- : FdoFgfGeometryImpl<FdoIMultiPoint>(factory, byteArray, data, count),
+ : FdoFgfGeometryImpl<FdoIMultiPoint>(factory),
m_ordinates(NULL)
{
+ Reset(byteArray, data, count);
}
+void FdoFgfMultiPoint::Reset(
+ FdoByteArray * byteArray,
+ const FdoByte * data,
+ FdoInt32 count
+ )
+{
+ SetFgf(byteArray, data, count);
+}
+
/************************************************************************/
/* Destructor */
/************************************************************************/
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiPoint.h
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiPoint.h 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiPoint.h 2007-01-29 19:43:26 UTC (rev 681)
@@ -42,6 +42,9 @@
FdoFgfMultiPoint(FdoFgfGeometryFactory * factory, FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+ // Support object re-use, matching the constructor.
+ void Reset(FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+
~FdoFgfMultiPoint();
// From FdoIGeometry
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiPolygon.cpp
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiPolygon.cpp 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiPolygon.cpp 2007-01-29 19:43:26 UTC (rev 681)
@@ -61,11 +61,21 @@
const FdoByte * data,
FdoInt32 count
)
- : FdoFgfGeometryImpl<FdoIMultiPolygon>(factory, byteArray, data, count)
+ : FdoFgfGeometryImpl<FdoIMultiPolygon>(factory)
{
+ Reset(byteArray, data, count);
}
+void FdoFgfMultiPolygon::Reset(
+ FdoByteArray * byteArray,
+ const FdoByte * data,
+ FdoInt32 count
+ )
+{
+ SetFgf(byteArray, data, count);
+}
+
/************************************************************************/
/* Destructor */
/************************************************************************/
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiPolygon.h
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiPolygon.h 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/MultiPolygon.h 2007-01-29 19:43:26 UTC (rev 681)
@@ -41,6 +41,9 @@
FdoFgfMultiPolygon(FdoFgfGeometryFactory * factory, FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+ // Support object re-use, matching the constructor.
+ void Reset(FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+
~FdoFgfMultiPolygon();
// From FdoIGeometry
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Point.cpp
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Point.cpp 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Point.cpp 2007-01-29 19:43:26 UTC (rev 681)
@@ -86,11 +86,22 @@
const FdoByte * data,
FdoInt32 count
)
- : FdoFgfGeometryImpl<FdoIPoint>(factory, byteArray, data, count)
+ : FdoFgfGeometryImpl<FdoIPoint>(factory)
{
+ Reset(byteArray, data, count);
}
+void FdoFgfPoint::Reset(
+ FdoByteArray * byteArray,
+ const FdoByte * data,
+ FdoInt32 count
+ )
+{
+ SetFgf(byteArray, data, count);
+}
+
+
/************************************************************************/
/* Destructor */
/************************************************************************/
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Point.h
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Point.h 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Point.h 2007-01-29 19:43:26 UTC (rev 681)
@@ -46,9 +46,12 @@
// Just latch onto the data stream.
FdoFgfPoint(FdoFgfGeometryFactory * factory, FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
- virtual ~FdoFgfPoint();
+ // Support object re-use, matching the constructor.
+ void Reset(FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+ virtual ~FdoFgfPoint();
+
// From FdoIGeometry
virtual FdoIEnvelope* GetEnvelope() const;
virtual FdoInt32 GetDimensionality() const;
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Polygon.cpp
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Polygon.cpp 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Polygon.cpp 2007-01-29 19:43:26 UTC (rev 681)
@@ -71,11 +71,21 @@
const FdoByte * data,
FdoInt32 count
)
- : FdoFgfGeometryImpl<FdoIPolygon>(factory, byteArray, data, count)
+ : FdoFgfGeometryImpl<FdoIPolygon>(factory)
{
+ Reset(byteArray, data, count);
}
+void FdoFgfPolygon::Reset(
+ FdoByteArray * byteArray,
+ const FdoByte * data,
+ FdoInt32 count
+ )
+{
+ SetFgf(byteArray, data, count);
+}
+
/************************************************************************/
/* Destructor */
/************************************************************************/
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Polygon.h
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Polygon.h 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Polygon.h 2007-01-29 19:43:26 UTC (rev 681)
@@ -42,6 +42,9 @@
FdoFgfPolygon(FdoFgfGeometryFactory * factory, FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+ // Support object re-use, matching the constructor.
+ void Reset(FdoByteArray * byteArray, const FdoByte * data, FdoInt32 count);
+
virtual ~FdoFgfPolygon();
// FdoIGeometry
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Pool.h
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Pool.h 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Pool.h 2007-01-29 19:43:26 UTC (rev 681)
@@ -67,38 +67,52 @@
{
FdoInt32 freeIndex = -1;
FdoInt32 reusableIndex = -1;
+ FdoInt32 startIndex = m_LastVisitedIndex+1;
FdoPtr<OBJ> reusableItem;
- FdoInt32 startIndex = m_LastVisitedIndex+1;
FdoInt32 count = FdoCollection <OBJ, EXC>::GetCount();
- // Nothing notably clever here -- linear search for free entry, also
- // noting a re-usable item, if found.
- for (FdoInt32 i=startIndex; -1 == freeIndex && i < count; i++)
+ // Nothing notably clever here -- linear search for re-usable item, also
+ // noting a free entry, if found.
+ for (FdoInt32 i=startIndex; -1 == reusableIndex && i < count; i++)
{
FdoPtr<OBJ> candidate = FdoCollection<OBJ, EXC>::GetItem(i);
- if (candidate == NULL)
- freeIndex = i;
- else if (-1 == reusableIndex && 2 == GET_REFCOUNT(candidate.p)) // '2' == 1 for cache + 1 for 'candidate'
+ if (candidate != NULL && -1 == reusableIndex && 2 == GET_REFCOUNT(candidate.p)) // '2' == 1 for cache + 1 for 'candidate'
{
reusableIndex = i;
reusableItem = candidate;
}
+ else if (candidate == NULL && -1 == freeIndex)
+ {
+ freeIndex = i;
+ }
}
- // Roll around to start of array if needed.
- for (FdoInt32 i=0; -1 == freeIndex && i < startIndex; i++)
+ for (FdoInt32 i=0; -1 == reusableIndex && i < startIndex; i++)
{
- FdoPtr<OBJ> candidate = FdoCollection <OBJ, EXC>::GetItem(i);
- if (candidate == NULL)
- freeIndex = i;
- else if (-1 == reusableIndex && 2 == GET_REFCOUNT(candidate.p))
+ FdoPtr<OBJ> candidate = FdoCollection<OBJ, EXC>::GetItem(i);
+ if (candidate != NULL && -1 == reusableIndex && 2 == GET_REFCOUNT(candidate.p)) // '2' == 1 for cache + 1 for 'candidate'
{
reusableIndex = i;
reusableItem = candidate;
}
+ else if (candidate == NULL && -1 == freeIndex)
+ {
+ freeIndex = i;
+ }
}
- if (-1 != freeIndex)
+ if (reusableItem != NULL)
{
+ // We found a re-usable item.
+ // Remember where we found it and release our ownership.
+ m_LastVisitedIndex = reusableIndex;
+ FDO_SAFE_ADDREF(reusableItem.p); // This increases share for the return value.
+ FdoCollection<OBJ, EXC>::SetItem(reusableIndex, NULL);
+#ifdef EXTRA_DEBUG
+ m_ReusableHits++;
+#endif
+ }
+ else if (-1 != freeIndex)
+ {
// We found an empty entry in the cache. We'll return NULL,
// and internally remember where we found the entry for when
// the caller calls AddItem().
@@ -108,22 +122,13 @@
m_EmptyHits++;
#endif
}
- else if (reusableItem != NULL)
- {
- // We found no empty entry, but did find a re-usable item.
- // Remember where we found it and release our ownership.
- m_LastVisitedIndex = reusableIndex;
- FDO_SAFE_ADDREF(reusableItem.p); // This increases share for the return value.
- FdoCollection<OBJ, EXC>::SetItem(reusableIndex, NULL);
-#ifdef EXTRA_DEBUG
- m_ReusableHits++;
-#endif
- }
else
{
- // We didn't find anything we wanted. Release the entry
- // where we started. We should pick it up as free when the
- // caller calls AddItem().
+ // We didn't find anything we wanted. Release the next entry,
+ // effecting a round-robin procedure for a full pool.
+ m_LastVisitedIndex++;
+ if (m_LastVisitedIndex >= count)
+ m_LastVisitedIndex = 0;
FdoCollection<OBJ, EXC>::SetItem(m_LastVisitedIndex, NULL);
#ifdef EXTRA_DEBUG
m_Misses++;
@@ -231,5 +236,33 @@
} \
};
+#define FDOPOOL_CREATE_OBJECT( pool_I, poolType_I, poolSize_I, objectType_I, constructorCall_I, resetCall_I ) \
+{ \
+ if ((pool_I) == NULL) \
+ (pool_I) = poolType_I::Create(poolSize_I); \
+ objectType_I * ret = (pool_I)->FindReusableItem(); \
+ if (NULL == ret) \
+ { \
+ try \
+ { \
+ ret = new constructorCall_I; \
+ if ( NULL == ret ) throw; \
+ } \
+ catch (...) \
+ { \
+ throw FdoException::Create(FdoException::NLSGetMessage(FDO_NLSID(FDO_1_BADALLOC))); \
+ } \
+ } \
+ else /* Re-use an object from the pool.*/ \
+ { \
+ ret->resetCall_I; \
+ } \
+ \
+ (pool_I)->AddItem(ret); \
+ \
+ return ret; \
+}
+
+
#endif
Modified: trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Util.cpp
===================================================================
--- trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Util.cpp 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Geometry/Fgf/Util.cpp 2007-01-29 19:43:26 UTC (rev 681)
@@ -30,6 +30,8 @@
FdoInt32 dimensionality = 0;
FdoInt32 numPositions = 0;
FdoInt32 numOrdsPerPos = 0;
+ FdoInt32 numOrds = 0;
+ const double * ordinates = NULL;
FdoInt32 numRings = 0;
FdoInt32 numSubGeometries = 0;
FdoInt32 numCurveSegments = 0;
@@ -60,19 +62,21 @@
numPositions = ls->GetCount();
FGFUTIL_WRITE_INT32(outputStream, dimensionality);
FGFUTIL_WRITE_INT32(outputStream, numPositions);
- for (i=0; i < numPositions; i++)
- {
- FdoPtr<FdoIDirectPosition> pos = ls->GetItem(i);
- WriteDirectPosition(outputStream, pos);
- }
+ numOrdsPerPos = GeometryUtility::DimensionalityToNumOrdinates(dimensionality);
+ numOrds = numPositions * numOrdsPerPos;
+ ordinates = ls->GetOrdinates();
+ FGFUTIL_WRITE_DOUBLES(outputStream, numOrds, ordinates);
break;
case FdoGeometryType_Point:
pt = static_cast<FdoIPoint *>(geometry);
dimensionality = pt->GetDimensionality();
+ numPositions = 1;
FGFUTIL_WRITE_INT32(outputStream, dimensionality);
- pos = pt->GetPosition();
- WriteDirectPosition(outputStream, pos);
+ numOrdsPerPos = GeometryUtility::DimensionalityToNumOrdinates(dimensionality);
+ numOrds = numPositions * numOrdsPerPos;
+ ordinates = pt->GetOrdinates();
+ FGFUTIL_WRITE_DOUBLES(outputStream, numOrds, ordinates);
break;
case FdoGeometryType_Polygon:
@@ -202,14 +206,12 @@
{
// Write the number of positions in this ring
FdoInt32 numPositions = lineRing->GetCount();
+ FdoInt32 dimensionality = lineRing->GetDimensionality();
FGFUTIL_WRITE_INT32(outputStream, numPositions);
-
- // Now write the positions
- for (FdoInt32 i=0; i<numPositions; i++)
- {
- FdoPtr<FdoIDirectPosition> pos = lineRing->GetItem(i);
- WriteDirectPosition(outputStream, pos);
- }
+ FdoInt32 numOrdsPerPos = GeometryUtility::DimensionalityToNumOrdinates(dimensionality);
+ FdoInt32 numOrds = numPositions * numOrdsPerPos;
+ const double * ordinates = lineRing->GetOrdinates();
+ FGFUTIL_WRITE_DOUBLES(outputStream, numOrds, ordinates);
}
@@ -285,18 +287,16 @@
// we will write numPositions-1 because its start position
// has already been written as end point of previous segment
// and we will be writing numPosition-1 positions in fgf buffer
- FdoInt32 numPositions = ((FdoILineStringSegment*)curveSeg)->GetCount();
+ FdoILineStringSegment * lss = (FdoILineStringSegment*)curveSeg;
+ FdoInt32 dimensionality = lss->GetDimensionality();
+ FdoInt32 numPositions = lss->GetCount();
FGFUTIL_WRITE_INT32(outputStream, numPositions-1);
+ FdoInt32 numOrdsPerPos = GeometryUtility::DimensionalityToNumOrdinates(dimensionality);
+ FdoInt32 numOrds = (numPositions-1) * numOrdsPerPos;
+ const double * ordinates = lss->GetOrdinates();
+ ordinates += numOrdsPerPos;
+ FGFUTIL_WRITE_DOUBLES(outputStream, numOrds, ordinates);
- // Only the points except the startpoint will be written because the startpoint is
- // already stored as member of CurveString or as end point of previous
- // segment NOTE: i==1 below.
- for (FdoInt32 i=1; i<numPositions; i++)
- {
- FdoPtr<FdoIDirectPosition> pos = ((FdoILineStringSegment*)curveSeg)->GetItem(i);
- WriteDirectPosition(outputStream, pos);
- }
-
break;
}
default:
@@ -473,19 +473,27 @@
case FdoGeometryComponentType_LineStringSegment:
{
FdoInt32 numPositions = ReadInt32(inputStream, streamEnd);
- FdoPtr<FdoDirectPositionCollection> positions = FdoDirectPositionCollection::Create();
+ FdoInt32 numOrdsPerPos = GeometryUtility::DimensionalityToNumOrdinates(dimensionality);
+ FdoInt32 numOrds = (numPositions+1) * numOrdsPerPos;
+ FdoPtr<FdoDoubleArray> da = FdoDoubleArray::Create(numOrds);
+ double * ordinates = da->GetData();
+ double * currentOrdinates = ordinates;
+ const double * positionOrdinates = startPos->GetOrdinates();
// add the startPos
- positions->Add(startPos);
+ for (FdoInt32 i=0; i < numOrdsPerPos; i++)
+ *currentOrdinates++ = *positionOrdinates++;
// Now add remaining positions
- for (FdoInt32 i=0; i<numPositions; i++)
- {
- FdoPtr<FdoIDirectPosition> pos = ReadDirectPosition(factory, dimensionality, inputStream, streamEnd);
- positions->Add(pos);
- }
+ numOrds -= numOrdsPerPos; // Adjust for already having start position.
+ FGFUTIL_STREAM_CHECK(inputStream, streamEnd, numOrds);
+ positionOrdinates = (const double *) *inputStream;
+ for (FdoInt32 i=0; i < numOrds; i++)
+ *currentOrdinates++ = *positionOrdinates++;
+ *inputStream += numOrds * sizeof(double);
+ numOrds += numOrdsPerPos; // Adjust for start position + remaining ones.
- curveSeg = factory->CreateLineStringSegment(positions);
+ curveSeg = factory->CreateLineStringSegment(dimensionality, numOrds, ordinates);
break;
}
Modified: trunk/Fdo/Unmanaged/Src/Spatial/SpatialUtility.cpp
===================================================================
--- trunk/Fdo/Unmanaged/Src/Spatial/SpatialUtility.cpp 2007-01-26 19:25:27 UTC (rev 680)
+++ trunk/Fdo/Unmanaged/Src/Spatial/SpatialUtility.cpp 2007-01-29 19:43:26 UTC (rev 681)
@@ -1,6 +1,6 @@
/*
*
-* Copyright (C) 2004-2006 Autodesk, Inc.
+* Copyright (C) 2004-2007 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
@@ -1646,7 +1646,11 @@
int dim;
GET_POSITION(pt, &x, &y, &dim);
- return PointInPolygon(poly, x, y);
+ bool isOnExtBoundary = false;
+ bool isInside = PointInPolygon(poly, x, y, &isOnExtBoundary);
+ if (isOnExtBoundary)
+ isInside = !strictInside;
+ return isInside;
}
case FdoGeometryType_LineString :
return PolygonContainsLineString(poly, (FdoILineString*)geom, strictInside);
More information about the fdo-commits
mailing list