58
62
CPLFree( m_pszFID );
60
for( int i = 0; i < m_nPropertyCount; i++ )
62
if( m_papszProperty[i] )
63
CPLFree( m_papszProperty[i] );
66
CPLFree( m_papszProperty );
67
CPLFree( m_pszGeometry );
65
for( i = 0; i < m_nPropertyCount; i++ )
67
int nSubProperties = m_pasProperties[i].nSubProperties;
68
if (nSubProperties == 1)
69
CPLFree( m_pasProperties[i].aszSubProperties[0] );
70
else if (nSubProperties > 1)
72
for( int j = 0; j < nSubProperties; j++)
73
CPLFree( m_pasProperties[i].papszSubProperties[j] );
74
CPLFree( m_pasProperties[i].papszSubProperties );
78
if (m_nGeometryCount == 1)
80
CPLDestroyXMLNode(m_apsGeometry[0]);
82
else if (m_nGeometryCount > 1)
84
for(i=0;i<m_nGeometryCount;i++)
85
CPLDestroyXMLNode(m_papsGeometry[i]);
86
CPLFree(m_papsGeometry);
89
CPLFree( m_pasProperties );
68
90
CSLDestroy( m_papszOBProperties );
85
107
/************************************************************************/
87
/************************************************************************/
89
const char *GMLFeature::GetProperty( int iIndex ) const
92
if( iIndex < 0 || iIndex >= m_nPropertyCount )
95
return m_papszProperty[iIndex];
98
/************************************************************************/
100
/************************************************************************/
102
void GMLFeature::SetProperty( int iIndex, const char *pszValue )
105
if( iIndex < 0 || iIndex >= m_poClass->GetPropertyCount() )
108
/* SetPropertyDirectly() */
109
/************************************************************************/
111
void GMLFeature::SetPropertyDirectly( int iIndex, char *pszValue )
111
114
if( iIndex >= m_nPropertyCount )
113
m_papszProperty = (char **)
114
CPLRealloc( m_papszProperty,
115
sizeof(char *) * m_poClass->GetPropertyCount() );
116
for( int i = m_nPropertyCount; i < m_poClass->GetPropertyCount(); i++ )
117
m_papszProperty[i] = NULL;
118
m_nPropertyCount = m_poClass->GetPropertyCount();
116
int nClassPropertyCount = m_poClass->GetPropertyCount();
117
m_pasProperties = (GMLProperty*)
118
CPLRealloc( m_pasProperties,
119
sizeof(GMLProperty) * nClassPropertyCount );
121
for( i = 0; i < m_nPropertyCount; i ++ )
123
/* Make sure papszSubProperties point to the right address in case */
124
/* m_pasProperties has been relocated */
125
if (m_pasProperties[i].nSubProperties <= 1)
126
m_pasProperties[i].papszSubProperties = m_pasProperties[i].aszSubProperties;
128
for( i = m_nPropertyCount; i < nClassPropertyCount; i++ )
130
m_pasProperties[i].nSubProperties = 0;
131
m_pasProperties[i].papszSubProperties = m_pasProperties[i].aszSubProperties;
132
m_pasProperties[i].aszSubProperties[0] = NULL;
133
m_pasProperties[i].aszSubProperties[1] = NULL;
135
m_nPropertyCount = nClassPropertyCount;
121
CPLFree( m_papszProperty[iIndex] );
122
m_papszProperty[iIndex] = CPLStrdup( pszValue );
138
GMLProperty* psProperty = &m_pasProperties[iIndex];
139
int nSubProperties = psProperty->nSubProperties;
140
if (nSubProperties == 0)
141
psProperty->aszSubProperties[0] = pszValue;
142
else if (nSubProperties == 1)
144
psProperty->papszSubProperties = (char**) CPLMalloc(
145
sizeof(char*) * (nSubProperties + 2) );
146
psProperty->papszSubProperties[0] = psProperty->aszSubProperties[0];
147
psProperty->aszSubProperties[0] = NULL;
148
psProperty->papszSubProperties[nSubProperties] = pszValue;
149
psProperty->papszSubProperties[nSubProperties + 1] = NULL;
153
psProperty->papszSubProperties = (char**) CPLRealloc(
154
psProperty->papszSubProperties,
155
sizeof(char*) * (nSubProperties + 2) );
156
psProperty->papszSubProperties[nSubProperties] = pszValue;
157
psProperty->papszSubProperties[nSubProperties + 1] = NULL;
159
psProperty->nSubProperties ++;
125
162
/************************************************************************/
134
171
if( m_pszFID != NULL )
135
172
printf( " FID = %s\n", m_pszFID );
137
for( int i = 0; i < m_nPropertyCount; i++ )
138
printf( " %s = %s\n",
139
m_poClass->GetProperty( i )->GetName(),
143
printf( " %s\n", m_pszGeometry );
175
for( i = 0; i < m_nPropertyCount; i++ )
177
const GMLProperty * psGMLProperty = GetProperty( i );
178
printf( " %s = ", m_poClass->GetProperty( i )->GetName());
179
for ( int j = 0; j < psGMLProperty->nSubProperties; j ++)
181
if (j > 0) printf(", ");
182
printf("%s", psGMLProperty->papszSubProperties[j]);
187
for(i=0;i<m_nGeometryCount;i++)
189
char* pszXML = CPLSerializeXMLTree(m_papsGeometry[i]);
190
printf( " %s\n", pszXML );
146
195
/************************************************************************/
147
196
/* SetGeometryDirectly() */
148
197
/************************************************************************/
150
void GMLFeature::SetGeometryDirectly( char *pszGeometry )
154
CPLFree( m_pszGeometry );
156
m_pszGeometry = pszGeometry;
199
void GMLFeature::SetGeometryDirectly( CPLXMLNode* psGeom )
202
if (m_apsGeometry[0] != NULL)
203
CPLDestroyXMLNode(m_apsGeometry[0]);
204
m_nGeometryCount = 1;
205
m_apsGeometry[0] = psGeom;
208
/************************************************************************/
210
/************************************************************************/
212
void GMLFeature::AddGeometry( CPLXMLNode* psGeom )
215
if (m_nGeometryCount == 0)
217
m_apsGeometry[0] = psGeom;
219
else if (m_nGeometryCount == 1)
221
m_papsGeometry = (CPLXMLNode **) CPLMalloc(
222
(m_nGeometryCount + 2) * sizeof(CPLXMLNode *));
223
m_papsGeometry[0] = m_apsGeometry[0];
224
m_apsGeometry[0] = NULL;
225
m_papsGeometry[m_nGeometryCount] = psGeom;
226
m_papsGeometry[m_nGeometryCount + 1] = NULL;
230
m_papsGeometry = (CPLXMLNode **) CPLRealloc(m_papsGeometry,
231
(m_nGeometryCount + 2) * sizeof(CPLXMLNode *));
232
m_papsGeometry[m_nGeometryCount] = psGeom;
233
m_papsGeometry[m_nGeometryCount + 1] = NULL;
159
238
/************************************************************************/