[Qgis-developer] Vector File Creatioin and documentation

maaza mekuria sailmcm at yahoo.com
Wed Sep 28 15:48:36 EDT 2011


Since I never heard from anyone. But I tried a few things and I resorted to using an "ESRI Shape File" provider (instead of "ogr") in the QgsVectorFileWriter instead of the QgsVectorLayer. The parameters are ill-defined and not properly documented. So I took the true and tired path of the past. I wrote the shapefiles to a directory using a piece of code that is shown below. It is not much different than the original but the provider is sure and it has worked for me in the past. 

void BNA::export2File(QgsVectorFileWriter* vr, FeatureMap&  mFeatureMap)
{

  if ( mFeatureMap.size()<=0)
    return;


  QgsFeature f;
 
  for ( FeatureMap::iterator it = mFeatureMap.begin(); it != mFeatureMap.end();it++)
  {
	  f = *it;
	  vr->addFeature( f );
  }
}


Can we do something to update the documentation? It is bugging me that I have to scratch my head and bang against the air and experiment to for so long before finding a solution. Is there a space for placing some sort of wiki documentation that anyone can contributes notes so that users benefit from the collective experiences of others. 

I posted the same question on the forum but that forum is not really very active except a few people who attempt to answer questions. Yet, it may be a good place to have the documentation if a wiki is not possible. 

What do you think?

Maaza

--- On Fri, 9/23/11, maaza mekuria <sailmcm at yahoo.com> wrote:

> From: maaza mekuria <sailmcm at yahoo.com>
> Subject: [Qgis-developer] Vector File Creatioin
> To: "QGIS Developer" <qgis-developer at lists.osgeo.org>
> Date: Friday, September 23, 2011, 3:50 PM
> I am wondering if I have to do to
> save the shape files. Below is the code I am using. I am
> able to create memory layers that I could save later. But I
> want to create many shapefiles and QGIS started to run out
> of memory when I was loading the memory shapefiles. Once I
> change the provider to OGR and give the path and basename,
> it gets a NULL provider.
> 
> Can some of the QGIS Master's help a novice? 
>  
> 
>       QString mPath = ("c:/tmp/qgis/");
>          QString mBaseName =
> ("BikeNA");
>          QString
> provLib="ogr";
>         QgsVectorLayer* vl = 0;
>         vl = new QgsVectorLayer( mPath,
> mBaseName, provLib );
>         QgsVectorDataProvider *prov =
> vl->dataProvider();
>         prov->addAttributes(
> attrList );
>       vl->startEditing();
>       QgsFeature f;
>       featureList::Iterator it;
>       for ( it = featureList.begin(); it !=
> featureList.end();it++)
>       {
>          f = *it;
>          vl->addFeature( f
> );
>       }
> 
>       vl->updateExtents();
>       vl->endEditCommand();
>       vl->commitChanges();
> 
> 
> 
> 
> maaza
> 
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
> 


More information about the Qgis-developer mailing list