[Qgis-developer] Re: Vector layer
Martin Dobias
wonder.sk at gmail.com
Sat Jan 27 15:07:45 EST 2007
It's possible to do it in a way as you write. However the benefit of
drawing it as a canvas item would be that you don't need to render the
whole map when you change/add a feature.
If you're interested in creating a new layer and rendering it together
with other layers, you'll probably find out that API is not very
polished for this. Creating new features is complicated by the fact
that you need to specify the geometry in WKB. For adding new features
see QgsVectorLayer::addFeatures()
Martin
On 1/27/07, sploid <sploid at yandex.ru> wrote:
> Previously I use MapX for show map and I don't need to draw features, I only
> add features to vector layer and update map.
>
>
>
> I think code should look like this:
>
>
>
> QgsFeaturePoint *pNewPoint = new QgsFeaturePoint( x, y );
>
> pLayer->addFeature( pNewPoint );
>
> QgsFeatureLine *pNewLine = new QgsFeatureLine( x1, y1, x2, y2 );
>
> pLayer->addFeature( pNewLine );
>
> pLayer->update( );
>
>
>
> and that's all.
>
>
>
> I don't understand why I should use QgsRubberBand for draw basic objects.
>
>
>
> > What's the reason of not wanting to paint the features with
> > QgsRubberBand? It supports drawing polylines and polygons. For points
> > you can use QgsVertexMarker.
> >
> > Also you could subclass your own map canvas items to do the same job.
> > So far we don't have any tutorials on this topic but it's not hard.
> >
> > Martin
> >
> > On 1/27/07, sploid <sploid at yandex.ru> wrote:
> >> I would like to show some points / lines on map canvas, and i don't want
> >> to
> >> paint every feature using QgsRubberBand.
> >>
> >> > It's not clear from your question whether you'd like to create a
> >> > vector layer, add some features to it and save it as a shapefile or
> >> > whether you just would like to show some points / lines on map canvas.
> >> >
> >> > Tim's suggestion is for the latter case. For the former one, you must
> >> > create new data source with OGR provider, and add features to it using
> >> > provider's functions.
> >> >
> >> > Martin
> >> >
> >> > On 1/27/07, sploid <sploid at yandex.ru> wrote:
> >> >>
> >> >>
> >> >>
> >> >> How to create new temporary vector layer and add lines and points on
> >> >> it?
> >> >> _______________________________________________
> >> >> Qgis-developer mailing list
> >> >> Qgis-developer at lists.qgis.org
> >> >> http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
> >> >>
> >> >>
> >> >>
> >> >
> >>
> >>
> >>
> >
>
>
>
More information about the Qgis-developer
mailing list