[mapguide-commits] r5109 - in sandbox/rfc94/Common:
CoordinateSystem Geometry Geometry/CoordinateSystem
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri Sep 3 09:07:28 EDT 2010
Author: baertelchen
Date: 2010-09-03 13:07:28 +0000 (Fri, 03 Sep 2010)
New Revision: 5109
Added:
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDefParams.cpp
Modified:
sandbox/rfc94/Common/CoordinateSystem/CoordSysDictionaryBase.cpp
sandbox/rfc94/Common/CoordinateSystem/CoordSysDictionaryBase.h
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticAnalyticalTransformDefParams.cpp
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticAnalyticalTransformDefParams.h
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticInterpolationTransformDefParams.cpp
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticInterpolationTransformDefParams.h
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticMultipleRegressionTransformDefParams.cpp
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticMultipleRegressionTransformDefParams.h
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPath.cpp
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPath.h
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPathDictionary.cpp
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPathElement.cpp
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPathElement.h
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDef.cpp
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDef.h
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDefDictionary.cpp
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDefParams.h
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformGridFile.cpp
sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformGridFile.h
sandbox/rfc94/Common/CoordinateSystem/CoordSysMacro.h
sandbox/rfc94/Common/CoordinateSystem/MentorDictionary.h
sandbox/rfc94/Common/CoordinateSystem/MentorUtil.cpp
sandbox/rfc94/Common/CoordinateSystem/MentorUtil.h
sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticPath.h
sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticPathElement.h
sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformDef.h
sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformDefParams.h
sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformGridFile.h
sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformGridFileFormat.h
sandbox/rfc94/Common/Geometry/Geometry.vcproj
Log:
Added IsValid() methods to all of the new Mg API types like Mg*GeodeticTransformationDef, Mg*GeodeticTransformationPath, etc. At the moment, there's no cs_gpchk method yet + it's not clear yet, what exactly cs_gxchk will be checking. We'll have to amend to the IsValid() implementations once we know all that.
Please note, that the cs_gxchk method isn't currently exported by csmap.lib. TO be fixed.
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysDictionaryBase.cpp
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysDictionaryBase.cpp 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysDictionaryBase.cpp 2010-09-03 13:07:28 UTC (rev 5109)
@@ -157,11 +157,12 @@
MG_TRY()
+ //::UpdateDef will lock the (file) resource via [SmartCriticalClass critical(true);]
MentorDictionary::UpdateDef<U, T>(
this->dictionaryItems, /* can be null in case no enumerator has been created yet or this dictionary isn't set up for caching */
definitionAccess->readDefinitionName,
definitionAccess->readDefinitionDescription,
- NULL, /* IsValid() callback */ //ABA; TBD
+ definitionAccess->validateDefinition,
definitionAccess->readDefinition,
definitionAccess->updateDefinition,
definitionAccess->setupCsStructFromMgInstance,
@@ -199,6 +200,8 @@
MG_TRY()
+ //::UpdateDef will lock the (file) resource via [SmartCriticalClass critical(true);]
+
//we don't pass our [this->items] here, as the dictionary is accessed anyway;
//if the caller passes us an unknown definition, we'll fail anyway
//with an exception what is per se slower than having success here
@@ -206,7 +209,7 @@
this->dictionaryItems, /* can be null in case no enumerator has been created yet or this dictionary isn't set up for caching */
definitionAccess->readDefinitionName,
definitionAccess->readDefinitionDescription,
- NULL, /* IsValid() callback */ //ABA; TBD
+ definitionAccess->validateDefinition,
definitionAccess->readDefinition,
definitionAccess->updateDefinition,
definitionAccess->setupCsStructFromMgInstance,
@@ -225,13 +228,13 @@
//Get the name to search for
pName = Convert_Wide_To_Ascii(sName.c_str()); //need to delete [] pName
- if (NULL == pName) //ABA: ???
- throw new MgOutOfMemoryException(L"CCoordinateSystemDictionaryBase.Get", __LINE__, __WFILE__, NULL, L"", NULL);
-
Ptr<T> pDefinition;
MG_TRY()
+ //make sure, we've exclusive access here
+ SmartCriticalClass critical(true);
+
//Look in the dictionary
pDef = definitionAccess->readDefinition(pName);
if (NULL == pDef)
@@ -266,35 +269,25 @@
DICTIONARY_BASE_TEMPLATE
bool DICTIONARY_BASE_TEMPLATE_METHOD::Has(CREFSTRING sName)
{
- bool bHas = false;
- char *pName = NULL;
-
MG_TRY()
+
+ try
+ {
+ Ptr<MgGuardDisposable> definition = this->Get(sName);
+ _ASSERT(NULL != definition);
- //Get the name to search for
- pName = Convert_Wide_To_Ascii(sName.c_str()); //need to delete [] pName
- if (NULL == pName) //ABA: ???
- throw new MgOutOfMemoryException(L"CCoordinateSystemDictionaryBase.Has", __LINE__, __WFILE__, NULL, L"", NULL);
-
- //Look in the dictionary
- U *pDef = definitionAccess->readDefinition(pName);
- if (NULL != pDef)
+ return NULL != definition;
+ }
+ catch(MgCoordinateSystemLoadFailedException* loadFailedException)
{
- bHas = true;
-
- CS_free(pDef);
- pDef = NULL;
-
- //make sure, we're deleting [pName]
+ loadFailedException->Release();
+ return false;
}
- MG_CATCH(L"CCoordinateSystemDictionaryBase.Has")
-
- delete [] pName;
-
- MG_THROW()
-
- return bHas;
+ MG_CATCH_AND_THROW(L"CCoordinateSystemDictionaryBase.Has")
+
+ _ASSERT(false);
+ return false;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysDictionaryBase.h
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysDictionaryBase.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysDictionaryBase.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -37,6 +37,7 @@
U* (*ReadDefinition)(const char* definitionKey), //reads a definition from a dictionary file; the caller is responsible for freeing the returned object
int (*UpdateDefinition)(U* definition, int), //updates the definition in the dictionary file
int (*DeleteDefinition)(U* definition), //deletes the definition in the dictionary file
+ bool (T::*ValidateDefinition)(), //validates a definition; this method is called on the Mg interface
bool (*SetupCsStructFromMgInstance)(T*, U&), //initializes the CS Map API struct (type U) from the Mg API objects (type T)
void (*FullInitialize)(T*, U*, MgCoordinateSystemCatalog* catalog), //fully initializes the Mg API objects from the CS Map API struct
const char* (*ReadDefinitionName)(const U& definition), //reads the definition's name; the caller has to copy the string's content
@@ -49,6 +50,8 @@
updateDefinition(UpdateDefinition),
deleteDefinition(DeleteDefinition),
+ validateDefinition(ValidateDefinition),
+
setupCsStructFromMgInstance(SetupCsStructFromMgInstance),
fullInitialize(FullInitialize),
@@ -65,6 +68,7 @@
U* (*readDefinition)(const char* definitionKey);
int (*updateDefinition)(U* definition, int);
int (*deleteDefinition)(U* definition);
+ bool (T::*validateDefinition)();
bool (*setupCsStructFromMgInstance)(T*, U&);
void (*fullInitialize)(T*, U*, MgCoordinateSystemCatalog* catalog);
const char* (*readDefinitionName)(const U& definition);
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticAnalyticalTransformDefParams.cpp
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticAnalyticalTransformDefParams.cpp 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticAnalyticalTransformDefParams.cpp 2010-09-03 13:07:28 UTC (rev 5109)
@@ -29,8 +29,8 @@
using namespace CSLibrary;
-CCoordinateSystemGeodeticAnalyticalTransformDefParams::CCoordinateSystemGeodeticAnalyticalTransformDefParams(const csGeocentricXformParams& params)
- : geocentricTransformParams(NULL)
+CCoordinateSystemGeodeticAnalyticalTransformDefParams::CCoordinateSystemGeodeticAnalyticalTransformDefParams(const csGeocentricXformParams& params, bool isProtected)
+ : CCoordinateSystemGeodeticTransformDefParams(isProtected), geocentricTransformParams(NULL)
{
this->geocentricTransformParams = (csGeocentricXformParams*) CS_malc(sizeof(csGeocentricXformParams));
if (NULL == this->geocentricTransformParams)
@@ -65,6 +65,18 @@
memcpy(target, this->geocentricTransformParams, sizeof(cs_GeodeticTransform_::csGeodeticXformParameters::csGeodeticXformParmsGeocentric));
}
+bool CCoordinateSystemGeodeticAnalyticalTransformDefParams::IsValid()
+{
+ //we're relying on the CS_gxchk() method that will be invoked, before the parent transformation
+ //definition is finally passed to CS_Map
+ return true;
+}
+
+bool CCoordinateSystemGeodeticAnalyticalTransformDefParams::IsProtected()
+{
+ return CCoordinateSystemGeodeticTransformDefParams::IsProtected();
+}
+
DEFINE_GET_SET_NUMERIC(CCoordinateSystemGeodeticAnalyticalTransformDefParams,DeltaX,double,this->geocentricTransformParams->deltaX)
DEFINE_GET_SET_NUMERIC(CCoordinateSystemGeodeticAnalyticalTransformDefParams,DeltaY,double,this->geocentricTransformParams->deltaY)
DEFINE_GET_SET_NUMERIC(CCoordinateSystemGeodeticAnalyticalTransformDefParams,DeltaZ,double,this->geocentricTransformParams->deltaZ)
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticAnalyticalTransformDefParams.h
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticAnalyticalTransformDefParams.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticAnalyticalTransformDefParams.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -26,16 +26,17 @@
public MgCoordinateSystemGeodeticAnalyticalTransformDefParams,
public CCoordinateSystemGeodeticTransformDefParams
{
-
public:
- CCoordinateSystemGeodeticAnalyticalTransformDefParams(const csGeocentricXformParams& params);
+ CCoordinateSystemGeodeticAnalyticalTransformDefParams(const csGeocentricXformParams& params, bool isProtected);
~CCoordinateSystemGeodeticAnalyticalTransformDefParams();
virtual void Dispose();
+ virtual bool IsValid();
+ virtual bool IsProtected();
+
virtual void CopyTo(void* target) const;
-
//MgCoordinateSystemGeodeticAnalyticalTransformDefParams implementation
virtual double GetDeltaX();
virtual void SetDeltaX(double deltaX);
@@ -69,7 +70,6 @@
private:
void ReleaseInstance();
- bool IsProtected() { return false; }
private:
csGeocentricXformParams* geocentricTransformParams;
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticInterpolationTransformDefParams.cpp
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticInterpolationTransformDefParams.cpp 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticInterpolationTransformDefParams.cpp 2010-09-03 13:07:28 UTC (rev 5109)
@@ -34,8 +34,8 @@
using namespace CSLibrary;
CCoordinateSystemGeodeticInterpolationTransformDefParams::CCoordinateSystemGeodeticInterpolationTransformDefParams(
- const csGridFileXformParams& params)
- : gridFileParams(NULL)
+ const csGridFileXformParams& params, bool isProtected)
+ : CCoordinateSystemGeodeticTransformDefParams(isProtected), gridFileParams(NULL)
{
this->Reset();
*this->gridFileParams = params;
@@ -73,27 +73,34 @@
void CCoordinateSystemGeodeticInterpolationTransformDefParams::SetGridFiles(MgDisposableCollection* gridFiles)
{
- VERIFY_INITIALIZED(CCoordinateSystemGeodeticInterpolationTransformDefParams::SetGridFileNames);
+ VERIFY_INITIALIZED(L"CCoordinateSystemGeodeticInterpolationTransformDefParams.SetGridFiles");
+ VERIFY_NOT_PROTECTED(L"CCoordinateSystemGeodeticInterpolationTransformDefParams.SetGridFiles");
//we don't take ownership over fileNames
ENSURE_NOT_NULL(gridFiles, CCoordinateSystemGeodeticInterpolationTransformDefParams::SetGridFileNames);
const INT32 fileNamesCount = gridFiles->GetCount();
if (fileNamesCount > csGRIDI1_FILEMAX)
- throw new MgInvalidArgumentException(L"CCoordinateSystemGeodeticInterpolationTransformDefParams.SetGridFileNames", __LINE__, __WFILE__, NULL, L"", NULL);
+ throw new MgInvalidArgumentException(L"CCoordinateSystemGeodeticInterpolationTransformDefParams.SetGridFiles", __LINE__, __WFILE__, NULL, L"", NULL);
- csGridFileXFormat* allFiles = new csGridFileXFormat[fileNamesCount];
+ bool emptyFileCollection = (0 == fileNamesCount);
+ csGridFileXFormat* allFiles = emptyFileCollection ? NULL : new csGridFileXFormat[fileNamesCount];
MG_TRY()
- memset(allFiles, 0, fileNamesCount * sizeof(csGridFileXFormat));
+ if (!emptyFileCollection)
+ memset(allFiles, 0, fileNamesCount * sizeof(csGridFileXFormat));
for(INT32 i = 0; i < fileNamesCount; i++)
{
- Ptr<MgDisposable> gridFile = gridFiles->GetItem(i);
+ Ptr<MgDisposable> gridFile = gridFiles->GetItem(i); //calls [AddRef] on the item being returned
CCoordinateSystemGeodeticTransformGridFile* gridFileSetting = dynamic_cast<CCoordinateSystemGeodeticTransformGridFile*>(gridFile.p);
if (NULL == gridFileSetting)
- throw new MgInvalidArgumentException(L"CCoordinateSystemGeodeticInterpolationTransformDefParams.SetGridFileNames", __LINE__, __WFILE__, NULL, L"", NULL);
+ throw new MgInvalidArgumentException(L"CCoordinateSystemGeodeticInterpolationTransformDefParams.SetGridFiles", __LINE__, __WFILE__, NULL, L"", NULL);
+ //we only allow for setting valid grid files
+ if (!gridFileSetting->IsValid())
+ throw new MgInvalidArgumentException(L"CCoordinateSystemGeodeticInterpolationTransformDefParams.SetGridFiles", __LINE__, __WFILE__, NULL, L"", NULL);
+
//take the values from the settings we have been passed here and set our internal
//[csGridFileXFormat] instance at index [i] to those values
gridFileSetting->CopyTo(&allFiles[i]);
@@ -103,12 +110,13 @@
//wipe out all memory where the filenames are stored...
memset(this->gridFileParams->fileNames, 0, csGRIDI1_FILEMAX * sizeof(csGridFileXFormat));
- //...and copy our values in
- memcpy(this->gridFileParams->fileNames, allFiles, fileNamesCount * sizeof(csGridFileXFormat));
+ //...and copy our values in case we've been given a non-empty list
+ if (!emptyFileCollection)
+ memcpy(this->gridFileParams->fileNames, allFiles, fileNamesCount * sizeof(csGridFileXFormat));
MG_CATCH(L"CCoordinateSystemGeodeticInterpolationTransformDefParams.SetGridFileNames");
- delete[] allFiles;
+ delete[] allFiles; //safe to call on [null]
MG_THROW();
}
@@ -126,7 +134,7 @@
csGridFileXFormat& singleGridFile = this->gridFileParams->fileNames[i];
Ptr<CCoordinateSystemGeodeticTransformGridFile> gridFileSetting =
- new CCoordinateSystemGeodeticTransformGridFile(&singleGridFile);
+ new CCoordinateSystemGeodeticTransformGridFile(&singleGridFile, this->IsProtected());
//the collection will take ownership over [gridFileSetting]
gridFileNames->Add(gridFileSetting);
@@ -137,9 +145,39 @@
MgCoordinateSystemGeodeticTransformGridFile* CCoordinateSystemGeodeticInterpolationTransformDefParams::NewGridFile()
{
- return new CCoordinateSystemGeodeticTransformGridFile(NULL);
+ return new CCoordinateSystemGeodeticTransformGridFile(NULL, false);
}
+bool CCoordinateSystemGeodeticInterpolationTransformDefParams::IsValid()
+{
+ if (NULL == this->gridFileParams)
+ return false;
+
+ Ptr<MgDisposableCollection> gridFiles = this->GetGridFiles();
+ INT32 gridFileCount = gridFiles->GetCount();
+ if (gridFileCount > csGRIDI1_FILEMAX)
+ return false;
+
+ for (INT32 i = 0; i < gridFileCount; i++)
+ {
+ Ptr<MgDisposable> gridFilePtr = gridFiles->GetItem(i);
+ MgCoordinateSystemGeodeticTransformGridFile* gridFile = dynamic_cast<MgCoordinateSystemGeodeticTransformGridFile*>(gridFilePtr.p);
+
+ if (NULL == gridFile || !gridFile->IsValid())
+ {
+ _ASSERT(false); //how comes? This can only have happened when we initialized this item here
+ return false;
+ }
+ }
+
+ return true; //0 items count is ok
+}
+
+bool CCoordinateSystemGeodeticInterpolationTransformDefParams::IsProtected()
+{
+ return CCoordinateSystemGeodeticTransformDefParams::IsProtected();
+}
+
DEFINE_GET_SET_STRING(CCoordinateSystemGeodeticInterpolationTransformDefParams,Fallback,this->gridFileParams->fallback)
void CCoordinateSystemGeodeticInterpolationTransformDefParams::CopyTo(void* target) const
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticInterpolationTransformDefParams.h
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticInterpolationTransformDefParams.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticInterpolationTransformDefParams.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -28,7 +28,7 @@
public CCoordinateSystemGeodeticTransformDefParams
{
public:
- CCoordinateSystemGeodeticInterpolationTransformDefParams(const csGridFileXformParams& params);
+ CCoordinateSystemGeodeticInterpolationTransformDefParams(const csGridFileXformParams& params, bool isProtected);
~CCoordinateSystemGeodeticInterpolationTransformDefParams();
// >>> MgCoordinateSystemGeodeticInterpolationTransformDefParams
@@ -42,7 +42,9 @@
// <<< MgCoordinateSystemGeodeticInterpolationTransformDefParams
- virtual bool IsProtected() { return false; };
+ virtual bool IsValid(); //from MgCoordinateSystemGeodeticTransformDefParams
+ virtual bool IsProtected();
+
virtual void Dispose();
private:
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticMultipleRegressionTransformDefParams.cpp
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticMultipleRegressionTransformDefParams.cpp 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticMultipleRegressionTransformDefParams.cpp 2010-09-03 13:07:28 UTC (rev 5109)
@@ -34,8 +34,8 @@
using namespace CSLibrary;
CCoordinateSystemGeodeticMultipleRegressionTransformDefParams::CCoordinateSystemGeodeticMultipleRegressionTransformDefParams(
- const csMultipleRegressionXformParams& params)
- : mulRegParams(NULL)
+ const csMultipleRegressionXformParams& params, bool isProtected)
+ : CCoordinateSystemGeodeticTransformDefParams(isProtected), mulRegParams(NULL)
{
this->Reset();
*this->mulRegParams = params;
@@ -78,7 +78,18 @@
memcpy(target, this->mulRegParams, sizeof(csMultipleRegressionXformParams));
}
+bool CCoordinateSystemGeodeticMultipleRegressionTransformDefParams::IsValid()
+{
+ //we're relying on the CS_gxchk() method that will be invoked, before the parent transformation
+ //definition is finally passed to CS_Map
+ return true;
+}
+bool CCoordinateSystemGeodeticMultipleRegressionTransformDefParams::IsProtected()
+{
+ return CCoordinateSystemGeodeticTransformDefParams::IsProtected();
+}
+
//DEFINE_GET_SET_NUMERIC_IDX(CCoordinateSystemGeodeticMultipleRegressionTransformDefParams,PhiBitmap,UINT32,this->mulRegParams->phiBitMap,3)
//DEFINE_GET_SET_NUMERIC_IDX(CCoordinateSystemGeodeticMultipleRegressionTransformDefParams,LambdaBitmap,UINT32,this->mulRegParams->lambdaBitMap,3)
//DEFINE_GET_SET_NUMERIC_IDX(CCoordinateSystemGeodeticMultipleRegressionTransformDefParams,HeightBitmap,UINT32,this->mulRegParams->heightBitMap,3)
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticMultipleRegressionTransformDefParams.h
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticMultipleRegressionTransformDefParams.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticMultipleRegressionTransformDefParams.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -29,11 +29,12 @@
{
public:
- CCoordinateSystemGeodeticMultipleRegressionTransformDefParams(const csMultipleRegressionXformParams& mulRegParams);
+ CCoordinateSystemGeodeticMultipleRegressionTransformDefParams(const csMultipleRegressionXformParams& mulRegParams, bool isProtected);
~CCoordinateSystemGeodeticMultipleRegressionTransformDefParams();
virtual void Dispose();
- virtual bool IsProtected() { return false; };
+ virtual bool IsValid();
+ virtual bool IsProtected();
//virtual UINT32 GetPhiBitmap(INT32 index /* range [0..3]*/); //long compiles as 32 bit in MS VC;
//virtual void SetPhiBitmap(INT32 index, UINT32 value); //long compiles as 32 bit in MS VC;
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPath.cpp
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPath.cpp 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPath.cpp 2010-09-03 13:07:28 UTC (rev 5109)
@@ -24,7 +24,7 @@
#include "CoordSysTransform.h" //for CCoordinateSystemTransform
#include "CoordSysUtil.h" //for CsDictionaryOpenMode
-#include "MentorUtil.h" //for IsLegalMentorName
+#include "MentorDictionary.h"
using namespace CSLibrary;
@@ -76,7 +76,7 @@
MgCoordinateSystemGeodeticPath* CCoordinateSystemGeodeticPath::CreateClone()
{
- VERIFY_INITIALIZED(CCoordinateSystemGeodeticPath::CreateClone);
+ VERIFY_INITIALIZED(L"CCoordinateSystemGeodeticPath.CreateClone");
Ptr<CCoordinateSystemGeodeticPath> clonedPath = new CCoordinateSystemGeodeticPath(NULL);
clonedPath->Initialize(*this->pathDefinition);
@@ -85,12 +85,18 @@
return clonedPath.Detach();
}
+MgCoordinateSystemGeodeticPathElement* CCoordinateSystemGeodeticPath::NewPathElement()
+{
+ return new CCoordinateSystemGeodeticPathElement(NULL, false);
+}
+
void CCoordinateSystemGeodeticPath::CopyTo(cs_GeodeticPath_& pathDef) const
{
- VERIFY_INITIALIZED(CopyTo);
+ VERIFY_INITIALIZED(L"CCoordinateSystemGeodeticPath.CopyTo");
pathDef = *this->pathDefinition;
}
+//helper - don't delete; will be called by MentorUtil / DictionaryUtil
bool CCoordinateSystemGeodeticPath::IsEncrypted()
{
return false;
@@ -98,27 +104,68 @@
bool CCoordinateSystemGeodeticPath::IsProtected()
{
- VERIFY_INITIALIZED(IsProtected);
- return 1 == this->pathDefinition->protect; //ABA: see cs_map; actually 0 does indicate protected...
+ VERIFY_INITIALIZED(L"CCoordinateSystemGeodeticPath.IsProtected");
+ return DICTIONARY_SYS_DEF == this->pathDefinition->protect;
}
+bool CCoordinateSystemGeodeticPath::IsValid()
+{
+ if (NULL == this->pathDefinition)
+ return false;
+
+ //make sure, the names for this path and the datums are set
+ size_t pathNameLength = strlen(this->pathDefinition->pathName);
+ if (0 == pathNameLength || pathNameLength >= sizeof(this->pathDefinition->pathName))
+ return false;
+
+ size_t srcDatumNameLength = strlen(this->pathDefinition->srcDatum);
+ if (0 == srcDatumNameLength || srcDatumNameLength >= sizeof(this->pathDefinition->srcDatum))
+ return false;
+
+ size_t trgDatumNameLength = strlen(this->pathDefinition->trgDatum);
+ if (0 == trgDatumNameLength || trgDatumNameLength >= sizeof(this->pathDefinition->trgDatum))
+ return false;
+
+ //check, whether there are only valid path elements according to MgCoordinateSystemGeodeticPathElement::IsValid()
+ Ptr<MgDisposableCollection> pathElements = this->GetPathElements();
+ INT32 pathElementCount = pathElements->GetCount();
+ if (0 == pathElementCount || pathElementCount > csPATH_MAXXFRM)
+ return false;
+
+ if (pathElementCount != this->pathDefinition->elementCount)
+ return false;
+
+ for(INT32 i = 0; i < pathElementCount; i++)
+ {
+ Ptr<MgDisposable> mgDisposable = pathElements->GetItem(i);
+ MgCoordinateSystemGeodeticPathElement* pathElement = dynamic_cast<MgCoordinateSystemGeodeticPathElement*>(mgDisposable.p);
+ if (NULL == pathElement)
+ throw new MgInvalidArgumentException(L"CCoordinateSystemGeodeticPath.IsValid", __LINE__, __WFILE__, NULL, L"", NULL);
+
+ if (!pathElement->IsValid())
+ return false;
+ }
+
+ //TODO: add gp_gpchk in cs_map.h
+ return true; //for any other stuff, like [accuracy] etc. rely on cs_gpcheck
+}
+
//all getters and setters
MgDisposableCollection* CCoordinateSystemGeodeticPath::GetPathElements()
{
- VERIFY_INITIALIZED(GetPathElements);
+ VERIFY_INITIALIZED(L"CCoordinateSystemGeodeticPath.GetPathElements");
Ptr<MgDisposableCollection> pathElements = new MgDisposableCollection();
const INT32 pathElementCount = this->pathDefinition->elementCount;
- for(int i = 0; i < pathElementCount; i++)
+ for(int i = 0; (i < pathElementCount && i <= csPATH_MAXXFRM); i++)
{
- cs_GeodeticPathElement_ pathElement = this->pathDefinition->geodeticPathElements[i];
- bool isInversed = (1 == pathElement.direction);
- STRING transformName = MentorReadString(pathElement.geodeticXformName);
+ const cs_GeodeticPathElement_ pathElement = this->pathDefinition->geodeticPathElements[i];
- Ptr<CCoordinateSystemGeodeticPathElement> mgPathElement = new CCoordinateSystemGeodeticPathElement(transformName, isInversed);
+ Ptr<CCoordinateSystemGeodeticPathElement> mgPathElement =
+ new CCoordinateSystemGeodeticPathElement(&pathElement, this->IsProtected());
//the elements will be released when the collection is released
pathElements->Add(mgPathElement);
@@ -129,7 +176,8 @@
void CCoordinateSystemGeodeticPath::SetPathElements(MgDisposableCollection* pathElements)
{
- VERIFY_INITIALIZED(CCoordinateSystemGeodeticPath::SetPathElements);
+ VERIFY_INITIALIZED(L"CCoordinateSystemGeodeticPath.SetPathElements");
+ VERIFY_NOT_PROTECTED(L"CCoordinateSystemGeodeticPath.SetPathElements");
ENSURE_NOT_NULL(pathElements, CCoordinateSystemGeodeticPath::SetPathElements);
@@ -137,9 +185,6 @@
if (0 == pathElementCount || pathElementCount > csPATH_MAXXFRM)
throw new MgInvalidArgumentException(L"CCoordinateSystemGeodeticPath.SetPathElements", __LINE__, __WFILE__, NULL, L"", NULL);
- if (this->IsProtected())
- throw new MgCoordinateSystemInitializationFailedException(L"CCoordinateSystemGeodeticPath.SetPathElements", __LINE__, __WFILE__, NULL, L"MgCoordinateSystemProtectedException", NULL);
-
cs_GeodeticPathElement_* validElements = new cs_GeodeticPathElement_[pathElementCount];
MG_TRY()
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPath.h
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPath.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPath.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -34,6 +34,7 @@
void Reset();
virtual MgCoordinateSystemGeodeticPath* CreateClone();
+ virtual MgCoordinateSystemGeodeticPathElement* NewPathElement();
//properties
virtual STRING GetPathName();
@@ -71,7 +72,9 @@
//helper - don't delete
virtual bool IsEncrypted();
+
virtual bool IsProtected();
+ virtual bool IsValid();
void CopyTo(cs_GeodeticPath_& pathDef) const;
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPathDictionary.cpp
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPathDictionary.cpp 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPathDictionary.cpp 2010-09-03 13:07:28 UTC (rev 5109)
@@ -42,6 +42,7 @@
CCoordinateSystemGeodeticPathDictionary::UpdateGeodeticPath, /* CS_gpupd has a different signature than the other CS 'update' methods */
CS_gpdel,
+ &CCoordinateSystemGeodeticPath::IsValid,
CCoordinateSystemGeodeticPathDictionary::SetupCsGeodeticPathStruct,
CCoordinateSystemGeodeticPathDictionary::FullInitialize,
@@ -64,41 +65,6 @@
this->m_pDictionary = NULL;
}
-//Private member function which tries to get a def with the specified
-//name from the file, which is assumed to be already open. If found,
-//returns an allocated def which the caller must free via CS_free().
-//If not found, returns NULL.
-//
-//cs_GeodeticPath_* CCoordinateSystemGeodeticPathDictionary::ReadDefFromFile(const char *pathName) const
-//{
-// ////If the dictionary version is current, we can just
-// ////use the regular function.
-// //if (cs_GPDEF_MAGIC == m_lMagic)
-// //{
-// // SmartCriticalClass critical(true);
-// // return CS_gpdef(pathName);
-// //}
-//
-// //_ASSERT(false);
-// //return NULL;
-//
-// return NULL;
-//}
-
-//cs_GeodeticPath_* CCoordinateSystemGeodeticPathDictionary::ReadDefinition(const char* definitionKey, INT32 dictionaryMagicNumber)
-//{
-// //If the dictionary version is current, we can just
-// //use the regular function.
-// if (cs_GPDEF_MAGIC == dictionaryMagicNumber)
-// {
-// SmartCriticalClass critical(true);
-// return CS_gpdef(definitionKey);
-// }
-//
-// _ASSERT(false);
-// return NULL;
-//}
-
const char* CCoordinateSystemGeodeticPathDictionary::ReadName(const cs_GeodeticPath_& definition)
{
return definition.pathName;
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPathElement.cpp
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPathElement.cpp 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPathElement.cpp 2010-09-03 13:07:28 UTC (rev 5109)
@@ -15,21 +15,32 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-
#include "GeometryCommon.h"
#include "CoordSysCommon.h"
+#include "CriticalSection.h"
#include "CoordSysGeodeticPathElement.h"
+
+#include "CoordSysTransform.h" //for CCoordinateSystemTransform
+#include "CoordSysUtil.h" //for CsDictionaryOpenMode
+#include "MentorDictionary.h"
+
using namespace CSLibrary;
-CCoordinateSystemGeodeticPathElement::CCoordinateSystemGeodeticPathElement(CREFSTRING transformName, bool isInversed)
-: transformName(transformName), isInversed(isInversed)
+#define CS_MAP_DEF_VARIABLE this->pathElement //needed by CoordSysMacro
+
+#include "CoordSysMacro.h" //for DEFINE_GET_SET_STRING and DEFINE_GET_SET_NUMERIC
+
+CCoordinateSystemGeodeticPathElement::CCoordinateSystemGeodeticPathElement(const cs_GeodeticPathElement_* const pathElementArg, bool isProtected)
+ : pathElement(NULL), isProtected(isProtected)
{
+ this->Reset(pathElementArg);
}
CCoordinateSystemGeodeticPathElement::~CCoordinateSystemGeodeticPathElement()
{
+ this->CleanupInstanceVariables();
}
void CCoordinateSystemGeodeticPathElement::Dispose()
@@ -37,22 +48,59 @@
delete this;
}
-STRING CCoordinateSystemGeodeticPathElement::GetTransformName()
+void CCoordinateSystemGeodeticPathElement::CleanupInstanceVariables()
{
- return this->transformName;
+ if (NULL != this->pathElement)
+ {
+ CS_free(this->pathElement);
+ this->pathElement = NULL;
+ }
}
-void CCoordinateSystemGeodeticPathElement::SetTransformName(CREFSTRING transformName)
+void CCoordinateSystemGeodeticPathElement::Reset(const cs_GeodeticPathElement_* const pathElementArg)
{
- this->transformName = transformName;
+ cs_GeodeticPathElement_* tempPathElement = (cs_GeodeticPathElement_*) CS_malc(sizeof(cs_GeodeticPathElement_));
+ if (NULL == tempPathElement)
+ throw new MgOutOfMemoryException(L"CCoordinateSystemGeodeticPathElement.Reset", __LINE__, __WFILE__, NULL, L"", NULL);
+
+ MG_TRY()
+
+ this->CleanupInstanceVariables();
+ if (NULL == pathElementArg) //initialize to 0 memory
+ memset(tempPathElement, 0, sizeof(cs_GeodeticPathElement_));
+ else
+ *tempPathElement = *pathElementArg; //otherwise, copy the values from the arg over
+
+ this->pathElement = tempPathElement; //make us hold the allocated memory...
+ tempPathElement = NULL; //...and make sure, we don't free it below
+
+ MG_CATCH(L"CCoordinateSystemGeodeticPathElement.Reset")
+
+ if (NULL != tempPathElement)
+ CS_free(tempPathElement);
+
+ MG_THROW()
}
-bool CCoordinateSystemGeodeticPathElement::GetIsInversed()
+bool CCoordinateSystemGeodeticPathElement::IsValid()
{
- return this->isInversed;
+ if (NULL == this->pathElement)
+ return false;
+
+ size_t transformNameLength = strlen(this->pathElement->geodeticXformName);
+ _ASSERT(transformNameLength < sizeof(this->pathElement->geodeticXformName)); //how comes?
+
+ //TODO: put transformNameLength 64 in cs_map.h
+ if (0 == transformNameLength || transformNameLength >= sizeof(this->pathElement->geodeticXformName))
+ return false;
+
+ return (cs_PATHDIR_FWD == this->pathElement->direction) || (cs_PATHDIR_INV == this->pathElement->direction);
}
-void CCoordinateSystemGeodeticPathElement::SetIsInversed(bool isInversed)
+bool CCoordinateSystemGeodeticPathElement::IsProtected()
{
- this->isInversed = isInversed;
-}
\ No newline at end of file
+ return this->isProtected;
+}
+
+DEFINE_GET_SET_STRING(CCoordinateSystemGeodeticPathElement,TransformName,this->pathElement->geodeticXformName)
+DEFINE_GET_SET_NUMERIC(CCoordinateSystemGeodeticPathElement,IsInversed,bool,this->pathElement->direction)
\ No newline at end of file
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPathElement.h
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPathElement.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticPathElement.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -21,14 +21,15 @@
namespace CSLibrary
{
-
class CCoordinateSystemGeodeticPathElement : public MgCoordinateSystemGeodeticPathElement
{
public:
- CCoordinateSystemGeodeticPathElement(CREFSTRING transformName, bool isInversed);
+ CCoordinateSystemGeodeticPathElement(const cs_GeodeticPathElement_* const pathElement, bool isProtected);
~CCoordinateSystemGeodeticPathElement();
virtual void Dispose();
+ virtual bool IsValid();
+ virtual bool IsProtected();
virtual STRING GetTransformName();
virtual void SetTransformName(CREFSTRING);
@@ -37,8 +38,12 @@
virtual void SetIsInversed(bool);
private:
- bool isInversed;
- STRING transformName;
+ void Reset(const cs_GeodeticPathElement_* const pathElement);
+ void CleanupInstanceVariables();
+
+ private:
+ bool isProtected;
+ cs_GeodeticPathElement_* pathElement;
};
} //namespace CSLibrary
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDef.cpp
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDef.cpp 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDef.cpp 2010-09-03 13:07:28 UTC (rev 5109)
@@ -27,7 +27,7 @@
#include "CoordSysTransform.h" //for CCoordinateSystemTransform
#include "CoordSysUtil.h" //for CsDictionaryOpenMode
-#include "MentorUtil.h" //for IsLegalMentorName
+#include "MentorDictionary.h"
using namespace CSLibrary;
@@ -81,40 +81,46 @@
if (NULL == newEmptyDef) //uses CS_malc which returns NULL in case allocation fails
throw new MgOutOfMemoryException(L"CCoordinateSystemGeodeticTransformDef.Initialize", __LINE__, __WFILE__, NULL, L"", NULL);
- //ok - did work; release this instance's information
+ MG_TRY()
+
+ //now, 0 our temp memory we've allocated
+ memset ((void*)newEmptyDef, 0, sizeof(cs_GeodeticTransform_));
+
+ //ok - everything worked out so far; release this instance's information
this->ReleaseInstance();
-
- memset ((void*)newEmptyDef, 0, sizeof(cs_GeodeticTransform_));
-
+ _ASSERT(NULL == this->transformDefinition);
+
this->transformDefinition = newEmptyDef;
+ newEmptyDef = NULL; //make sure, we don't free that one after we get a hold on the (no longer temp) memory
+
this->transformationDefType = transformationType;
+
+ MG_CATCH(L"CCoordinateSystemGeodeticTransformDef.Reset")
+
+ if (NULL != newEmptyDef)
+ CS_free(newEmptyDef);
+
+ MG_THROW()
}
-INT32 CCoordinateSystemGeodeticTransformDef::GetTransformationDefType(INT32 methodCode)
+INT32 CCoordinateSystemGeodeticTransformDef::GetTransformationDefType(INT32 methodCode /* method code as read from the dictionary entry; this is not */)
{
INT32 transformationType;
- //the following swtich/case is built from the information found in [CS_gxio.c]
switch(methodCode)
{
- //case MgCoordinateSystemGeodeticTransformationMethod::None:
+ //standalone methods; see information in cs_geodetic.h
case cs_DTCMTH_NULLX:
case cs_DTCMTH_WGS72:
transformationType = MgCoordinateSystemGeodeticTransformDefType::None;
break;
- //case MgCoordinateSystemGeodeticTransformationMethod::MReg:
+ //multiple Regression methods
case cs_DTCMTH_MULRG:
case cs_DTCMTH_PLYNM:
transformationType = MgCoordinateSystemGeodeticTransformDefType::MultipleRegression;
break;
- //case MgCoordinateSystemGeodeticTransformationMethod::Molodensky:
- //case MgCoordinateSystemGeodeticTransformationMethod::Bursa:
- //case MgCoordinateSystemGeodeticTransformationMethod::SevenParameter:
- //case MgCoordinateSystemGeodeticTransformationMethod::ThreeParameter:
- //case MgCoordinateSystemGeodeticTransformationMethod::SixParameter:
- //case MgCoordinateSystemGeodeticTransformationMethod::FourParameter:
- //case MgCoordinateSystemGeodeticTransformationMethod::Geocentric:
+ //geocentric methods
case cs_DTCMTH_3PARM:
case cs_DTCMTH_MOLOD:
case cs_DTCMTH_AMOLO:
@@ -128,18 +134,7 @@
transformationType = MgCoordinateSystemGeodeticTransformDefType::Analytical;
break;
- //case MgCoordinateSystemGeodeticTransformationMethod::NAD27:
- //case MgCoordinateSystemGeodeticTransformationMethod::HPGN:
- //case MgCoordinateSystemGeodeticTransformationMethod::AGD66:
- //case MgCoordinateSystemGeodeticTransformationMethod::AGD84:
- //case MgCoordinateSystemGeodeticTransformationMethod::NZGD49:
- //case MgCoordinateSystemGeodeticTransformationMethod::ATS77:
- //case MgCoordinateSystemGeodeticTransformationMethod::CSRS:
- //case MgCoordinateSystemGeodeticTransformationMethod::TOKYO:
- //case MgCoordinateSystemGeodeticTransformationMethod::RGF93:
- //case MgCoordinateSystemGeodeticTransformationMethod::ED50:
- //case MgCoordinateSystemGeodeticTransformationMethod::DHDN:
- //case MgCoordinateSystemGeodeticTransformationMethod::CHENYX:
+ //grid file interpolation methods
case cs_DTCMTH_FILE:
case cs_DTCMTH_NTv1:
case cs_DTCMTH_NTv2:
@@ -185,7 +180,7 @@
MgCoordinateSystemGeodeticTransformDef* CCoordinateSystemGeodeticTransformDef::CreateClone()
{
- VERIFY_INITIALIZED(CCoordinateSystemGeodeticTransformDef::CreateClone);
+ VERIFY_INITIALIZED(L"CCoordinateSystemGeodeticTransformDef.CreateClone");
Ptr<CCoordinateSystemGeodeticTransformDef> clonedTransformDef = new CCoordinateSystemGeodeticTransformDef(NULL);
clonedTransformDef->Initialize(*this->transformDefinition);
@@ -196,7 +191,7 @@
void CCoordinateSystemGeodeticTransformDef::CopyTo(cs_GeodeticTransform_& transformDef) const
{
- VERIFY_INITIALIZED(CopyTo);
+ VERIFY_INITIALIZED(L"CCoordinateSystemGeodeticTransformDef.CopyTo");
//copy our values into the [cs_GeodeticTransform_] we've been passed here
transformDef = *this->transformDefinition;
@@ -209,6 +204,8 @@
MgCoordinateSystemGeodeticTransformDefParams* CCoordinateSystemGeodeticTransformDef::GetParameters()
{
+ VERIFY_INITIALIZED(L"CCoordinateSystemGeodeticTransformDef.CopyTo");
+
switch(this->transformationDefType)
{
case MgCoordinateSystemGeodeticTransformDefType::None:
@@ -216,15 +213,15 @@
case MgCoordinateSystemGeodeticTransformDefType::Analytical:
return static_cast<MgCoordinateSystemGeodeticAnalyticalTransformDefParams*>(
- new CCoordinateSystemGeodeticAnalyticalTransformDefParams(this->transformDefinition->parameters.geocentricParameters));
+ new CCoordinateSystemGeodeticAnalyticalTransformDefParams(this->transformDefinition->parameters.geocentricParameters, this->IsProtected()));
case MgCoordinateSystemGeodeticTransformDefType::Interpolation:
return static_cast<MgCoordinateSystemGeodeticInterpolationTransformDefParams*>(
- new CCoordinateSystemGeodeticInterpolationTransformDefParams(this->transformDefinition->parameters.fileParameters));
+ new CCoordinateSystemGeodeticInterpolationTransformDefParams(this->transformDefinition->parameters.fileParameters, this->IsProtected()));
case MgCoordinateSystemGeodeticTransformDefType::MultipleRegression:
return static_cast<MgCoordinateSystemGeodeticMultipleRegressionTransformDefParams*>(
- new CCoordinateSystemGeodeticMultipleRegressionTransformDefParams(this->transformDefinition->parameters.dmaMulRegParameters));
+ new CCoordinateSystemGeodeticMultipleRegressionTransformDefParams(this->transformDefinition->parameters.dmaMulRegParameters, this->IsProtected()));
default: //invalid state; why's that?
_ASSERT(false);
@@ -234,10 +231,8 @@
void CCoordinateSystemGeodeticTransformDef::SetParameters(MgCoordinateSystemGeodeticTransformDefParams* parameters)
{
- VERIFY_INITIALIZED(CCoordinateSystemGeodeticTransformDef::SetParameters);
-
- if (this->IsProtected())
- throw new MgCoordinateSystemInitializationFailedException(L"CCoordinateSystemGeodeticTransformDef::SetParameters", __LINE__, __WFILE__, NULL, L"MgCoordinateSystemProtectedException", NULL);
+ VERIFY_INITIALIZED(L"CCoordinateSystemGeodeticTransformDef.SetParameters");
+ VERIFY_NOT_PROTECTED(L"CCoordinateSystemGeodeticTransformDef.SetParameters");
//first check, whether this is a NONE transformation definition; if so, ignore the parameter altogether and wipe out
//this instance's parameter information to NULL
@@ -280,10 +275,29 @@
bool CCoordinateSystemGeodeticTransformDef::IsProtected()
{
- VERIFY_INITIALIZED(IsProtected);
- return 1 == this->transformDefinition->protect; //ABA: see cs_map; actually 0 does indicate protected...
+ VERIFY_INITIALIZED(L"CCoordinateSystemGeodeticTransformDef.IsProtected");
+ return (DICTIONARY_SYS_DEF == this->transformDefinition->protect);
}
+bool CCoordinateSystemGeodeticTransformDef::IsValid()
+{
+ if (NULL == this->transformDefinition) //an unitialized definition is always invalid
+ return false;
+
+ Ptr<MgCoordinateSystemGeodeticTransformDefParams> params = this->GetParameters();
+ if (!params->IsValid())
+ return false;
+
+ //TODO: would we also need to check, whether the datum(s) exists?
+
+ CriticalClass.Enter();
+ //TODO: pass correct parameters; make sure, CS_gxchk checks all stuff
+ int nNumErrs = CS_gxchk(this->transformDefinition, 0, NULL, 0);
+ CriticalClass.Leave();
+
+ return (0 == nNumErrs);
+}
+
//helper - don't delete
bool CCoordinateSystemGeodeticTransformDef::IsEncrypted()
{
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDef.h
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDef.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDef.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -87,7 +87,9 @@
//helper - don't delete
virtual bool IsEncrypted();
+
virtual bool IsProtected();
+ virtual bool IsValid();
void CopyTo(cs_GeodeticTransform_& transformDef) const;
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDefDictionary.cpp
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDefDictionary.cpp 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDefDictionary.cpp 2010-09-03 13:07:28 UTC (rev 5109)
@@ -42,6 +42,7 @@
CCoordinateSystemGeodeticTransformDefDictionary::UpdateGeodeticTransformDef, /* CS_gpupd has a different signature than the other CS 'update' methods */
CS_gxdel,
+ &CCoordinateSystemGeodeticTransformDef::IsValid,
CCoordinateSystemGeodeticTransformDefDictionary::SetupCsStructFromMgTransformDef,
CCoordinateSystemGeodeticTransformDefDictionary::FullInitialize,
Added: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDefParams.cpp
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDefParams.cpp (rev 0)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDefParams.cpp 2010-09-03 13:07:28 UTC (rev 5109)
@@ -0,0 +1,38 @@
+//
+// Copyright (C) 2004-2010 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 "GeometryCommon.h"
+#include "CoordSysGeodeticTransformDefParams.h"
+
+#include <cs_map.h>
+
+using namespace CSLibrary;
+
+CCoordinateSystemGeodeticTransformDefParams::CCoordinateSystemGeodeticTransformDefParams(bool isProtected)
+: isProtected(isProtected)
+{
+}
+
+CCoordinateSystemGeodeticTransformDefParams::~CCoordinateSystemGeodeticTransformDefParams()
+{
+}
+
+bool CCoordinateSystemGeodeticTransformDefParams::IsProtected()
+{
+ return this->isProtected;
+}
+
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDefParams.h
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDefParams.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformDefParams.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -25,6 +25,14 @@
{
public:
virtual void CopyTo(void* target) const = 0;
+ virtual bool IsProtected();
+
+ protected:
+ CCoordinateSystemGeodeticTransformDefParams(bool isProtected);
+ virtual ~CCoordinateSystemGeodeticTransformDefParams();
+
+ private:
+ bool isProtected;
};
} //namespace CSLibrary
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformGridFile.cpp
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformGridFile.cpp 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformGridFile.cpp 2010-09-03 13:07:28 UTC (rev 5109)
@@ -32,8 +32,8 @@
using namespace CSLibrary;
-CCoordinateSystemGeodeticTransformGridFile::CCoordinateSystemGeodeticTransformGridFile(const csGridFileXFormat* const fileFormatParam)
- : gridFileDesc(NULL)
+CCoordinateSystemGeodeticTransformGridFile::CCoordinateSystemGeodeticTransformGridFile(const csGridFileXFormat* const fileFormatParam, bool isProtected)
+ : gridFileDesc(NULL), isProtected(isProtected)
{
this->gridFileDesc = (csGridFileXFormat*)CS_malc(sizeof(csGridFileXFormat));
if (NULL == this->gridFileDesc)
@@ -70,7 +70,53 @@
*destGridFile = *this->gridFileDesc;
}
+bool CCoordinateSystemGeodeticTransformGridFile::IsProtected()
+{
+ return this->isProtected;
+}
+bool CCoordinateSystemGeodeticTransformGridFile::IsValid()
+{
+ _ASSERT(NULL != this->gridFileDesc);
+
+ size_t fileNameLength = strlen(this->gridFileDesc->fileName);
+
+ _ASSERT(fileNameLength < csGRIDI1_FLNMSZ);
+ if (0 == fileNameLength || fileNameLength >= csGRIDI1_FLNMSZ)
+ return false;
+
+ switch(this->gridFileDesc->fileFormat)
+ {
+ case cs_DTCFRMTTYP_NTv1:
+ case cs_DTCFRMTTYP_NTv2:
+ case cs_DTCFRMTTYP_NADCON:
+ case cs_DTCFRMTTYP_RGF:
+ case cs_DTCFRMTTYP_PAR:
+ case cs_DTCFRMTTYP_ATS77:
+ break;
+
+ //unsupported file formats
+ case cs_DTCFRMTTYP_NONE:
+ default:
+ return false;
+ }
+
+ switch(this->gridFileDesc->direction)
+ {
+ case 'i':
+ case 'I':
+ case 'f':
+ case 'F':
+ break;
+
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+
//************************************ Getters / Setters ***************************** /
DEFINE_GET_SET_NUMERIC(CCoordinateSystemGeodeticTransformGridFile,FileFormat,INT32,this->gridFileDesc->fileFormat);
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformGridFile.h
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformGridFile.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysGeodeticTransformGridFile.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -26,7 +26,7 @@
public MgCoordinateSystemGeodeticTransformGridFile
{
public:
- CCoordinateSystemGeodeticTransformGridFile(const csGridFileXFormat* const fileFormatParam);
+ CCoordinateSystemGeodeticTransformGridFile(const csGridFileXFormat* const fileFormatParam, bool isProtected);
~CCoordinateSystemGeodeticTransformGridFile();
// >>> MgCoordinateSystemGeodeticTransformGridFile
@@ -39,10 +39,12 @@
virtual STRING GetFileName();
virtual void SetFileName(CREFSTRING fileName);
+ virtual bool IsProtected();
+ virtual bool IsValid();
+
// <<< MgCoordinateSystemGeodeticTransformGridFile
virtual void Dispose();
- virtual bool IsProtected() { return false; }
virtual void CopyTo(csGridFileXFormat* destGridFile) const;
@@ -51,6 +53,7 @@
private:
csGridFileXFormat* gridFileDesc;
+ bool isProtected;
};
}
Modified: sandbox/rfc94/Common/CoordinateSystem/CoordSysMacro.h
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/CoordSysMacro.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/CoordSysMacro.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -18,25 +18,30 @@
#ifndef _MG_COORDSYSMACRO_H_
#define _MG_COORDSYSMACRO_H_
-//make sure to have CS_MAP_DEF_VARIABLE defined before including this header
+//make sure to have CS_MAP_DEF_VARIABLE defined before including this header; this is used by VERIFY_INITIALIZED(x)
#ifdef CS_MAP_DEF_VARIABLE
+ #define MAKE_L_STRING(x) L## #x
+
#define VERIFY_INITIALIZED(x) if (NULL == CS_MAP_DEF_VARIABLE) \
- throw new MgInvalidOperationException(L# x, __LINE__, __WFILE__, NULL, L"", NULL)
+ throw new MgInvalidOperationException(x, __LINE__, __WFILE__, NULL, L"", NULL)
+ #define VERIFY_NOT_PROTECTED(x) if (this->IsProtected()) \
+ throw new MgCoordinateSystemInitializationFailedException(x, __LINE__, __WFILE__, NULL, L"MgCoordinateSystemProtectedException", NULL);
+
#define DEFINE_GET_STRING(x,y) STRING x::Get##y()
#define DEFINE_SET_STRING(x,y) void x::Set##y(CREFSTRING propertyValue)
#define DEFINE_GET_SET_STRING(className,propertyName,charBuffer) \
DEFINE_GET_STRING(className,propertyName) \
{ \
- VERIFY_INITIALIZED(className##.Get##propertyName); \
+ VERIFY_INITIALIZED(MAKE_L_STRING(className##.Get##propertyName)); \
return MentorReadString(charBuffer); \
} \
DEFINE_SET_STRING(className,propertyName) \
{ \
- VERIFY_INITIALIZED(className##.Set##propertyName); \
+ VERIFY_INITIALIZED(MAKE_L_STRING(className##.Set##propertyName)); \
if (this->IsProtected()) \
throw new MgCoordinateSystemInitializationFailedException(L"SetString", __LINE__, __WFILE__, NULL, L"MgCoordinateSystemProtectedException", NULL); \
\
@@ -52,12 +57,12 @@
#define DEFINE_GET_SET_NUMERIC(className, propertyName,targetType,target) \
DEFINE_GET_NUMERIC(className,propertyName,targetType) \
{ \
- VERIFY_INITIALIZED(className##.Get##propertyName); \
+ VERIFY_INITIALIZED(MAKE_L_STRING(className##.Get##propertyName)); \
return target; \
} \
DEFINE_SET_NUMERIC(className,propertyName,targetType) \
{ \
- VERIFY_INITIALIZED(className##.Set##propertyName); \
+ VERIFY_INITIALIZED(MAKE_L_STRING(className##.Set##propertyName)); \
if (this->IsProtected()) \
throw new MgCoordinateSystemInitializationFailedException(L"SetValue", __LINE__, __WFILE__, NULL, L"MgCoordinateSystemProtectedException", NULL); \
\
@@ -67,7 +72,7 @@
#define DEFINE_GET_SET_NUMERIC_IDX(className, propertyName,targetType,target,maxIdx) \
DEFINE_GET_NUMERIC_IDX(className,propertyName,targetType) \
{ \
- VERIFY_INITIALIZED(className##.Get##propertyName); \
+ VERIFY_INITIALIZED(MAKE_L_STRING(className##.Get##propertyName)); \
if (index < 0 || index > maxIdx) \
throw new MgArgumentOutOfRangeException(L"GetValue", __LINE__, __WFILE__, NULL, L"MgCoordinateSystemProtectedException", NULL); \
\
@@ -75,7 +80,7 @@
} \
DEFINE_SET_NUMERIC_IDX(className,propertyName,targetType) \
{ \
- VERIFY_INITIALIZED(className##.Set##propertyName); \
+ VERIFY_INITIALIZED(MAKE_L_STRING(className##.Set##propertyName)); \
if (this->IsProtected()) \
throw new MgCoordinateSystemInitializationFailedException(L"SetValue", __LINE__, __WFILE__, NULL, L"MgCoordinateSystemProtectedException", NULL); \
\
Modified: sandbox/rfc94/Common/CoordinateSystem/MentorDictionary.h
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/MentorDictionary.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/MentorDictionary.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -32,6 +32,8 @@
#include "MentorUtil.h"
#include "Foundation.h"
+#define DICTIONARY_SYS_DEF 1
+
namespace MentorDictionary
{
void SetFileName(INT32& lMagic, CsDictionaryOpenMode (*ValidMagic)(long), CREFSTRING sDirectory, CREFSTRING sFileName, REFSTRING sFileNameSet, const wchar_t* kpMethodName);
@@ -146,7 +148,10 @@
//Look in the dictionary
bool bActuallyExists = false;
INT16 sProtect = 0;
+
+ //make sure, we've exclusive access to the file(s)
SmartCriticalClass critical(true);
+
T *pDef = CS_Tdef(keyName);
if (NULL != pDef)
{
Modified: sandbox/rfc94/Common/CoordinateSystem/MentorUtil.cpp
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/MentorUtil.cpp 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/MentorUtil.cpp 2010-09-03 13:07:28 UTC (rev 5109)
@@ -1643,6 +1643,8 @@
void MentorSetString(CREFSTRING sSrc, char *pDest, UINT32 nMaxSize)
{
+ //make sure to have checked the Protection level before calling this method
+
char *pStr = NULL;
MG_TRY()
@@ -1654,12 +1656,6 @@
throw new MgNullArgumentException(L"MentorSetString", __LINE__, __WFILE__, NULL, L"", NULL);
}
- //if (Protected())
- //{
- // //Can't modify a read-only object.
- // throw new MgCoordinateSystemInitializationFailedException(L"MentorSetString", __LINE__, __WFILE__, NULL, L"MgCoordinateSystemProtectedException", NULL);
- //}
-
if (!IsLegalString(sSrc.c_str(), nMaxSize))
{
//Can't set string, caller gave us an illegal value
Modified: sandbox/rfc94/Common/CoordinateSystem/MentorUtil.h
===================================================================
--- sandbox/rfc94/Common/CoordinateSystem/MentorUtil.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/CoordinateSystem/MentorUtil.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -251,7 +251,9 @@
//reads a const char* and returns the STRING class object for it
STRING MentorReadString(const char* mentorString = NULL);
-//writes a string into the destination char buffer specified through pDest
+//writes a string into the destination char buffer specified through pDest; this method has no idea
+//where the target buffer is, i.e. the caller must have checked the target item's protection
+//level first; usually [Mg*Item::IsProtected()]
void MentorSetString(CREFSTRING sSrc, char *pDest, UINT32 nMaxSize);
//Macro which defines comparison function, suitable for use with CS_bins,
Modified: sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticPath.h
===================================================================
--- sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticPath.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticPath.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -67,8 +67,11 @@
virtual MgDisposableCollection* GetPathElements() = 0;
virtual void SetPathElements(MgDisposableCollection* pathElements) = 0;
- virtual bool IsProtected()=0;
+ virtual bool IsProtected() = 0;
+ virtual bool IsValid() = 0;
+ virtual MgCoordinateSystemGeodeticPathElement* NewPathElement() = 0;
+
virtual MgCoordinateSystemGeodeticPath* CreateClone() = 0;
protected:
Modified: sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticPathElement.h
===================================================================
--- sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticPathElement.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticPathElement.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -24,6 +24,9 @@
virtual bool GetIsInversed() = 0;
virtual void SetIsInversed(bool) = 0;
+ virtual bool IsValid() = 0;
+ virtual bool IsProtected() = 0;
+
protected:
/////////////////////////////////////////////////////////////////
/// \brief
Modified: sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformDef.h
===================================================================
--- sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformDef.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformDef.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -66,6 +66,7 @@
virtual void SetAccuracy(double accuracy) = 0;
virtual bool IsProtected() = 0;
+ virtual bool IsValid() = 0;
virtual INT32 GetTransformDefType() = 0;
Modified: sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformDefParams.h
===================================================================
--- sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformDefParams.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformDefParams.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -23,6 +23,9 @@
PUBLISHED_API:
+ virtual bool IsValid() = 0;
+ virtual bool IsProtected() = 0;
+
//protected:
// /////////////////////////////////////////////////////////////////
// /// \brief
Modified: sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformGridFile.h
===================================================================
--- sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformGridFile.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformGridFile.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -32,6 +32,9 @@
virtual STRING GetFileName() = 0;
virtual void SetFileName(CREFSTRING fileName) = 0;
+ virtual bool IsProtected() = 0;
+ virtual bool IsValid() = 0;
+
protected:
/////////////////////////////////////////////////////////////////
/// \brief
Modified: sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformGridFileFormat.h
===================================================================
--- sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformGridFileFormat.h 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/Geometry/CoordinateSystem/CoordinateSystemGeodeticTransformGridFileFormat.h 2010-09-03 13:07:28 UTC (rev 5109)
@@ -23,12 +23,12 @@
{
PUBLISHED_API:
static const INT32 None = 0;
- static const INT32 NTv1 = 256;
- static const INT32 NTv2 = 512;
- static const INT32 NADCON = 768;
- static const INT32 RGF = 1024;
- static const INT32 PAR = 1280;
- static const INT32 ATS77 = 1536;
+ static const INT32 NTv1 = 1;
+ static const INT32 NTv2 = 2;
+ static const INT32 NADCON = 3;
+ static const INT32 RGF = 4;
+ static const INT32 PAR = 5;
+ static const INT32 ATS77 = 6;
};
Modified: sandbox/rfc94/Common/Geometry/Geometry.vcproj
===================================================================
--- sandbox/rfc94/Common/Geometry/Geometry.vcproj 2010-09-03 10:38:14 UTC (rev 5108)
+++ sandbox/rfc94/Common/Geometry/Geometry.vcproj 2010-09-03 13:07:28 UTC (rev 5109)
@@ -3015,6 +3015,10 @@
>
</File>
<File
+ RelativePath="..\CoordinateSystem\CoordSysGeodeticTransformDefParams.cpp"
+ >
+ </File>
+ <File
RelativePath="..\CoordinateSystem\CoordSysGeodeticTransformDefParams.h"
>
</File>
More information about the mapguide-commits
mailing list