Index: src/app/qgsoptions.cpp =================================================================== --- src/app/qgsoptions.cpp (Revision 7763) +++ src/app/qgsoptions.cpp (Arbeitskopie) @@ -142,6 +142,8 @@ cbxSplitterRedraw->setChecked(settings.value("/qgis/splitterRedraw", QVariant(true)).toBool()); + cbxInteriorLabels->setChecked(settings.value("/qgis/interiorLabels", QVariant(false)).toBool()); + // // Locale settings // @@ -262,6 +264,8 @@ settings.writeEntry("/qgis/zoom_factor", spinZoomFactor->value()); settings.setValue("/qgis/splitterRedraw", cbxSplitterRedraw->isChecked()); + settings.setValue("/qgis/interiorLabels", cbxInteriorLabels->isChecked()); + // // Locale settings // Index: src/core/qgsgeometry.cpp =================================================================== --- src/core/qgsgeometry.cpp (Revision 7763) +++ src/core/qgsgeometry.cpp (Arbeitskopie) @@ -2276,6 +2276,18 @@ return sqrDist; } +void QgsGeometry::interiorPoints(std::vector &points) +{ + exportWkbToGeos(); + + points.clear(); + + for(size_t i=0; igetNumGeometries(); i++) { + GEOS_GEOM::Point *p = mGeos->getGeometryN(i)->getInteriorPoint(); + points.push_back( QgsPoint( p->getX(), p->getY() ) ); + } +} + int QgsGeometry::addRing(const QList& ring) { //bail out if this geometry is not polygon/multipolygon @@ -3159,7 +3171,7 @@ bool QgsGeometry::exportWkbToGeos() { - QgsDebugMsg("QgsGeometry::exportWkbToGeos: entered."); + // QgsDebugMsg("QgsGeometry::exportWkbToGeos: entered."); if (!mDirtyGeos) { @@ -3238,7 +3250,7 @@ hasZValue = true; case QGis::WKBLineString: { - QgsDebugMsg("QgsGeometry::geosGeometry: Linestring found"); + // QgsDebugMsg("QgsGeometry::geosGeometry: Linestring found"); GEOS_GEOM::DefaultCoordinateSequence* sequence=new GEOS_GEOM::DefaultCoordinateSequence(); ptr = mGeometry + 5; @@ -3299,7 +3311,7 @@ hasZValue = true; case QGis::WKBPolygon: { - QgsDebugMsg("Polygon found"); + // QgsDebugMsg("Polygon found"); // get number of rings in the polygon numRings = (int *) (mGeometry + 1 + sizeof(int)); @@ -3349,7 +3361,7 @@ hasZValue = true; case QGis::WKBMultiPolygon: { - QgsDebugMsg("Multipolygon found"); + //QgsDebugMsg("Multipolygon found"); std::vector *polygons=new std::vector; // get the number of polygons Index: src/core/qgslabel.cpp =================================================================== --- src/core/qgslabel.cpp (Revision 7763) +++ src/core/qgslabel.cpp (Arbeitskopie) @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -457,44 +458,52 @@ void QgsLabel::labelPoint ( std::vector& points, QgsFeature & feature ) { - QgsGeometry* geometry = feature.geometry(); - unsigned char *geom = geometry->wkbBuffer(); - QGis::WKBTYPE wkbType = geometry->wkbType(); + QSettings settings; + if( settings.value("/qgis/interiorLabels").toBool() ) + { + feature.geometry()->interiorPoints(points); + } + else + { + QgsGeometry* geometry = feature.geometry(); + unsigned char *geom = geometry->wkbBuffer(); + QGis::WKBTYPE wkbType = geometry->wkbType(); - QgsPoint point; + QgsPoint point; - switch (wkbType) - { - case QGis::WKBPoint25D: - case QGis::WKBPoint: - case QGis::WKBLineString25D: - case QGis::WKBLineString: - case QGis::WKBPolygon25D: - case QGis::WKBPolygon: + switch (wkbType) { - labelPoint(point, geom); - points.push_back(point); - } - break; - case QGis::WKBMultiPoint25D: - case QGis::WKBMultiPoint: - case QGis::WKBMultiLineString25D: - case QGis::WKBMultiLineString: - case QGis::WKBMultiPolygon25D: - case QGis::WKBMultiPolygon: - // Return a position for each individual in the multi-feature - { - int numFeatures = (int)(*(geom + 5)); - geom += 9; // now points to start of array of WKB's - for (int i = 0; i < numFeatures; ++i) + case QGis::WKBPoint25D: + case QGis::WKBPoint: + case QGis::WKBLineString25D: + case QGis::WKBLineString: + case QGis::WKBPolygon25D: + case QGis::WKBPolygon: { - geom = labelPoint(point, geom); + labelPoint(point, geom); points.push_back(point); } + break; + case QGis::WKBMultiPoint25D: + case QGis::WKBMultiPoint: + case QGis::WKBMultiLineString25D: + case QGis::WKBMultiLineString: + case QGis::WKBMultiPolygon25D: + case QGis::WKBMultiPolygon: + // Return a position for each individual in the multi-feature + { + int numFeatures = (int)(*(geom + 5)); + geom += 9; // now points to start of array of WKB's + for (int i = 0; i < numFeatures; ++i) + { + geom = labelPoint(point, geom); + points.push_back(point); + } + } + break; + default: + QgsDebugMsg("Unknown geometry type of " + QString::number(wkbType)); } - break; - default: - QgsDebugMsg("Unknown geometry type of " + QString::number(wkbType)); } } Index: src/core/qgsgeometry.h =================================================================== --- src/core/qgsgeometry.h (Revision 7763) +++ src/core/qgsgeometry.h (Arbeitskopie) @@ -236,6 +236,11 @@ QgsPoint& minDistPoint, QgsGeometryVertexIndex& beforeVertex); + /** + * Get interior points (e.g. for labels) + */ + void interiorPoints(std::vector& points); + /**Adds a new ring to this geometry. This makes only sense for polygon and multipolygons. @return 0 in case of success (ring added), 1 problem with geometry type, 2 ring not closed, \ 3 ring is not valid geometry, 4 ring not disjoint with existing rings, 5 no polygon found which contained the ring*/ Index: src/ui/qgsoptionsbase.ui =================================================================== --- src/ui/qgsoptionsbase.ui (Revision 7763) +++ src/ui/qgsoptionsbase.ui (Arbeitskopie) @@ -427,6 +427,13 @@ + + + + Render labels inside areas (slower) + + +