Skip to content

Commit 287bebe

Browse files
committed
faces
1 parent 1077410 commit 287bebe

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

src/providers/grass/qgsgrass.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,14 @@ QStringList GRASS_LIB_EXPORT QgsGrass::vectorLayers( QString gisdbase,
853853
list.append( l );
854854
}
855855

856+
/* Faces */
857+
int nfaces = Vect_cidx_get_type_count( &map, field, GV_FACE );
858+
if ( nfaces > 0 )
859+
{
860+
QString l = fs + "_face";
861+
list.append( l );
862+
}
863+
856864
/* Polygons */
857865
int nareas = Vect_cidx_get_type_count( &map, field, GV_AREA );
858866
if ( nareas > 0 )

src/providers/grass/qgsgrassprovider.cpp

+28-6
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ QgsGrassProvider::QgsGrassProvider( QString uri )
143143
{
144144
mLayerType = LINE;
145145
}
146+
else if ( mGrassType == GV_FACE )
147+
{
148+
mLayerType = FACE;
149+
}
146150
else if ( mGrassType == GV_AREA )
147151
{
148152
mLayerType = POLYGON;
@@ -175,6 +179,7 @@ QgsGrassProvider::QgsGrassProvider( QString uri )
175179
mQgisType = QGis::WKBLineString;
176180
break;
177181
case POLYGON:
182+
case FACE:
178183
mQgisType = QGis::WKBPolygon;
179184
break;
180185
}
@@ -347,7 +352,7 @@ bool QgsGrassProvider::nextFeature( QgsFeature& feature )
347352
feature.clearAttributeMap();
348353

349354
// TODO int may be 64 bits (memcpy)
350-
if ( type & ( GV_POINTS | GV_LINES ) ) /* points or lines */
355+
if ( type & ( GV_POINTS | GV_LINES | GV_FACE ) ) /* points or lines */
351356
{
352357
Vect_read_line( mMap, mPoints, mCats, id );
353358
int npoints = mPoints->n_points;
@@ -356,10 +361,14 @@ bool QgsGrassProvider::nextFeature( QgsFeature& feature )
356361
{
357362
wkbsize = 1 + 4 + 2 * 8;
358363
}
359-
else // GV_LINES
364+
else if ( type & GV_LINES )
360365
{
361366
wkbsize = 1 + 4 + 4 + npoints * 2 * 8;
362367
}
368+
else // GV_FACE
369+
{
370+
wkbsize = 1 + 4 + 4 + 4 + npoints * 2 * 8;
371+
}
363372
wkb = new unsigned char[wkbsize];
364373
unsigned char *wkbp = wkb;
365374
wkbp[0] = ( unsigned char ) QgsApplication::endian();
@@ -369,9 +378,18 @@ bool QgsGrassProvider::nextFeature( QgsFeature& feature )
369378
memcpy( wkbp, &mQgisType, 4 );
370379
wkbp += 4;
371380

381+
/* Number of rings */
382+
if ( type & GV_FACE )
383+
{
384+
int nrings = 1;
385+
memcpy( wkbp, &nrings, 4 );
386+
wkbp += 4;
387+
}
388+
372389
/* number of points */
373-
if ( type & GV_LINES )
390+
if ( type & ( GV_LINES | GV_FACE ) )
374391
{
392+
QgsDebugMsg( QString( "set npoints = %1" ).arg( npoints ) );
375393
memcpy( wkbp, &npoints, 4 );
376394
wkbp += 4;
377395
}
@@ -494,7 +512,7 @@ void QgsGrassProvider::select( QgsAttributeList fetchAttributes,
494512
box.N = rect.yMaximum(); box.S = rect.yMinimum();
495513
box.E = rect.xMaximum(); box.W = rect.xMinimum();
496514
box.T = PORT_DOUBLE_MAX; box.B = -PORT_DOUBLE_MAX;
497-
if ( mLayerType == POINT || mLayerType == CENTROID || mLayerType == LINE || mLayerType == BOUNDARY )
515+
if ( mLayerType == POINT || mLayerType == CENTROID || mLayerType == LINE || mLayerType == FACE || mLayerType == BOUNDARY )
498516
{
499517
Vect_select_lines_by_box( mMap, &box, mGrassType, mList );
500518
}
@@ -519,7 +537,7 @@ void QgsGrassProvider::select( QgsAttributeList fetchAttributes,
519537
Vect_append_point( Polygon, rect.xMinimum(), rect.yMaximum(), 0 );
520538
Vect_append_point( Polygon, rect.xMinimum(), rect.yMinimum(), 0 );
521539

522-
if ( mLayerType == POINT || mLayerType == CENTROID || mLayerType == LINE || mLayerType == BOUNDARY )
540+
if ( mLayerType == POINT || mLayerType == CENTROID || mLayerType == LINE || mLayerType == FACE || mLayerType == BOUNDARY )
523541
{
524542
Vect_select_lines_by_polygon( mMap, Polygon, 0, NULL, mGrassType, mList );
525543
}
@@ -1386,6 +1404,10 @@ int QgsGrassProvider::grassLayerType( QString name )
13861404
{
13871405
return GV_LINES;
13881406
}
1407+
else if ( ts.compare( "face" ) == 0 )
1408+
{
1409+
return GV_FACE;
1410+
}
13891411
else if ( ts.compare( "polygon" ) == 0 )
13901412
{
13911413
return GV_AREA;
@@ -2314,7 +2336,7 @@ QString *QgsGrassProvider::isOrphan( int field, int cat, int *orphan )
23142336
{
23152337
int t, id;
23162338
int ret = Vect_cidx_find_next( mMap, fieldIndex, cat,
2317-
GV_POINTS | GV_LINES, 0, &t, &id );
2339+
GV_POINTS | GV_LINES | GV_FACE, 0, &t, &id );
23182340

23192341
if ( ret >= 0 )
23202342
{

src/providers/grass/qgsgrassprovider.h

+1
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ class GRASS_EXPORT QgsGrassProvider : public QgsVectorDataProvider
518518
{
519519
POINT = 1, // <field>_point
520520
LINE, // <field>_line
521+
FACE, // <field>_face
521522
POLYGON, // <field>_polygon
522523
BOUNDARY, // boundary (currently not used)
523524
CENTROID // centroid (currently not used)

0 commit comments

Comments
 (0)