Created
March 7, 2012 21:22
-
-
Save jef-n/1996329 to your computer and use it in GitHub Desktop.
better support for wfxext:replace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: ogr/ogrsf_frmts/nas/nashandler.cpp | |
=================================================================== | |
--- ogr/ogrsf_frmts/nas/nashandler.cpp (revision 24046) | |
+++ ogr/ogrsf_frmts/nas/nashandler.cpp (working copy) | |
@@ -1,7 +1,7 @@ | |
/********************************************************************** | |
- * $Id: gmlhandler.cpp 13760 2008-02-11 17:48:30Z warmerdam $ | |
+ * $Id$ | |
* | |
- * Project: GML Reader | |
+ * Project: NAS Reader | |
* Purpose: Implementation of NASHandler class. | |
* Author: Frank Warmerdam, warmerdam@pobox.com | |
* | |
@@ -155,8 +155,9 @@ | |
} | |
/* -------------------------------------------------------------------- */ | |
-/* Is this the ogc:Filter element in a wfs:Delete operation? */ | |
-/* If so we translate it as a specialized sort of feature. */ | |
+/* Is this the ogc:Filter element in a wfs:Delete or */ | |
+/* wfsext:Replace operation? If so we translate it as a */ | |
+/* specialized sort of feature. */ | |
/* -------------------------------------------------------------------- */ | |
else if( EQUAL(szElementName,"Filter") | |
&& (pszLast = m_poReader->GetState()->GetLastComponent()) != NULL | |
@@ -181,6 +182,14 @@ | |
m_nDepth ++; | |
m_poReader->SetFeaturePropertyDirectly( "typeName", CPLStrdup(m_osLastTypeName) ); | |
+ m_poReader->SetFeaturePropertyDirectly( "context", CPLStrdup(pszLast) ); | |
+ | |
+ if( m_osLastReplacingFID != "" ) | |
+ m_poReader->SetFeaturePropertyDirectly( "replacedBy", CPLStrdup(m_osLastReplacingFID) ); | |
+ | |
+ if( m_osLastSafeToIgnore != "" ) | |
+ m_poReader->SetFeaturePropertyDirectly( "safeToIgnore", CPLStrdup(m_osLastSafeToIgnore) ); | |
+ | |
return; | |
} | |
@@ -189,10 +198,33 @@ | |
/* -------------------------------------------------------------------- */ | |
else if( m_poReader->IsFeatureElement( szElementName ) ) | |
{ | |
+ const char* pszFilteredClassName = m_poReader->GetFilteredClassName(); | |
+ if ( pszFilteredClassName != NULL && | |
+ strcmp("Delete", pszFilteredClassName) == 0 ) | |
+ { | |
m_osLastTypeName = szElementName; | |
- const char* pszFilteredClassName = m_poReader->GetFilteredClassName(); | |
+ pszLast = m_poReader->GetState()->GetLastComponent(); | |
+ if( pszLast != NULL && EQUAL(pszLast,"Replace") ) | |
+ { | |
+ int nIndex; | |
+ XMLCh Name[100]; | |
+ tr_strcpy( Name, "gml:id" ); | |
+ nIndex = attrs.getIndex( Name ); | |
+ | |
+ CPLAssert( nIndex!=-1 ); | |
+ CPLAssert( EQUAL(m_osLastReplacingFID,"") ); | |
+ | |
+ // Capture "gml:id" attribute as part of the property value - | |
+ // primarily this is for the wfsext:Replace operation's attribute. | |
+ char *pszReplacingFID = tr_strdup( attrs.getValue( nIndex ) ); | |
+ m_osLastReplacingFID = pszReplacingFID; | |
+ | |
+ CPLFree( pszReplacingFID ); | |
+ } | |
+ } | |
+ | |
if ( pszFilteredClassName != NULL && | |
strcmp(szElementName, pszFilteredClassName) != 0 ) | |
{ | |
@@ -232,9 +264,39 @@ | |
m_osLastTypeName = pszTypeName; | |
CPLFree( pszTypeName ); | |
} | |
+ | |
+ m_osLastSafeToIgnore = ""; | |
+ m_osLastReplacingFID = ""; | |
} | |
/* -------------------------------------------------------------------- */ | |
+/* If it is the wfsext:Replace element, then remember the */ | |
+/* safeToIgnore attribute so we can assign it to the feature */ | |
+/* that will be produced when we process the Filter element. */ | |
+/* -------------------------------------------------------------------- */ | |
+ else if( EQUAL(szElementName,"Replace") ) | |
+ { | |
+ int nIndex; | |
+ XMLCh Name[100]; | |
+ | |
+ tr_strcpy( Name, "safeToIgnore" ); | |
+ nIndex = attrs.getIndex( Name ); | |
+ | |
+ if( nIndex != -1 ) | |
+ { | |
+ char *pszSafeToIgnore = tr_strdup( attrs.getValue( nIndex ) ); | |
+ m_osLastSafeToIgnore = pszSafeToIgnore; | |
+ CPLFree( pszSafeToIgnore ); | |
+ } | |
+ else | |
+ { | |
+ m_osLastSafeToIgnore = "false"; | |
+ } | |
+ | |
+ m_osLastReplacingFID = ""; | |
+ } | |
+ | |
+/* -------------------------------------------------------------------- */ | |
/* If it is (or at least potentially is) a simple attribute, */ | |
/* then start collecting it. */ | |
/* -------------------------------------------------------------------- */ | |
Index: ogr/ogrsf_frmts/nas/nasreader.cpp | |
=================================================================== | |
--- ogr/ogrsf_frmts/nas/nasreader.cpp (revision 24046) | |
+++ ogr/ogrsf_frmts/nas/nasreader.cpp (working copy) | |
@@ -1,5 +1,5 @@ | |
/****************************************************************************** | |
- * $Id: gmlreader.cpp 10645 2007-01-18 02:22:39Z warmerdam $ | |
+ * $Id$ | |
* | |
* Project: NAS Reader | |
* Purpose: Implementation of NASReader class. | |
@@ -263,7 +263,7 @@ | |
} | |
catch (const XMLException& toCatch) | |
{ | |
- CPLDebug( "GML", | |
+ CPLDebug( "NAS", | |
"Error during NextFeature()! Message:\n%s", | |
tr_strdup( toCatch.getMessage() ) ); | |
} | |
@@ -306,7 +306,7 @@ | |
GMLFeatureClass *poNewClass = new GMLFeatureClass( pszElement ); | |
- AddClass( poNewClass ); | |
+ iClass = AddClass( poNewClass ); | |
} | |
/* -------------------------------------------------------------------- */ | |
@@ -491,10 +491,20 @@ | |
m_nClassCount++; | |
m_papoClass = (GMLFeatureClass **) | |
CPLRealloc( m_papoClass, sizeof(void*) * m_nClassCount ); | |
+ | |
+ // keep delete the last entry | |
+ if( m_nClassCount > 1 && EQUAL( m_papoClass[m_nClassCount-2]->GetName(), "Delete" ) ) | |
+ { | |
+ m_papoClass[m_nClassCount-1] = m_papoClass[m_nClassCount-2]; | |
+ m_papoClass[m_nClassCount-2] = poNewClass; | |
+ return m_nClassCount-2; | |
+ } | |
+ else | |
+ { | |
m_papoClass[m_nClassCount-1] = poNewClass; | |
- | |
return m_nClassCount-1; | |
} | |
+} | |
/************************************************************************/ | |
/* ClearClasses() */ | |
@@ -545,7 +555,7 @@ | |
{ | |
if( poClass->IsSchemaLocked() ) | |
{ | |
- CPLDebug("GML","Encountered property missing from class schema."); | |
+ CPLDebug("NAS","Encountered property missing from class schema."); | |
CPLFree(pszValue); | |
return; | |
} | |
Index: ogr/ogrsf_frmts/nas/ogrnasdatasource.cpp | |
=================================================================== | |
--- ogr/ogrsf_frmts/nas/ogrnasdatasource.cpp (revision 24046) | |
+++ ogr/ogrsf_frmts/nas/ogrnasdatasource.cpp (working copy) | |
@@ -1,5 +1,5 @@ | |
/****************************************************************************** | |
- * $Id: ogrgmldatasource.cpp 12743 2007-11-13 13:59:37Z dron $ | |
+ * $Id$ | |
* | |
* Project: OGR | |
* Purpose: Implements OGRNASDataSource class. | |
@@ -31,7 +31,7 @@ | |
#include "cpl_conv.h" | |
#include "cpl_string.h" | |
-CPL_CVSID("$Id: ogrgmldatasource.cpp 12743 2007-11-13 13:59:37Z dron $"); | |
+CPL_CVSID("$Id$"); | |
static const char *apszURNNames[] = | |
{ | |
@@ -237,8 +237,20 @@ | |
} | |
poRelationLayer = new OGRNASRelationLayer( this ); | |
- papoLayers[nLayers++] = poRelationLayer; | |
+ // keep delete the last layer | |
+ if( nLayers>0 && EQUAL( papoLayers[nLayers-1]->GetName(), "Delete" ) ) | |
+ { | |
+ papoLayers[nLayers] = papoLayers[nLayers-1]; | |
+ papoLayers[nLayers-1] = poRelationLayer; | |
+ } | |
+ else | |
+ { | |
+ papoLayers[nLayers] = poRelationLayer; | |
+ } | |
+ | |
+ nLayers++; | |
+ | |
return TRUE; | |
} | |
Index: ogr/ogrsf_frmts/nas/ogrnasdriver.cpp | |
=================================================================== | |
--- ogr/ogrsf_frmts/nas/ogrnasdriver.cpp (revision 24046) | |
+++ ogr/ogrsf_frmts/nas/ogrnasdriver.cpp (working copy) | |
@@ -1,5 +1,5 @@ | |
/****************************************************************************** | |
- * $Id: ogrgmldriver.cpp 10645 2007-01-18 02:22:39Z warmerdam $ | |
+ * $Id$ | |
* | |
* Project: OGR | |
* Purpose: OGRNASDriver implementation | |
@@ -30,7 +30,7 @@ | |
#include "ogr_nas.h" | |
#include "cpl_conv.h" | |
-CPL_CVSID("$Id: ogrgmldriver.cpp 10645 2007-01-18 02:22:39Z warmerdam $"); | |
+CPL_CVSID("$Id$"); | |
/************************************************************************/ | |
/* ~OGRNASDriver() */ | |
Index: ogr/ogrsf_frmts/nas/nasreaderp.h | |
=================================================================== | |
--- ogr/ogrsf_frmts/nas/nasreaderp.h (revision 24046) | |
+++ ogr/ogrsf_frmts/nas/nasreaderp.h (working copy) | |
@@ -1,5 +1,5 @@ | |
/****************************************************************************** | |
- * $Id: gmlreaderp.h 10645 2007-01-18 02:22:39Z warmerdam $ | |
+ * $Id$ | |
* | |
* Project: NAS Reader | |
* Purpose: Private Declarations for OGR NAS Reader code. | |
@@ -65,6 +65,8 @@ | |
int m_bIgnoreFeature; | |
CPLString m_osLastTypeName; | |
+ CPLString m_osLastReplacingFID; | |
+ CPLString m_osLastSafeToIgnore; | |
public: | |
NASHandler( NASReader *poReader ); | |
Index: ogr/ogrsf_frmts/nas/ogr_nas.h | |
=================================================================== | |
--- ogr/ogrsf_frmts/nas/ogr_nas.h (revision 24046) | |
+++ ogr/ogrsf_frmts/nas/ogr_nas.h (working copy) | |
@@ -1,5 +1,5 @@ | |
/****************************************************************************** | |
- * $Id: ogr_gml.h 10645 2007-01-18 02:22:39Z warmerdam $ | |
+ * $Id$ | |
* | |
* Project: NAS Reader | |
* Purpose: Declarations for OGR wrapper classes for NAS, and NAS<->OGR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment