本文整理汇总了C++中OGRGeometry::exportToKML方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRGeometry::exportToKML方法的具体用法?C++ OGRGeometry::exportToKML怎么用?C++ OGRGeometry::exportToKML使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRGeometry
的用法示例。
在下文中一共展示了OGRGeometry::exportToKML方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetLayerDefn
OGRErr OGRGFTTableLayer::ISetFeature( OGRFeature *poFeature )
{
GetLayerDefn();
if (!poDS->IsReadWrite())
{
CPLError(CE_Failure, CPLE_AppDefined,
"Operation not available in read-only mode");
return OGRERR_FAILURE;
}
if (osTableId.size() == 0)
{
CPLError(CE_Failure, CPLE_NotSupported,
"Cannot set feature to non-created table");
return OGRERR_FAILURE;
}
if (poDS->GetAccessToken().size() == 0)
{
CPLError(CE_Failure, CPLE_AppDefined,
"Operation not available in unauthenticated mode");
return OGRERR_FAILURE;
}
if (poFeature->GetFID() == OGRNullFID)
{
CPLError( CE_Failure, CPLE_AppDefined,
"FID required on features given to SetFeature()." );
return OGRERR_FAILURE;
}
CPLString osCommand;
osCommand += "UPDATE ";
osCommand += osTableId;
osCommand += " SET ";
int iField;
int nFieldCount = poFeatureDefn->GetFieldCount();
for(iField = 0; iField < nFieldCount + bHiddenGeometryField; iField++)
{
if (iField > 0)
osCommand += ", ";
if (iField == nFieldCount)
{
osCommand += EscapeAndQuote(GetGeometryColumn());
}
else
{
const char* pszFieldName =
poFeatureDefn->GetFieldDefn(iField)->GetNameRef();
osCommand += EscapeAndQuote(pszFieldName);
}
osCommand += " = ";
OGRGeometry* poGeom = poFeature->GetGeometryRef();
if (iGeometryField != iLatitudeField && iField == iGeometryField &&
(iField == nFieldCount || poGeom != NULL || !poFeature->IsFieldSet( iField )))
{
if (poGeom == NULL)
osCommand += "''";
else
{
char* pszKML;
if (poGeom->getSpatialReference() != NULL &&
!poGeom->getSpatialReference()->IsSame(poSRS))
{
OGRGeometry* poGeom4326 = poGeom->clone();
poGeom4326->transformTo(poSRS);
pszKML = poGeom4326->exportToKML();
delete poGeom4326;
}
else
{
pszKML = poGeom->exportToKML();
}
osCommand += "'";
osCommand += pszKML;
osCommand += "'";
CPLFree(pszKML);
}
continue;
}
if( !poFeature->IsFieldSet( iField ) )
{
osCommand += "''";
}
else
{
OGRFieldType eType = poFeatureDefn->GetFieldDefn(iField)->GetType();
if (eType != OFTInteger && eType != OFTReal)
{
CPLString osTmp;
const char* pszVal = poFeature->GetFieldAsString(iField);
if (!CPLIsUTF8(pszVal, -1))
//.........这里部分代码省略.........
示例2: ICreateFeature
OGRErr OGRGFTTableLayer::ICreateFeature( OGRFeature *poFeature )
{
if (!poDS->IsReadWrite())
{
CPLError(CE_Failure, CPLE_AppDefined,
"Operation not available in read-only mode");
return OGRERR_FAILURE;
}
if (osTableId.size() == 0)
{
CreateTableIfNecessary();
if (osTableId.size() == 0)
{
CPLError(CE_Failure, CPLE_NotSupported,
"Cannot add feature to non-created table");
return OGRERR_FAILURE;
}
}
if (poDS->GetAccessToken().size() == 0)
{
CPLError(CE_Failure, CPLE_AppDefined,
"Operation not available in unauthenticated mode");
return OGRERR_FAILURE;
}
CPLString osCommand;
osCommand += "INSERT INTO ";
osCommand += osTableId;
osCommand += " (";
int iField;
int nFieldCount = poFeatureDefn->GetFieldCount();
for(iField = 0; iField < nFieldCount; iField++)
{
if (iField > 0)
osCommand += ", ";
const char* pszFieldName =
poFeatureDefn->GetFieldDefn(iField)->GetNameRef();
osCommand += EscapeAndQuote(pszFieldName);
}
if (bHiddenGeometryField)
{
if (iField > 0)
osCommand += ", ";
osCommand += EscapeAndQuote(GetGeometryColumn());
}
osCommand += ") VALUES (";
for(iField = 0; iField < nFieldCount + bHiddenGeometryField; iField++)
{
if (iField > 0)
osCommand += ", ";
OGRGeometry* poGeom = poFeature->GetGeometryRef();
/* If there's a geometry, let's use it in priority over the textual */
/* content of the field. */
if (iGeometryField != iLatitudeField && iField == iGeometryField &&
(iField == nFieldCount || poGeom != NULL || !poFeature->IsFieldSet( iField )))
{
if (poGeom == NULL)
osCommand += "''";
else
{
char* pszKML;
if (poGeom->getSpatialReference() != NULL &&
!poGeom->getSpatialReference()->IsSame(poSRS))
{
OGRGeometry* poGeom4326 = poGeom->clone();
poGeom4326->transformTo(poSRS);
pszKML = poGeom4326->exportToKML();
delete poGeom4326;
}
else
{
pszKML = poGeom->exportToKML();
}
osCommand += "'";
osCommand += pszKML;
osCommand += "'";
CPLFree(pszKML);
}
continue;
}
if( !poFeature->IsFieldSet( iField ) )
{
osCommand += "''";
}
else
{
OGRFieldType eType = poFeatureDefn->GetFieldDefn(iField)->GetType();
if (eType != OFTInteger && eType != OFTReal)
{
CPLString osTmp;
const char* pszVal = poFeature->GetFieldAsString(iField);
//.........这里部分代码省略.........