[mapguide-commits] r4294 - trunk/MgDev/Common/CoordinateSystem
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Oct 12 13:56:57 EDT 2009
Author: NormOlsen
Date: 2009-10-12 13:56:56 -0400 (Mon, 12 Oct 2009)
New Revision: 4294
Modified:
trunk/MgDev/Common/CoordinateSystem/CoordSysGridGeneric.cpp
trunk/MgDev/Common/CoordinateSystem/CoordSysGrids.cpp
trunk/MgDev/Common/CoordinateSystem/CoordSysGrids.h
trunk/MgDev/Common/CoordinateSystem/CoordSysMgrs.cpp
trunk/MgDev/Common/CoordinateSystem/CoordSysMgrsZone.cpp
trunk/MgDev/Common/CoordinateSystem/CoordSysOneGrid.cpp
trunk/MgDev/Common/CoordinateSystem/CoordSysTransform.cpp
Log:
Submitted in response to RFC 76. THis submission includes the results of some serious testing with an UI/API that actually uses most all the features. Several defects and a _HUGE_ memory leak were corrected. While more testing is underway, the code submitted for RFC 76 is substantially complete.
Modified: trunk/MgDev/Common/CoordinateSystem/CoordSysGridGeneric.cpp
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/CoordSysGridGeneric.cpp 2009-10-09 14:39:20 UTC (rev 4293)
+++ trunk/MgDev/Common/CoordinateSystem/CoordSysGridGeneric.cpp 2009-10-12 17:56:56 UTC (rev 4294)
@@ -54,7 +54,7 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CCoordinateSystemGridGeneric::~CCoordinateSystemGridGeneric()
{
- delete m_TheGrid;
+ SAFE_RELEASE (m_TheGrid);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
INT32 CCoordinateSystemGridGeneric::GetSpecializationType ()
@@ -75,7 +75,7 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
MgCoordinateSystemGridLineCollection* CCoordinateSystemGridGeneric::GetGridLines (MgCoordinateSystemGridSpecification* specification)
{
- MgCoordinateSystemGridLineCollection* gridLines;
+ MgCoordinateSystemGridLineCollection* gridLines = 0;
if (m_TheGrid != 0)
{
Modified: trunk/MgDev/Common/CoordinateSystem/CoordSysGrids.cpp
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/CoordSysGrids.cpp 2009-10-09 14:39:20 UTC (rev 4293)
+++ trunk/MgDev/Common/CoordinateSystem/CoordSysGrids.cpp 2009-10-12 17:56:56 UTC (rev 4294)
@@ -249,8 +249,8 @@
INT32 gridCrsUnitCode;
double unitConversion;
- MgCoordinateSystemCatalog* catalogPtr = gridCS->GetCatalog ();
- MgCoordinateSystemUnitInformation* unitInfoPtr = catalogPtr->GetUnitInformation ();
+ Ptr<MgCoordinateSystemCatalog> catalogPtr = gridCS->GetCatalog ();
+ Ptr<MgCoordinateSystemUnitInformation> unitInfoPtr = catalogPtr->GetUnitInformation ();
gridCrsUnitCode = gridCS->GetUnitCode ();
// Verify that the unit type of the specification match the unit type
@@ -280,8 +280,8 @@
INT32 gridCrsUnitCode;
double unitConversion;
- MgCoordinateSystemCatalog* catalogPtr = gridCS->GetCatalog ();
- MgCoordinateSystemUnitInformation* unitInfoPtr = catalogPtr->GetUnitInformation ();
+ Ptr<MgCoordinateSystemCatalog> catalogPtr = gridCS->GetCatalog ();
+ Ptr<MgCoordinateSystemUnitInformation> unitInfoPtr = catalogPtr->GetUnitInformation ();
gridCrsUnitCode = gridCS->GetUnitCode ();
// Verify that the unit type of the specification match the unit type
@@ -311,8 +311,8 @@
INT32 gridCrsUnitCode;
double unitConversion;
- MgCoordinateSystemCatalog* catalogPtr = gridCS->GetCatalog ();
- MgCoordinateSystemUnitInformation* unitInfoPtr = catalogPtr->GetUnitInformation ();
+ Ptr<MgCoordinateSystemCatalog> catalogPtr = gridCS->GetCatalog ();
+ Ptr<MgCoordinateSystemUnitInformation> unitInfoPtr = catalogPtr->GetUnitInformation ();
gridCrsUnitCode = gridCS->GetUnitCode ();
// Verify that the unit type of the specification match the unit type
@@ -342,8 +342,8 @@
INT32 gridCrsUnitCode;
double unitConversion;
- MgCoordinateSystemCatalog* catalogPtr = gridCS->GetCatalog ();
- MgCoordinateSystemUnitInformation* unitInfoPtr = catalogPtr->GetUnitInformation ();
+ Ptr<MgCoordinateSystemCatalog> catalogPtr = gridCS->GetCatalog ();
+ Ptr<MgCoordinateSystemUnitInformation> unitInfoPtr = catalogPtr->GetUnitInformation ();
gridCrsUnitCode = gridCS->GetUnitCode ();
// Verify that the unit type of the specification match the unit type
@@ -374,8 +374,8 @@
double toMeters;
double toDegrees;
- MgCoordinateSystemCatalog* catalogPtr = gridCS->GetCatalog ();
- MgCoordinateSystemUnitInformation* unitInfoPtr = catalogPtr->GetUnitInformation ();
+ Ptr<MgCoordinateSystemCatalog> catalogPtr = gridCS->GetCatalog ();
+ Ptr<MgCoordinateSystemUnitInformation> unitInfoPtr = catalogPtr->GetUnitInformation ();
// UnitConversion will convert the units of the coordinate system to
// meters by multiplication. By inverting this, we have a value which
@@ -483,7 +483,13 @@
collection->Add (clPnt);
MgLinearRing* ring = factory.CreateLinearRing (collection);
+ if (ring == 0)
+ {
+ throw new MgOutOfMemoryException(L"MgCoordinateSystemGridBoundary.SetBoundaryExtents",
+ __LINE__, __WFILE__, NULL, L"", NULL);
+ }
m_GridBoundary = factory.CreatePolygon (ring,NULL);
+ ring->Release ();
MG_CATCH_AND_THROW(L"MgCoordinateSystemGridBoundary.SetBoundaryExtents")
}
void CCoordinateSystemGridBoundary::SetBoundaryExtents (MgPolygon* boundary)
Modified: trunk/MgDev/Common/CoordinateSystem/CoordSysGrids.h
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/CoordSysGrids.h 2009-10-09 14:39:20 UTC (rev 4293)
+++ trunk/MgDev/Common/CoordinateSystem/CoordSysGrids.h 2009-10-12 17:56:56 UTC (rev 4294)
@@ -261,7 +261,6 @@
{
public:
CCoordinateSystemGridLine (INT32 orientation,double value);
- CCoordinateSystemGridLine (const CCoordinateSystemGridLine& source);
~CCoordinateSystemGridLine (void);
INT32 GetGridOrientation(void);
@@ -281,6 +280,9 @@
INT32 m_Orientation;
double m_Value;
Ptr<MgLineStringCollection> m_LineSegments;
+
+private: // Not implemented
+ CCoordinateSystemGridLine (const CCoordinateSystemGridLine& source);
};
//=============================================================================
@@ -324,7 +326,7 @@
Ptr<MgLineStringCollection> m_NorthLine;
Ptr<MgLineStringCollection> m_WestLine;
-private:
+private: // Not implemented
CCoordinateSystemGridRegion (void);
CCoordinateSystemGridRegion (const CCoordinateSystemGridRegion& source);
};
@@ -337,9 +339,7 @@
{
public:
CCoordinateSystemGridTick (INT32 orientation,double value);
- CCoordinateSystemGridTick (const CCoordinateSystemGridTick& source);
~CCoordinateSystemGridTick (void);
- CCoordinateSystemGridTick& operator= (const CCoordinateSystemGridTick& rhs);
void SetOnGridLine (bool isOnGridLine);
void SetOrientation (INT32 orientation);
@@ -361,6 +361,10 @@
double m_Value;
Ptr<MgCoordinate> m_Position;
Ptr<MgCoordinate> m_Direction;
+
+private: // Not implemented
+ CCoordinateSystemGridTick (const CCoordinateSystemGridTick& source);
+ CCoordinateSystemGridTick& operator= (const CCoordinateSystemGridTick& rhs);
};
//=============================================================================
Modified: trunk/MgDev/Common/CoordinateSystem/CoordSysMgrs.cpp
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/CoordSysMgrs.cpp 2009-10-09 14:39:20 UTC (rev 4293)
+++ trunk/MgDev/Common/CoordinateSystem/CoordSysMgrs.cpp 2009-10-12 17:56:56 UTC (rev 4294)
@@ -69,7 +69,10 @@
m_pCsTarget (),
m_pCsMgrs (NULL),
m_GridBoundary (),
- m_ZoneCollection ()
+ m_ZoneCollection (),
+ m_GraticuleUtm (),
+ m_GraticuleUpsNorth (),
+ m_GraticuleUpsSouth ()
{
}
CCoordinateSystemMgrs::CCoordinateSystemMgrs(MgCoordinateSystem* pTargetCs,INT8 nLetteringScheme,
@@ -82,7 +85,11 @@
m_pCsTarget (),
m_pCsMgrs (NULL),
m_GridBoundary (),
- m_ZoneCollection ()
+ m_ZoneCollection (),
+ m_GraticuleUtm (),
+ m_GraticuleUpsNorth (),
+ m_GraticuleUpsSouth ()
+
{
m_pCsTarget = SAFE_ADDREF (pTargetCs);
}
@@ -686,6 +693,7 @@
double northMin, northMax; // frame boundary extrema in 'LL84' (or 'LL')
Ptr<MgPolygon> pPolygon;
+ Ptr<MgPolygon> pPolygonIntersection;
Ptr<MgCoordinate> pSouthwest;
Ptr<MgCoordinate> pNortheast;
Ptr<MgCoordinateSystem> llCRS;
@@ -724,7 +732,9 @@
pNortheast->SetY (-80.0);
llBoundary = csFactory->GridBoundary (pSouthwest,pNortheast);
pPolygon = llBoundary->GetBoundary (toFrameTransform,1.0);
- reducedFrameBoundary = csFactory->GridBoundary (pPolygon);
+ Ptr<MgPolygon> pPolygonTemp = frameBoundary->GetBoundary ();
+ pPolygonIntersection = dynamic_cast<MgPolygon*>(pPolygon->Intersection (pPolygonTemp));
+ reducedFrameBoundary = csFactory->GridBoundary (pPolygonIntersection);
mgrsZoneGrid = new CCoordinateSystemMgrsZone (reducedFrameBoundary,zoneNbr,useFrameDatum,frameCRS,m_nLetteringScheme);
zoneCollection->Add (mgrsZoneGrid);
@@ -741,7 +751,9 @@
pNortheast->SetY (northMax);
llBoundary = csFactory->GridBoundary (pSouthwest,pNortheast);
pPolygon = llBoundary->GetBoundary (toFrameTransform,1.0);
- reducedFrameBoundary = csFactory->GridBoundary (pPolygon);
+ Ptr<MgPolygon> pPolygonTemp = frameBoundary->GetBoundary ();
+ pPolygonIntersection = dynamic_cast<MgPolygon*>(pPolygon->Intersection (pPolygonTemp));
+ reducedFrameBoundary = csFactory->GridBoundary (pPolygonIntersection);
mgrsZoneGrid = new CCoordinateSystemMgrsZone (reducedFrameBoundary,zoneNbr,useFrameDatum,frameCRS,m_nLetteringScheme);
zoneCollection->Add (mgrsZoneGrid);
@@ -795,7 +807,9 @@
// TODO: We should not use a hard coded curve precision value here.
llBoundary = csFactory->GridBoundary (pSouthwest,pNortheast);
pPolygon = llBoundary->GetBoundary (toFrameTransform,1.0);
- reducedFrameBoundary = csFactory->GridBoundary (pPolygon);
+ Ptr<MgPolygon> pPolygonTemp = frameBoundary->GetBoundary ();
+ pPolygonIntersection = dynamic_cast<MgPolygon*>(pPolygon->Intersection (pPolygonTemp));
+ reducedFrameBoundary = csFactory->GridBoundary (pPolygonIntersection);
mgrsZoneGrid = new CCoordinateSystemMgrsZone (reducedFrameBoundary,zoneNbr,useFrameDatum,frameCRS,m_nLetteringScheme);
zoneCollection->Add (mgrsZoneGrid);
}
@@ -818,7 +832,9 @@
llBoundary = csFactory->GridBoundary (pSouthwest,pNortheast);
pPolygon = llBoundary->GetBoundary (toFrameTransform,1.0);
- reducedFrameBoundary = csFactory->GridBoundary (pPolygon);
+ Ptr<MgPolygon> pPolygonTemp = frameBoundary->GetBoundary ();
+ pPolygonIntersection = dynamic_cast<MgPolygon*>(pPolygon->Intersection (pPolygonTemp));
+ reducedFrameBoundary = csFactory->GridBoundary (pPolygonIntersection);
mgrsZoneGrid = new CCoordinateSystemMgrsZone (reducedFrameBoundary,zoneNbr,useFrameDatum,frameCRS,m_nLetteringScheme);
zoneCollection->Add (mgrsZoneGrid);
}
Modified: trunk/MgDev/Common/CoordinateSystem/CoordSysMgrsZone.cpp
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/CoordSysMgrsZone.cpp 2009-10-09 14:39:20 UTC (rev 4293)
+++ trunk/MgDev/Common/CoordinateSystem/CoordSysMgrsZone.cpp 2009-10-12 17:56:56 UTC (rev 4294)
@@ -224,10 +224,10 @@
southwest->SetY (static_cast<double>(northIndex));
northeast->SetX (static_cast<double>(eastIndex + 100000));
northeast->SetY (static_cast<double>(northIndex + 100000));
-
- // Now we need the designation. The comes from the MgCoordinateSystemMgrs object that knows about the lettering scheme.
+
+ // Now we need the designation. The comes from the MgCoordinateSystemMgrs object that knows about the lettering scheme.
// Unfortunately, we don't have a reference to the host Mgrs object, so we're going to have to know
- /// about the lettering scheme.
+ // about the lettering scheme.
STRING designation = CCoordinateSystemMgrs::GridSquareDesignation (m_UtmZone,static_cast<double>(eastIndex + 1),
static_cast<double>(northIndex + 1),
m_LetteringScheme);
Modified: trunk/MgDev/Common/CoordinateSystem/CoordSysOneGrid.cpp
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/CoordSysOneGrid.cpp 2009-10-09 14:39:20 UTC (rev 4293)
+++ trunk/MgDev/Common/CoordinateSystem/CoordSysOneGrid.cpp 2009-10-12 17:56:56 UTC (rev 4294)
@@ -462,7 +462,7 @@
{
delete this;
}
-
+#pragma message ("Remove this code before code complete.")
//=============================================================================
// This object was invented to carry multiple MGRS grids, but is no longer used
// as there is now a CCoordinateSystemMgrsZone object and a related collection
Modified: trunk/MgDev/Common/CoordinateSystem/CoordSysTransform.cpp
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/CoordSysTransform.cpp 2009-10-09 14:39:20 UTC (rev 4293)
+++ trunk/MgDev/Common/CoordinateSystem/CoordSysTransform.cpp 2009-10-12 17:56:56 UTC (rev 4294)
@@ -1186,6 +1186,7 @@
{
MgCoordinate* pntPtr = factory.CreateCoordinateXY (curPtr->trgX,curPtr->trgY);
coordinateCollection->Add (pntPtr);
+ pntPtr->Release ();
}
lineString = factory.CreateLineString (coordinateCollection);
More information about the mapguide-commits
mailing list