Example #1
0
CPLXMLNode *OGR_G_ExportToGMLTree( OGRGeometryH hGeometry )

{
    char        *pszText;
    CPLXMLNode  *psTree;

    pszText = OGR_G_ExportToGML( hGeometry );
    if( pszText == NULL )
        return NULL;

    psTree = CPLParseXMLString( pszText );

    CPLFree( pszText );

    return psTree;
}
Example #2
0
char *OGRGeometry::exportToGML() const
{
    return OGR_G_ExportToGML( (OGRGeometryH) this );
}
bool QgsShapeFile::scanGeometries()
{
  QProgressDialog *sg = new QProgressDialog();
  sg->setMinimum( 0 );
  sg->setMaximum( 0 );
  QString label = tr( "Scanning " );
  label += fileName;
  sg->setLabel( new QLabel( label ) );
  sg->show();
  qApp->processEvents();

  OGRFeatureH feat;
  OGRwkbGeometryType currentType = wkbUnknown;
  bool multi = false;
  while (( feat = OGR_L_GetNextFeature( ogrLayer ) ) )
  {
    qApp->processEvents();

    //    feat->DumpReadable(NULL);
    OGRGeometryH geom = OGR_F_GetGeometryRef( feat );
    if ( geom )
    {
      QString gml =  OGR_G_ExportToGML( geom );
      // QgsDebugMsg(gml);
      if ( gml.indexOf( "gml:Multi" ) > -1 )
      {
        // QgsDebugMsg("MULTI Part Feature detected");
        multi = true;
      }
      OGRFeatureDefnH fDef = OGR_F_GetDefnRef( feat );
      OGRwkbGeometryType gType = OGR_FD_GetGeomType( fDef );
      // QgsDebugMsg(gType);
      if ( gType > currentType )
      {
        currentType = gType;
      }
      if ( gType < currentType )
      {
        QgsDebugMsg( QString( "Encountered inconsistent geometry type %1" ).arg( gType ) );
      }

    }
  }

  // a hack to support 2.5D geometries (their wkb is equivalent to 2D variants
  // except that the highest bit is set also). For now we will ignore 3rd coordinate.
  hasMoreDimensions = false;
  if ( currentType & wkb25DBit )
  {
    QgsDebugMsg( "Got a shapefile with 2.5D geometry." );
    currentType = wkbFlatten( currentType );
    hasMoreDimensions = true;
  }

  OGR_L_ResetReading( ogrLayer );
  geom_type = geometries[currentType];
  if ( multi && ( geom_type.indexOf( "MULTI" ) == -1 ) )
  {
    geom_type = "MULTI" + geom_type;
  }
  delete sg;

  // QgsDebugMsg(QString("Geometry type is %1 (%2)").arg(currentType).arg(geometries[currentType]));
  return multi;
}