<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=KOI8-R" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Barry Rowlingson пишет:
<blockquote
cite="midd8ad40b50903260100y32c16849te56c7c673e5b8a89@mail.gmail.com"
type="cite">
<pre wrap="">[oops, meant to Reply to the list but didn't! Sorry if you get this twice!]
2009/3/26 Голубев Анатолий <a class="moz-txt-link-rfc2396E" href="mailto:golubev@nordcomp.ru"><golubev@nordcomp.ru></a>:
</pre>
<blockquote type="cite">
<pre wrap="">Hi, list! Can someone write a simple example or algorithm to
programmatically add features to empty vector layer?
</pre>
</blockquote>
<pre wrap=""><!---->
Python or C++?
Here's some python code from one of my plugins:
<a class="moz-txt-link-freetext" href="http://code.google.com/p/bsrplugins/source/browse/trunk/topocolour/adjlayer.py">http://code.google.com/p/bsrplugins/source/browse/trunk/topocolour/adjlayer.py</a>
The 'make' function creates a new vector layer called 'vl' using the
'memory' provider. The layer has 'LineString' features (line 8). Each
feature has three attributes (lines 11-13).
Then a loop adds some features using information from the 'ig' object
passed in.
* construct a QgsGeometry object from some QPoint() objects
(QgsgeometryFromPolyline)
* set the geometry of the feature (fet.setGeometry) and add the
attributes (fet.setAttributes).
* add the feature to the layer provider (pr.addFeatures).
Once that's done you may want to add the layer to the Qgis map registry.
Translating this to C++ should be fairly simple. Hope this helps.
Barry
</pre>
</blockquote>
Thanks for answer, this helps alot.<br>
</body>
</html>