OGRErr OGRGeoJSONWriteLayer::ICreateFeature( OGRFeature* poFeature ) { VSILFILE* fp = poDS_->GetOutputFile(); if( NULL == poFeature ) { CPLDebug( "GeoJSON", "Feature is null" ); return OGRERR_INVALID_HANDLE; } json_object* poObj = OGRGeoJSONWriteFeature( poFeature, bWriteBBOX, nCoordPrecision ); CPLAssert( NULL != poObj ); if( nOutCounter_ > 0 ) { /* Separate "Feature" entries in "FeatureCollection" object. */ VSIFPrintfL( fp, ",\n" ); } VSIFPrintfL( fp, "%s", json_object_to_json_string( poObj ) ); json_object_put( poObj ); ++nOutCounter_; OGRGeometry* poGeometry = poFeature->GetGeometryRef(); if ( bWriteBBOX && !poGeometry->IsEmpty() ) { OGREnvelope3D sEnvelope; poGeometry->getEnvelope(&sEnvelope); if( poGeometry->getCoordinateDimension() == 3 ) bBBOX3D = TRUE; sEnvelopeLayer.Merge(sEnvelope); } return OGRERR_NONE; }
json_object* OGRGeoJSONWriteFeature( OGRFeature* poFeature, int bWriteBBOX, int nCoordPrecision ) { CPLAssert( NULL != poFeature ); json_object* poObj = json_object_new_object(); CPLAssert( NULL != poObj ); json_object_object_add( poObj, "type", json_object_new_string("Feature") ); /* -------------------------------------------------------------------- */ /* Write FID if available */ /* -------------------------------------------------------------------- */ if ( poFeature->GetFID() != OGRNullFID ) { json_object_object_add( poObj, "id", json_object_new_int64(poFeature->GetFID()) ); } /* -------------------------------------------------------------------- */ /* Write feature attributes to GeoJSON "properties" object. */ /* -------------------------------------------------------------------- */ json_object* poObjProps = NULL; poObjProps = OGRGeoJSONWriteAttributes( poFeature ); json_object_object_add( poObj, "properties", poObjProps ); /* -------------------------------------------------------------------- */ /* Write feature geometry to GeoJSON "geometry" object. */ /* Null geometries are allowed, according to the GeoJSON Spec. */ /* -------------------------------------------------------------------- */ json_object* poObjGeom = NULL; OGRGeometry* poGeometry = poFeature->GetGeometryRef(); if ( NULL != poGeometry ) { poObjGeom = OGRGeoJSONWriteGeometry( poGeometry, nCoordPrecision ); if ( bWriteBBOX && !poGeometry->IsEmpty() ) { OGREnvelope3D sEnvelope; poGeometry->getEnvelope(&sEnvelope); json_object* poObjBBOX = json_object_new_array(); json_object_array_add(poObjBBOX, json_object_new_double_with_precision(sEnvelope.MinX, nCoordPrecision)); json_object_array_add(poObjBBOX, json_object_new_double_with_precision(sEnvelope.MinY, nCoordPrecision)); if (poGeometry->getCoordinateDimension() == 3) json_object_array_add(poObjBBOX, json_object_new_double_with_precision(sEnvelope.MinZ, nCoordPrecision)); json_object_array_add(poObjBBOX, json_object_new_double_with_precision(sEnvelope.MaxX, nCoordPrecision)); json_object_array_add(poObjBBOX, json_object_new_double_with_precision(sEnvelope.MaxY, nCoordPrecision)); if (poGeometry->getCoordinateDimension() == 3) json_object_array_add(poObjBBOX, json_object_new_double_with_precision(sEnvelope.MaxZ, nCoordPrecision)); json_object_object_add( poObj, "bbox", poObjBBOX ); } } json_object_object_add( poObj, "geometry", poObjGeom ); return poObj; }
OGRErr OGRGeoconceptLayer::CreateFeature( OGRFeature* poFeature ) { OGRwkbGeometryType eGt; OGRGeometry* poGeom; int nextField, iGeom, nbGeom, isSingle; poGeom= poFeature->GetGeometryRef(); if (poGeom == NULL) { CPLError( CE_Warning, CPLE_NotSupported, "NULL geometry not supported in Geoconcept, feature skipped.\n"); return OGRERR_NONE; } eGt= poGeom->getGeometryType(); switch( eGt ) { case wkbPoint : case wkbPoint25D : case wkbMultiPoint : case wkbMultiPoint25D : if( GetSubTypeKind_GCIO(_gcFeature)==vUnknownItemType_GCIO ) { SetSubTypeKind_GCIO(_gcFeature,vPoint_GCIO); } else if( GetSubTypeKind_GCIO(_gcFeature)!=vPoint_GCIO ) { CPLError( CE_Failure, CPLE_NotSupported, "Can't write non ponctual feature in a ponctual Geoconcept layer %s.\n", _poFeatureDefn->GetName()); return OGRERR_FAILURE; } break; case wkbLineString : case wkbLineString25D : case wkbMultiLineString : case wkbMultiLineString25D : if( GetSubTypeKind_GCIO(_gcFeature)==vUnknownItemType_GCIO ) { SetSubTypeKind_GCIO(_gcFeature,vLine_GCIO); } else if( GetSubTypeKind_GCIO(_gcFeature)!=vLine_GCIO ) { CPLError( CE_Failure, CPLE_NotSupported, "Can't write non linear feature in a linear Geoconcept layer %s.\n", _poFeatureDefn->GetName()); return OGRERR_FAILURE; } break; case wkbPolygon : case wkbPolygon25D : case wkbMultiPolygon : case wkbMultiPolygon25D : if( GetSubTypeKind_GCIO(_gcFeature)==vUnknownItemType_GCIO ) { SetSubTypeKind_GCIO(_gcFeature,vPoly_GCIO); } else if( GetSubTypeKind_GCIO(_gcFeature)!=vPoly_GCIO ) { CPLError( CE_Failure, CPLE_NotSupported, "Can't write non polygonal feature in a polygonal Geoconcept layer %s.\n", _poFeatureDefn->GetName()); return OGRERR_FAILURE; } break; case wkbUnknown : case wkbGeometryCollection : case wkbGeometryCollection25D : case wkbNone : case wkbLinearRing : default : CPLError( CE_Warning, CPLE_AppDefined, "Geometry type %s not supported in Geoconcept, feature skipped.\n", OGRGeometryTypeToName(eGt) ); return OGRERR_NONE; } if( GetSubTypeDim_GCIO(_gcFeature)==vUnknown3D_GCIO ) { if( poGeom->getCoordinateDimension()==3 ) { SetSubTypeDim_GCIO(_gcFeature,v3D_GCIO); } else { SetSubTypeDim_GCIO(_gcFeature,v2D_GCIO); } } switch( eGt ) { case wkbPoint : case wkbPoint25D : nbGeom= 1; isSingle= TRUE; break; case wkbMultiPoint : case wkbMultiPoint25D : nbGeom= ((OGRGeometryCollection*)poGeom)->getNumGeometries(); isSingle= FALSE; break; case wkbLineString : case wkbLineString25D : nbGeom= 1; isSingle= TRUE; break; case wkbMultiLineString : case wkbMultiLineString25D : nbGeom= ((OGRGeometryCollection*)poGeom)->getNumGeometries(); isSingle= FALSE; break; case wkbPolygon : case wkbPolygon25D : nbGeom= 1; isSingle= TRUE; break; case wkbMultiPolygon : case wkbMultiPolygon25D : nbGeom= ((OGRGeometryCollection*)poGeom)->getNumGeometries(); isSingle= FALSE; break; case wkbUnknown : case wkbGeometryCollection : case wkbGeometryCollection25D : case wkbNone : case wkbLinearRing : default : nbGeom= 0; isSingle= FALSE; break; } /* 1st feature, let's write header : */ if( GetGCMode_GCIO(GetSubTypeGCHandle_GCIO(_gcFeature)) == vWriteAccess_GCIO && GetFeatureCount(TRUE) == 0 ) if( WriteHeader_GCIO(GetSubTypeGCHandle_GCIO(_gcFeature))==NULL ) { return OGRERR_FAILURE; } if( nbGeom>0 ) { for( iGeom= 0; iGeom<nbGeom; iGeom++ ) { nextField= StartWritingFeature_GCIO(_gcFeature, isSingle? poFeature->GetFID():OGRNullFID); while (nextField!=WRITECOMPLETED_GCIO) { if( nextField==WRITEERROR_GCIO ) { return OGRERR_FAILURE; } if( nextField==GEOMETRYEXPECTED_GCIO ) { OGRGeometry* poGeomPart= isSingle? poGeom:((OGRGeometryCollection*)poGeom)->getGeometryRef(iGeom); nextField= WriteFeatureGeometry_GCIO(_gcFeature, (OGRGeometryH)poGeomPart); } else { int iF, nF; OGRFieldDefn *poField; GCField* theField= GetSubTypeField_GCIO(_gcFeature,nextField); /* for each field, find out its mapping ... */ if( (nF= poFeature->GetFieldCount())>0 ) { for( iF= 0; iF<nF; iF++ ) { poField= poFeature->GetFieldDefnRef(iF); char* pszName = OGRGeoconceptLayer_GetCompatibleFieldName(poField->GetNameRef()); if( EQUAL(pszName, GetFieldName_GCIO(theField)) ) { CPLFree(pszName); nextField= WriteFeatureFieldAsString_GCIO(_gcFeature, nextField, poFeature->IsFieldSet(iF)? poFeature->GetFieldAsString(iF) : NULL); break; } CPLFree(pszName); } if( iF==nF ) { CPLError( CE_Failure, CPLE_AppDefined, "Can't find a field attached to %s on Geoconcept layer %s.\n", GetFieldName_GCIO(theField), _poFeatureDefn->GetName()); return OGRERR_FAILURE; } } else { nextField= WRITECOMPLETED_GCIO; } } } StopWritingFeature_GCIO(_gcFeature); } } return OGRERR_NONE; }
OGRErr OGRGeoJSONWriteLayer::ICreateFeature( OGRFeature* poFeature ) { VSILFILE* fp = poDS_->GetOutputFile(); OGRFeature* poFeatureToWrite; if( poCT_ != nullptr || bRFC7946_ ) { poFeatureToWrite = new OGRFeature(poFeatureDefn_); poFeatureToWrite->SetFrom( poFeature ); poFeatureToWrite->SetFID( poFeature->GetFID() ); OGRGeometry* poGeometry = poFeatureToWrite->GetGeometryRef(); if( poGeometry ) { const char* const apszOptions[] = { "WRAPDATELINE=YES", nullptr }; OGRGeometry* poNewGeom = OGRGeometryFactory::transformWithOptions( poGeometry, poCT_, const_cast<char**>(apszOptions), oTransformCache_); if( poNewGeom == nullptr ) { delete poFeatureToWrite; return OGRERR_FAILURE; } OGREnvelope sEnvelope; poNewGeom->getEnvelope(&sEnvelope); if( sEnvelope.MinX < -180.0 || sEnvelope.MaxX > 180.0 || sEnvelope.MinY < -90.0 || sEnvelope.MaxY > 90.0 ) { CPLError(CE_Failure, CPLE_AppDefined, "Geometry extent outside of [-180.0,180.0]x[-90.0,90.0] bounds"); delete poFeatureToWrite; return OGRERR_FAILURE; } poFeatureToWrite->SetGeometryDirectly( poNewGeom ); } } else { poFeatureToWrite = poFeature; } json_object* poObj = OGRGeoJSONWriteFeature( poFeatureToWrite, oWriteOptions_ ); CPLAssert( nullptr != poObj ); if( nOutCounter_ > 0 ) { /* Separate "Feature" entries in "FeatureCollection" object. */ VSIFPrintfL( fp, ",\n" ); } VSIFPrintfL( fp, "%s", json_object_to_json_string( poObj ) ); json_object_put( poObj ); ++nOutCounter_; OGRGeometry* poGeometry = poFeatureToWrite->GetGeometryRef(); if( bWriteFC_BBOX && poGeometry != nullptr && !poGeometry->IsEmpty() ) { OGREnvelope3D sEnvelope = OGRGeoJSONGetBBox( poGeometry, oWriteOptions_ ); if( poGeometry->getCoordinateDimension() == 3 ) bBBOX3D = true; if( !sEnvelopeLayer.IsInit() ) { sEnvelopeLayer = sEnvelope; } else if( oWriteOptions_.bBBOXRFC7946 ) { const bool bEnvelopeCrossAM = ( sEnvelope.MinX > sEnvelope.MaxX ); const bool bEnvelopeLayerCrossAM = ( sEnvelopeLayer.MinX > sEnvelopeLayer.MaxX ); if( bEnvelopeCrossAM ) { if( bEnvelopeLayerCrossAM ) { sEnvelopeLayer.MinX = std::min(sEnvelopeLayer.MinX, sEnvelope.MinX); sEnvelopeLayer.MaxX = std::max(sEnvelopeLayer.MaxX, sEnvelope.MaxX); } else { if( sEnvelopeLayer.MinX > 0 ) { sEnvelopeLayer.MinX = std::min(sEnvelopeLayer.MinX, sEnvelope.MinX); sEnvelopeLayer.MaxX = sEnvelope.MaxX; } else if( sEnvelopeLayer.MaxX < 0 ) { sEnvelopeLayer.MaxX = std::max(sEnvelopeLayer.MaxX, sEnvelope.MaxX); sEnvelopeLayer.MinX = sEnvelope.MinX; } else { sEnvelopeLayer.MinX = -180.0; sEnvelopeLayer.MaxX = 180.0; } } } else if( bEnvelopeLayerCrossAM ) { if( sEnvelope.MinX > 0 ) { sEnvelopeLayer.MinX = std::min(sEnvelopeLayer.MinX, sEnvelope.MinX); } else if( sEnvelope.MaxX < 0 ) { sEnvelopeLayer.MaxX = std::max(sEnvelopeLayer.MaxX, sEnvelope.MaxX); } else { sEnvelopeLayer.MinX = -180.0; sEnvelopeLayer.MaxX = 180.0; } } else { sEnvelopeLayer.MinX = std::min(sEnvelopeLayer.MinX, sEnvelope.MinX); sEnvelopeLayer.MaxX = std::max(sEnvelopeLayer.MaxX, sEnvelope.MaxX); } sEnvelopeLayer.MinY = std::min(sEnvelopeLayer.MinY, sEnvelope.MinY); sEnvelopeLayer.MaxY = std::max(sEnvelopeLayer.MaxY, sEnvelope.MaxY); } else { sEnvelopeLayer.Merge(sEnvelope); } } if( poFeatureToWrite != poFeature ) delete poFeatureToWrite; return OGRERR_NONE; }
OGRErr OGRGMLLayer::ICreateFeature( OGRFeature *poFeature ) { int bIsGML3Output = poDS->IsGML3Output(); VSILFILE *fp = poDS->GetOutputFP(); int bWriteSpaceIndentation = poDS->WriteSpaceIndentation(); const char* pszPrefix = poDS->GetAppPrefix(); int bRemoveAppPrefix = poDS->RemoveAppPrefix(); if( !bWriter ) return OGRERR_FAILURE; poFeature->FillUnsetWithDefault(TRUE, NULL); if( !poFeature->Validate( OGR_F_VAL_ALL & ~OGR_F_VAL_GEOM_TYPE & ~OGR_F_VAL_ALLOW_NULL_WHEN_DEFAULT, TRUE ) ) return OGRERR_FAILURE; if (bWriteSpaceIndentation) VSIFPrintfL(fp, " "); if (bIsGML3Output) { if( bRemoveAppPrefix ) poDS->PrintLine( fp, "<featureMember>" ); else poDS->PrintLine( fp, "<%s:featureMember>", pszPrefix ); } else poDS->PrintLine( fp, "<gml:featureMember>" ); if( iNextGMLId == 0 ) { bSameSRS = true; for( int iGeomField = 1; iGeomField < poFeatureDefn->GetGeomFieldCount(); iGeomField++ ) { OGRGeomFieldDefn *poFieldDefn0 = poFeatureDefn->GetGeomFieldDefn(0); OGRGeomFieldDefn *poFieldDefn = poFeatureDefn->GetGeomFieldDefn(iGeomField); OGRSpatialReference* poSRS0 = poFieldDefn0->GetSpatialRef(); OGRSpatialReference* poSRS = poFieldDefn->GetSpatialRef(); if( poSRS0 != NULL && poSRS == NULL ) bSameSRS = false; else if( poSRS0 == NULL && poSRS != NULL ) bSameSRS = false; else if( poSRS0 != NULL && poSRS != NULL && poSRS0 != poSRS && !poSRS0->IsSame(poSRS) ) { bSameSRS = false; } } } if( poFeature->GetFID() == OGRNullFID ) poFeature->SetFID( iNextGMLId++ ); int nGMLIdIndex = -1; if (bWriteSpaceIndentation) VSIFPrintfL(fp, " "); VSIFPrintfL(fp, "<"); if( !bRemoveAppPrefix ) VSIFPrintfL(fp, "%s:", pszPrefix); if (bIsGML3Output) { nGMLIdIndex = poFeatureDefn->GetFieldIndex("gml_id"); if (nGMLIdIndex >= 0 && poFeature->IsFieldSet( nGMLIdIndex ) ) poDS->PrintLine( fp, "%s gml:id=\"%s\">", poFeatureDefn->GetName(), poFeature->GetFieldAsString(nGMLIdIndex) ); else poDS->PrintLine( fp, "%s gml:id=\"%s." CPL_FRMT_GIB "\">", poFeatureDefn->GetName(), poFeatureDefn->GetName(), poFeature->GetFID() ); } else { nGMLIdIndex = poFeatureDefn->GetFieldIndex("fid"); if (bUseOldFIDFormat) { poDS->PrintLine( fp, "%s fid=\"F" CPL_FRMT_GIB "\">", poFeatureDefn->GetName(), poFeature->GetFID() ); } else if (nGMLIdIndex >= 0 && poFeature->IsFieldSet( nGMLIdIndex ) ) { poDS->PrintLine( fp, "%s fid=\"%s\">", poFeatureDefn->GetName(), poFeature->GetFieldAsString(nGMLIdIndex) ); } else { poDS->PrintLine( fp, "%s fid=\"%s." CPL_FRMT_GIB "\">", poFeatureDefn->GetName(), poFeatureDefn->GetName(), poFeature->GetFID() ); } } for( int iGeomField = 0; iGeomField < poFeatureDefn->GetGeomFieldCount(); iGeomField++ ) { OGRGeomFieldDefn *poFieldDefn = poFeatureDefn->GetGeomFieldDefn(iGeomField); // Write out Geometry - for now it isn't indented properly. /* GML geometries don't like very much the concept of empty geometry */ OGRGeometry* poGeom = poFeature->GetGeomFieldRef(iGeomField); if( poGeom != NULL && !poGeom->IsEmpty()) { char *pszGeometry; OGREnvelope3D sGeomBounds; int nCoordDimension = poGeom->getCoordinateDimension(); poGeom->getEnvelope( &sGeomBounds ); if( bSameSRS ) poDS->GrowExtents( &sGeomBounds, nCoordDimension ); if (poGeom->getSpatialReference() == NULL && poFieldDefn->GetSpatialRef() != NULL) poGeom->assignSpatialReference(poFieldDefn->GetSpatialRef()); if (bIsGML3Output && poDS->WriteFeatureBoundedBy()) { bool bCoordSwap; char* pszSRSName = GML_GetSRSName(poGeom->getSpatialReference(), poDS->IsLongSRSRequired(), &bCoordSwap); char szLowerCorner[75], szUpperCorner[75]; if (bCoordSwap) { OGRMakeWktCoordinate(szLowerCorner, sGeomBounds.MinY, sGeomBounds.MinX, sGeomBounds.MinZ, nCoordDimension); OGRMakeWktCoordinate(szUpperCorner, sGeomBounds.MaxY, sGeomBounds.MaxX, sGeomBounds.MaxZ, nCoordDimension); } else { OGRMakeWktCoordinate(szLowerCorner, sGeomBounds.MinX, sGeomBounds.MinY, sGeomBounds.MinZ, nCoordDimension); OGRMakeWktCoordinate(szUpperCorner, sGeomBounds.MaxX, sGeomBounds.MaxY, sGeomBounds.MaxZ, nCoordDimension); } if (bWriteSpaceIndentation) VSIFPrintfL(fp, " "); poDS->PrintLine( fp, "<gml:boundedBy><gml:Envelope%s%s><gml:lowerCorner>%s</gml:lowerCorner><gml:upperCorner>%s</gml:upperCorner></gml:Envelope></gml:boundedBy>", (nCoordDimension == 3) ? " srsDimension=\"3\"" : "",pszSRSName, szLowerCorner, szUpperCorner); CPLFree(pszSRSName); } char** papszOptions = (bIsGML3Output) ? CSLAddString(NULL, "FORMAT=GML3") : NULL; if (bIsGML3Output && !poDS->IsLongSRSRequired()) papszOptions = CSLAddString(papszOptions, "GML3_LONGSRS=NO"); const char* pszSRSDimensionLoc = poDS->GetSRSDimensionLoc(); if( pszSRSDimensionLoc != NULL ) papszOptions = CSLSetNameValue(papszOptions, "SRSDIMENSION_LOC", pszSRSDimensionLoc); if (poDS->IsGML32Output()) { if( poFeatureDefn->GetGeomFieldCount() > 1 ) papszOptions = CSLAddString(papszOptions, CPLSPrintf("GMLID=%s.%s." CPL_FRMT_GIB, poFeatureDefn->GetName(), poFieldDefn->GetNameRef(), poFeature->GetFID())); else papszOptions = CSLAddString(papszOptions, CPLSPrintf("GMLID=%s.geom." CPL_FRMT_GIB, poFeatureDefn->GetName(), poFeature->GetFID())); } if( !bIsGML3Output && OGR_GT_IsNonLinear(poGeom->getGeometryType()) ) { OGRGeometry* poGeomTmp = OGRGeometryFactory::forceTo( poGeom->clone(),OGR_GT_GetLinear(poGeom->getGeometryType())); pszGeometry = poGeomTmp->exportToGML(papszOptions); delete poGeomTmp; } else pszGeometry = poGeom->exportToGML(papszOptions); CSLDestroy(papszOptions); if (bWriteSpaceIndentation) VSIFPrintfL(fp, " "); if( bRemoveAppPrefix ) poDS->PrintLine( fp, "<%s>%s</%s>", poFieldDefn->GetNameRef(), pszGeometry, poFieldDefn->GetNameRef() ); else poDS->PrintLine( fp, "<%s:%s>%s</%s:%s>", pszPrefix, poFieldDefn->GetNameRef(), pszGeometry, pszPrefix, poFieldDefn->GetNameRef() ); CPLFree( pszGeometry ); } } // Write all "set" fields. for( int iField = 0; iField < poFeatureDefn->GetFieldCount(); iField++ ) { OGRFieldDefn *poFieldDefn = poFeatureDefn->GetFieldDefn( iField ); if( poFeature->IsFieldSet( iField ) && iField != nGMLIdIndex ) { OGRFieldType eType = poFieldDefn->GetType(); if (eType == OFTStringList ) { char ** papszIter = poFeature->GetFieldAsStringList( iField ); while( papszIter != NULL && *papszIter != NULL ) { char *pszEscaped = OGRGetXML_UTF8_EscapedString( *papszIter ); GMLWriteField(poDS, fp, bWriteSpaceIndentation, pszPrefix, bRemoveAppPrefix, poFieldDefn, pszEscaped); CPLFree( pszEscaped ); papszIter ++; } } else if (eType == OFTIntegerList ) { int nCount = 0; const int* panVals = poFeature->GetFieldAsIntegerList( iField, &nCount ); if( poFieldDefn->GetSubType() == OFSTBoolean ) { for(int i = 0; i < nCount; i++) { /* 0 and 1 are OK, but the canonical representation is false and true */ GMLWriteField(poDS, fp, bWriteSpaceIndentation, pszPrefix, bRemoveAppPrefix, poFieldDefn, panVals[i] ? "true" : "false"); } } else { for(int i = 0; i < nCount; i++) { GMLWriteField(poDS, fp, bWriteSpaceIndentation, pszPrefix, bRemoveAppPrefix, poFieldDefn, CPLSPrintf("%d", panVals[i])); } } } else if (eType == OFTInteger64List ) { int nCount = 0; const GIntBig* panVals = poFeature->GetFieldAsInteger64List( iField, &nCount ); if( poFieldDefn->GetSubType() == OFSTBoolean ) { for(int i = 0; i < nCount; i++) { /* 0 and 1 are OK, but the canonical representation is false and true */ GMLWriteField(poDS, fp, bWriteSpaceIndentation, pszPrefix, bRemoveAppPrefix, poFieldDefn, panVals[i] ? "true" : "false"); } } else { for(int i = 0; i < nCount; i++) { GMLWriteField(poDS, fp, bWriteSpaceIndentation, pszPrefix, bRemoveAppPrefix, poFieldDefn, CPLSPrintf(CPL_FRMT_GIB, panVals[i])); } } } else if (eType == OFTRealList ) { int nCount = 0; const double* padfVals = poFeature->GetFieldAsDoubleList( iField, &nCount ); for(int i = 0; i < nCount; i++) { char szBuffer[80]; CPLsnprintf( szBuffer, sizeof(szBuffer), "%.15g", padfVals[i]); GMLWriteField(poDS, fp, bWriteSpaceIndentation, pszPrefix, bRemoveAppPrefix, poFieldDefn, szBuffer); } } else if ((eType == OFTInteger || eType == OFTInteger64) && poFieldDefn->GetSubType() == OFSTBoolean ) { /* 0 and 1 are OK, but the canonical representation is false and true */ GMLWriteField(poDS, fp, bWriteSpaceIndentation, pszPrefix, bRemoveAppPrefix, poFieldDefn, (poFeature->GetFieldAsInteger(iField)) ? "true" : "false"); } else { const char *pszRaw = poFeature->GetFieldAsString( iField ); char *pszEscaped = OGRGetXML_UTF8_EscapedString( pszRaw ); GMLWriteField(poDS, fp, bWriteSpaceIndentation, pszPrefix, bRemoveAppPrefix, poFieldDefn, pszEscaped); CPLFree( pszEscaped ); } } } if (bWriteSpaceIndentation) VSIFPrintfL(fp, " "); if( bRemoveAppPrefix ) poDS->PrintLine( fp, "</%s>", poFeatureDefn->GetName() ); else poDS->PrintLine( fp, "</%s:%s>", pszPrefix, poFeatureDefn->GetName() ); if (bWriteSpaceIndentation) VSIFPrintfL(fp, " "); if (bIsGML3Output) { if( bRemoveAppPrefix ) poDS->PrintLine( fp, "</featureMember>" ); else poDS->PrintLine( fp, "</%s:featureMember>", pszPrefix ); } else poDS->PrintLine( fp, "</gml:featureMember>" ); return OGRERR_NONE; }