本文整理汇总了C++中GeometryFactory::CreateGeometryFromWKB方法的典型用法代码示例。如果您正苦于以下问题:C++ GeometryFactory::CreateGeometryFromWKB方法的具体用法?C++ GeometryFactory::CreateGeometryFromWKB怎么用?C++ GeometryFactory::CreateGeometryFromWKB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeometryFactory
的用法示例。
在下文中一共展示了GeometryFactory::CreateGeometryFromWKB方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateGeometry
Geometry* FeatureShp::CreateGeometry(long index, SHPHandle pSHPHandle)
{
if(pSHPHandle==NULL)
{
return NULL;
}
int iWKBLen = 0;
g_uchar* pWKB = NULL;
Geometry* pGeometry = NULL;
SHPObject* pSHPObject = NULL;
GeometryFactory* pGeometryFactory = augeGetGeometryFactoryInstance();
pSHPObject = ::SHPReadObject(pSHPHandle, index);
if(pSHPObject==NULL)
{
return NULL;
}
iWKBLen = ShpUtil::GetWKBLength(pSHPObject);
if(iWKBLen==0)
{
::SHPDestroyObject(pSHPObject);
return NULL;
}
pWKB = (g_uchar*)auge_malloc(iWKBLen,sizeof(g_uchar));
if(pWKB==NULL)
{
::SHPDestroyObject(pSHPObject);
return NULL;
}
memset(pWKB, 0, iWKBLen);
if(ShpUtil::SHPObject_2_WKB(pSHPObject, pWKB, iWKBLen)==0)
{
delete[] pWKB;
::SHPDestroyObject(pSHPObject);
return NULL;
}
pGeometry = pGeometryFactory->CreateGeometryFromWKB(pWKB, true);
if(pGeometry==NULL)
{
delete[] pWKB;
}
::SHPDestroyObject(pSHPObject);
return pGeometry;
}
示例2: ProcessMultiPolygon
void PolygonToLineProcessorImpl::ProcessMultiPolygon(Feature* pinFeature, FeatureClass* poutFeatureClass, FeatureInsertCommand* cmd)
{
Geometry* pGeometry = NULL;
pGeometry = pinFeature->GetGeometry();
if(pGeometry==NULL)
{
return;
}
const char* fname = NULL;
GField* pField = NULL;
GFields* pFields = pinFeature->GetFeatureClass()->GetFields();
g_uint count = pFields->Count();
GValue* pValue = NULL;
GValue* pGeoValue = NULL;
Feature* poutFeature = poutFeatureClass->NewFeature();
augeFieldType type = augeFieldTypeNone;
for(g_uint i=0; i<count; i++)
{
pField = pFields->GetField(i);
type = pField->GetType();
if(type==augeFieldTypeGeometry)
{
continue;
}
fname = pField->GetName();
pValue = pinFeature->GetValue(i);
poutFeature->SetValue(fname, pValue);
}
Geometry* pGeoLine = NULL;
GeometryFactory* pGeometryFactory = augeGetGeometryFactoryInstance();
pField = pinFeature->GetFeatureClass()->GetFields()->GetGeometryField();
if(pField!=NULL)
{
pValue = pinFeature->GetValue(pField->GetName());
if(pValue!=NULL)
{
pGeometry = pValue->GetGeometry();
if(pGeometry!=NULL)
{
g_uint numPoints = 0;
g_uint numRings = 0;
g_uint numPolygons = 0;
g_uint ring_size = 0;
g_uint line_size = 0;
LinearRing* pLinearRing = NULL;
WKBPolygon* pWKBPolygon = NULL;
WKBMultiPolygon* pWKBMultiPolygon = (WKBMultiPolygon*)pGeometry->AsBinary();
WKBLineString* pWKBLineString = NULL;
g_byte* ptr = NULL;
numPolygons = pWKBMultiPolygon->numPolygons;
pWKBPolygon = (WKBPolygon*)(&(pWKBMultiPolygon->polygons[0]));
for(g_uint i=0; i<numPolygons; i++)
{
numRings = pWKBPolygon->numRings;
pLinearRing = (LinearRing*)(&(pWKBPolygon->rings[0]));
for(g_uint j=0; j<numRings; j++)
{
numPoints = pLinearRing->numPoints;
ring_size = sizeof(auge::Point) * numPoints + sizeof(g_int32);
line_size = ring_size + sizeof(g_int32) + sizeof(g_byte);
pWKBLineString = (WKBLineString*)malloc(line_size);
memset(pWKBLineString, 0, line_size);
pWKBLineString->byteOrder = coDefaultByteOrder;
pWKBLineString->wkbType = wkbLineString;
pWKBLineString->numPoints = numPoints;
memcpy(&(pWKBLineString->points[0]), &(pLinearRing->points[0]), sizeof(auge::Point) * numPoints);
pGeoLine = pGeometryFactory->CreateGeometryFromWKB((g_byte*)(pWKBLineString), true);
pGeoValue = new GValue(pGeoLine);
poutFeature->SetValue(pField->GetName(), pGeoValue);
cmd->Insert(poutFeature);
free(pWKBLineString);
ptr = (g_byte*)pLinearRing;
pLinearRing = (LinearRing*)(ptr + ring_size);
}
pWKBPolygon = (WKBPolygon*)pLinearRing;
}
}
}
}
poutFeature->Release();
}