Commit d3313b1b authored by Dan Lipsa's avatar Dan Lipsa
Browse files

BUG #1777: lambert test creates mangled up image

vtkGeoProjection initialized a new projection for every GetProjection call.
This created a lot of allocations/deletes which probably exposed
memory problems in proj4.
parent 524ba39d
...@@ -104,10 +104,11 @@ const char* vtkGeoProjection::GetProjectionDescription( int projection ) ...@@ -104,10 +104,11 @@ const char* vtkGeoProjection::GetProjectionDescription( int projection )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
vtkGeoProjection::vtkGeoProjection() vtkGeoProjection::vtkGeoProjection()
{ {
this->Name = 0; this->Name = NULL;
this->SetName( "latlong" ); this->SetName( "latlong" );
this->CentralMeridian = 0.; this->CentralMeridian = 0.;
this->Projection = 0; this->Projection = NULL;
this->ProjectionMTime = 0;
this->Internals = new vtkInternals(); this->Internals = new vtkInternals();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -138,9 +139,6 @@ void vtkGeoProjection::PrintSelf( ostream& os, vtkIndent indent ) ...@@ -138,9 +139,6 @@ void vtkGeoProjection::PrintSelf( ostream& os, vtkIndent indent )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int vtkGeoProjection::GetIndex() int vtkGeoProjection::GetIndex()
{ {
this->UpdateProjection();
if ( ! this->Projection )
return -1;
int i = 0; int i = 0;
for ( const PJ_LIST* proj = pj_get_list_ref(); proj && proj->id; ++ proj, ++ i ) for ( const PJ_LIST* proj = pj_get_list_ref(); proj && proj->id; ++ proj, ++ i )
{ {
...@@ -190,7 +188,7 @@ int vtkGeoProjection::UpdateProjection() ...@@ -190,7 +188,7 @@ int vtkGeoProjection::UpdateProjection()
if ( ! strcmp ( this->Name, "latlong" ) ) if ( ! strcmp ( this->Name, "latlong" ) )
{ {
// latlong is "null" projection. // latlong is "null" projection.
return 1; return 0;
} }
int argSize = 3 + this->GetNumberOfOptionalParameters(); int argSize = 3 + this->GetNumberOfOptionalParameters();
...@@ -219,11 +217,12 @@ int vtkGeoProjection::UpdateProjection() ...@@ -219,11 +217,12 @@ int vtkGeoProjection::UpdateProjection()
this->Projection = pj_init( argSize, const_cast<char**>( pjArgs ) ); this->Projection = pj_init( argSize, const_cast<char**>( pjArgs ) );
delete[] pjArgs; delete[] pjArgs;
this->ProjectionMTime = this->GetMTime();
if ( this->Projection ) if ( this->Projection )
{ {
return 1; return 0;
} }
return 0; return 1;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -232,18 +231,19 @@ void vtkGeoProjection::SetOptionalParameter(const char* key, const char* value) ...@@ -232,18 +231,19 @@ void vtkGeoProjection::SetOptionalParameter(const char* key, const char* value)
if(key != NULL && value != NULL) if(key != NULL && value != NULL)
{ {
this->Internals->OptionalParameters[key] = value; this->Internals->OptionalParameters[key] = value;
this->Modified();
} }
else else
{ {
vtkErrorMacro("Invalid Optional Parameter Key/Value pair. None can be NULL"); vtkErrorMacro("Invalid Optional Parameter Key/Value pair. None can be NULL");
} }
this->UpdateProjection();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void vtkGeoProjection::RemoveOptionalParameter(const char* key) void vtkGeoProjection::RemoveOptionalParameter(const char* key)
{ {
this->Internals->OptionalParameters.erase(key); this->Internals->OptionalParameters.erase(key);
this->UpdateProjection(); this->Modified();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int vtkGeoProjection::GetNumberOfOptionalParameters() int vtkGeoProjection::GetNumberOfOptionalParameters()
...@@ -264,5 +264,5 @@ const char* vtkGeoProjection::GetOptionalParameterValue(int index) ...@@ -264,5 +264,5 @@ const char* vtkGeoProjection::GetOptionalParameterValue(int index)
void vtkGeoProjection::ClearOptionalParameters() void vtkGeoProjection::ClearOptionalParameters()
{ {
this->Internals->OptionalParameters.clear(); this->Internals->OptionalParameters.clear();
this->UpdateProjection(); this->Modified();
} }
...@@ -127,7 +127,7 @@ protected: ...@@ -127,7 +127,7 @@ protected:
char* Name; char* Name;
double CentralMeridian; double CentralMeridian;
projPJ Projection; projPJ Projection;
vtkTimeStamp ProjectionMTime; unsigned long ProjectionMTime;
private: private:
vtkGeoProjection( const vtkGeoProjection& ); // Not implemented. vtkGeoProjection( const vtkGeoProjection& ); // Not implemented.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment