Skip to content
Permalink
Browse files

faces

  • Loading branch information
blazek committed Mar 29, 2012
1 parent 1077410 commit 287bebe961a9a0a91781a0cf4f7b4a034f75edc4
@@ -853,6 +853,14 @@ QStringList GRASS_LIB_EXPORT QgsGrass::vectorLayers( QString gisdbase,
list.append( l );
}

/* Faces */
int nfaces = Vect_cidx_get_type_count( &map, field, GV_FACE );
if ( nfaces > 0 )
{
QString l = fs + "_face";
list.append( l );
}

/* Polygons */
int nareas = Vect_cidx_get_type_count( &map, field, GV_AREA );
if ( nareas > 0 )
@@ -143,6 +143,10 @@ QgsGrassProvider::QgsGrassProvider( QString uri )
{
mLayerType = LINE;
}
else if ( mGrassType == GV_FACE )
{
mLayerType = FACE;
}
else if ( mGrassType == GV_AREA )
{
mLayerType = POLYGON;
@@ -175,6 +179,7 @@ QgsGrassProvider::QgsGrassProvider( QString uri )
mQgisType = QGis::WKBLineString;
break;
case POLYGON:
case FACE:
mQgisType = QGis::WKBPolygon;
break;
}
@@ -347,7 +352,7 @@ bool QgsGrassProvider::nextFeature( QgsFeature& feature )
feature.clearAttributeMap();

// TODO int may be 64 bits (memcpy)
if ( type & ( GV_POINTS | GV_LINES ) ) /* points or lines */
if ( type & ( GV_POINTS | GV_LINES | GV_FACE ) ) /* points or lines */
{
Vect_read_line( mMap, mPoints, mCats, id );
int npoints = mPoints->n_points;
@@ -356,10 +361,14 @@ bool QgsGrassProvider::nextFeature( QgsFeature& feature )
{
wkbsize = 1 + 4 + 2 * 8;
}
else // GV_LINES
else if ( type & GV_LINES )
{
wkbsize = 1 + 4 + 4 + npoints * 2 * 8;
}
else // GV_FACE
{
wkbsize = 1 + 4 + 4 + 4 + npoints * 2 * 8;
}
wkb = new unsigned char[wkbsize];
unsigned char *wkbp = wkb;
wkbp[0] = ( unsigned char ) QgsApplication::endian();
@@ -369,9 +378,18 @@ bool QgsGrassProvider::nextFeature( QgsFeature& feature )
memcpy( wkbp, &mQgisType, 4 );
wkbp += 4;

/* Number of rings */
if ( type & GV_FACE )
{
int nrings = 1;
memcpy( wkbp, &nrings, 4 );
wkbp += 4;
}

/* number of points */
if ( type & GV_LINES )
if ( type & ( GV_LINES | GV_FACE ) )
{
QgsDebugMsg( QString( "set npoints = %1" ).arg( npoints ) );
memcpy( wkbp, &npoints, 4 );
wkbp += 4;
}
@@ -494,7 +512,7 @@ void QgsGrassProvider::select( QgsAttributeList fetchAttributes,
box.N = rect.yMaximum(); box.S = rect.yMinimum();
box.E = rect.xMaximum(); box.W = rect.xMinimum();
box.T = PORT_DOUBLE_MAX; box.B = -PORT_DOUBLE_MAX;
if ( mLayerType == POINT || mLayerType == CENTROID || mLayerType == LINE || mLayerType == BOUNDARY )
if ( mLayerType == POINT || mLayerType == CENTROID || mLayerType == LINE || mLayerType == FACE || mLayerType == BOUNDARY )
{
Vect_select_lines_by_box( mMap, &box, mGrassType, mList );
}
@@ -519,7 +537,7 @@ void QgsGrassProvider::select( QgsAttributeList fetchAttributes,
Vect_append_point( Polygon, rect.xMinimum(), rect.yMaximum(), 0 );
Vect_append_point( Polygon, rect.xMinimum(), rect.yMinimum(), 0 );

if ( mLayerType == POINT || mLayerType == CENTROID || mLayerType == LINE || mLayerType == BOUNDARY )
if ( mLayerType == POINT || mLayerType == CENTROID || mLayerType == LINE || mLayerType == FACE || mLayerType == BOUNDARY )
{
Vect_select_lines_by_polygon( mMap, Polygon, 0, NULL, mGrassType, mList );
}
@@ -1386,6 +1404,10 @@ int QgsGrassProvider::grassLayerType( QString name )
{
return GV_LINES;
}
else if ( ts.compare( "face" ) == 0 )
{
return GV_FACE;
}
else if ( ts.compare( "polygon" ) == 0 )
{
return GV_AREA;
@@ -2314,7 +2336,7 @@ QString *QgsGrassProvider::isOrphan( int field, int cat, int *orphan )
{
int t, id;
int ret = Vect_cidx_find_next( mMap, fieldIndex, cat,
GV_POINTS | GV_LINES, 0, &t, &id );
GV_POINTS | GV_LINES | GV_FACE, 0, &t, &id );

if ( ret >= 0 )
{
@@ -518,6 +518,7 @@ class GRASS_EXPORT QgsGrassProvider : public QgsVectorDataProvider
{
POINT = 1, // <field>_point
LINE, // <field>_line
FACE, // <field>_face
POLYGON, // <field>_polygon
BOUNDARY, // boundary (currently not used)
CENTROID // centroid (currently not used)

0 comments on commit 287bebe

Please sign in to comment.
You can’t perform that action at this time.