[QGIS Commit] r10358 - branches/analysis_branch/src/analysis/vector
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Mar 21 11:13:42 EDT 2009
Author: cfarmer
Date: 2009-03-21 11:13:42 -0400 (Sat, 21 Mar 2009)
New Revision: 10358
Modified:
branches/analysis_branch/src/analysis/vector/qgsgeometryanalyzer.cpp
branches/analysis_branch/src/analysis/vector/qgsgeometryanalyzer.h
Log:
fix previous problematic commit
Modified: branches/analysis_branch/src/analysis/vector/qgsgeometryanalyzer.cpp
===================================================================
--- branches/analysis_branch/src/analysis/vector/qgsgeometryanalyzer.cpp 2009-03-21 14:18:11 UTC (rev 10357)
+++ branches/analysis_branch/src/analysis/vector/qgsgeometryanalyzer.cpp 2009-03-21 15:13:42 UTC (rev 10358)
@@ -39,7 +39,7 @@
// allAttrs = vprovider.attributeIndexes()
QgsAttributeList allAttrs = provider->attributeIndexes();
// vprovider.select( allAttrs )
- provider->select( allAttr, QgsRectangle(), true );
+ provider->select( allAttrs, QgsRectangle(), true );
// fields = vprovider.fields()
// const QgsFieldsList& fields = provider->fields();
// writer = QgsVectorFileWriter( self.myName, self.myEncoding,
@@ -48,12 +48,7 @@
fileEncoding, provider->fields(), provider->geometryType(), provider->crs() );
// check whether file creation was successful
- WriterError err = writer->hasError();
- if ( err != NoError )
- {
- delete writer;
- return err;
- }
+
// inFeat = QgsFeature()
QgsFeature inFeat;
// outFeat = QgsFeature()
@@ -91,7 +86,7 @@
for ( int it = unique.begin(); it != unique.end(); ++it )
{
- provider->select( allAttr, QgsRectangle(), true );
+ provider->select( allAttrs, QgsRectangle(), true );
// vprovider.rewind()
// multi_feature= []
// first = True
@@ -172,78 +167,74 @@
*/
}
+
bool QgsGeometryAnalyzer::extractNodes( QgsVectorLayer* layer,
const QString& shapefileName,
const QString& fileEncoding )
{
- QgsVectorDataProvider* provider = layer->dataProvider();
+/* QgsVectorDataProvider* provider = layer->dataProvider();
QgsAttributeList allAttrs = provider->attributeIndexes();
- provider->select( allAttr, QgsRectangle(), true );
- QgsVectorFileWriter* writer = new QgsVectorFileWriter( shapefileName,
- fileEncoding, provider->fields(), QGis::WKBPoint, provider->crs() );
-
- WriterError err = writer->hasError();
- if ( err != NoError )
- {
- delete writer;
- return err;
- }
-
+ provider->select( allAttrs, QgsRectangle(), true );
+ const QgsCoordinateReferenceSystem* outputCRS;
+ outputCRS = &layer->srs();
+ QgsVectorFileWriter* writer = new QgsVectorFileWriter( shapefileName,
+ fileEncoding, provider->fields(), QGis::WKBPoint, outputCRS );
+
QgsFeature inFeat;
QgsFeature outFeat;
QgsGeometry inGeom;
QgsGeometry outGeom;
- QList<QgsPoint> pointList;
+ QgsPolyline pointList;
+ QgsPoint point;
while ( provider->nextFeature( inFeat ) )
{
pointList = extractPoints( inFeat.geometry() );
outFeat.setAttributeMap( inFeat.attributeMap() );
- for ( QList<QgsPoint>::const_iterator point = pointList.constBegin(); point != pointList.constEnd(); ++point )
+ for ( QgsPolyline::iterator point = pointList.begin(); point != pointList.end(); point++ )
{
- outFeat.setGeometry( outGeom.fromPoint( point ) )
- writer.addFeature( outFeat )
+ QgsGeometry* point = QgsGeometry::fromPoint( point );
+ outFeat.setGeometry( point );
+ writer.addFeature( outFeat );
}
}
delete writer;
return true;
+ */
}
bool QgsGeometryAnalyzer::polygonsToLines( QgsVectorLayer* layer,
const QString& shapefileName,
const QString& fileEncoding )
{
+/*
QgsVectorDataProvider* provider = layer->dataProvider();
QgsAttributeList allAttrs = provider->attributeIndexes();
- provider->select( allAttr, QgsRectangle(), true );
+ provider->select( allAttrs, QgsRectangle(), true );
QgsVectorFileWriter* writer = new QgsVectorFileWriter( shapefileName,
fileEncoding, provider->fields(), QGis::WKBPoint, provider->crs() );
- WriterError err = writer->hasError();
- if ( err != NoError )
- {
- delete writer;
- return err;
- }
+
QgsFeature inFeat;
QgsFeature outFeat;
QgsGeometry inGeom;
QgsGeometry outGeom;
- QList<QgsPolyline> linetList;
+ QList<QgsPolyline> lineList;
while ( provider->nextFeature( inFeat ) )
{
- lineList = extractLines( inFeat.geometry() )
- outFeat.setAttributeMap( inFeat.attributeMap() )
- for ( QList<QgsPolyline>::const_iterator line = lineList.constBegin(); line != lineList.constEnd(); ++line )
+ lineList = QgsGeometryAnalyzer::extractLines( inFeat.geometry() );
+ outFeat.setAttributeMap( inFeat.attributeMap() );
+ for ( line = lineList.begin(); line != lineList.end(); line++ )
{
- outFeat.setGeometry( outGeom.fromPolyline( line ) )
- writer.addFeature( outFeat )
+ outFeat.setGeometry( outGeom.fromPolyline( line ) );
+ writer.addFeature( outFeat );
}
}
delete writer;
return true;
+ */
}
bool QgsGeometryAnalyzer::exportGeometryInformation( QgsVectorLayer* layer,
@@ -287,17 +278,10 @@
{
QgsVectorDataProvider* provider = layer->dataProvider();
QgsAttributeList allAttrs = provider->attributeIndexes();
- provider->select( allAttr, QgsRectangle(), true );
+ provider->select( allAttrs, QgsRectangle(), true );
QgsVectorFileWriter* writer = new QgsVectorFileWriter( shapefileName,
fileEncoding, provider->fields(), provider->geometryType(), provider->crs() );
-
- WriterError err = writer->hasError();
- if ( err != NoError )
- {
- delete writer;
- return err;
- }
-
+
QgsFeature inFeat;
QgsFeature outFeat;
QgsGeometry inGeom;
@@ -361,15 +345,10 @@
fields.insert( 9 , QgsField( QString( "WIDTH" ), QVariant.Double ) );
QgsVectorFileWriter* writer = new QgsVectorFileWriter( shapefileName,
- fileEncoding, fields, QGis::WKBPolygon, layer->dataProvider()->crs() );
+ fileEncoding, fields*, QGis::WKBPolygon, layer->dataProvider()->crs()* );
- WriterError err = writer->hasError();
- if ( err != NoError )
- {
- delete writer;
- return err;
- }
+
QgsRectangle rect;
rect = layer->extent();
double minx = rect.xMinimum();
@@ -489,6 +468,7 @@
}
QgsGeometry QgsGeometryAnalyzer::extractLines( QgsGeometry& geometry )
{
+/*
QGis::WkbType wkbType = geometry.wkbType();
QList<QgsPolyline> lineList;
QgsMultiPolygon polyList
@@ -496,18 +476,22 @@
{
if ( geometry.isMultipart() )
{
- polyList = geometry.asMultiPolygon()
- for ( QList<QgsPolyline>::const_iterator polygon = polyList.constBegin(); polygon != polyList.constEnd(); ++polygon )
+ polyList = geometry.asMultiPolygon();
+ for ( polygon = polyList.begin(); polygon != polyList.end(); polygon++ )
{
- lineList << line
+ for ( lines = polygon.begin(); lines != polygon.end(); lines++ )
+ {
+ lineList << lines;
+ }
}
else
{
- lineList = geom.asPolygon()
+ lineList = geometry.asPolygon();
}
}
}
return lineList
+ */
}
QgsGeometry QgsGeometryAnalyzer::extractAsSingle( QgsGeometry& geometry )
{
@@ -606,11 +590,11 @@
*/
}
-QList<QgsPoint> QgsGeometryAnalyzer::extractPoints( QgsGeometry& geometry )
+QList<QgsPoint> QgsGeometryAnalyzer::extractPoints( QgsGeometry geometry* )
{
- QGis::WkbType wkbType = geometry.wkbType();
+/* QGis::WkbType wkbType = geometry.wkbType();
QList<QgsPoint> pointList;
- QgsPolyline lineList;
+ QList<QgsPolyline> lineList;
switch ( wkbType )
{
case QGis::WKBPoint25D:
@@ -618,8 +602,8 @@
case QGis::WKBMultiLineString25D:
case QGis::WKBMultiLineString:
{
- geometry->convertToMultitype()
- pointList = geometry.asMultiPoint()
+ geometry->convertToMultitype();
+ pointList = geometry.asMultiPoint();
break;
}
case QGis::WKBLineString25D:
@@ -627,11 +611,11 @@
case QGis::WKBMultiLineString25D:
case QGis::WKBMultiLineString:
{
- geometry->convertToMultitype()
- lineList = geometry.asMultiPolyline()
- for ( QList<QgsPolyline>::const_iterator line = lineList.constBegin(); line != lineList.constEnd(); ++line )
+ geometry->convertToMultitype();
+ lineList = geometry.asMultiPolyline();
+ for ( line = lineList.begin(); line != lineList.end(); line++ )
{
- pointList << line
+ pointList << line;
}
break;
}
@@ -640,13 +624,13 @@
case QGis::WKBMultiPolygon25D:
case QGis::WKBMultiPolygon:
{
- geometry->convertToMultitype()
- QgsPolygon polyList = geometry.asMultiPolygon()
- for ( QList<QgsPolygon>::const_iterator lineList = polyList.constBegin(); lineList != polyList.constEnd(); ++lineList )
+ geometry->convertToMultitype();
+ QgsPolygon polyList = geometry.asMultiPolygon();
+ for ( lineList = polyList.begin(); lineList != polyList.end(); lineList++ )
{
- for ( QList<QgsPolyline>::const_iterator line = lineList.constBegin(); line != lineList.constEnd(); ++line )
+ for ( line = lineList.begin(); line != lineList.end(); line++ )
{
- pointList << line
+ pointList << line;
}
}
break;
@@ -655,4 +639,5 @@
break;
}
return pointList;
+ */
}
Modified: branches/analysis_branch/src/analysis/vector/qgsgeometryanalyzer.h
===================================================================
--- branches/analysis_branch/src/analysis/vector/qgsgeometryanalyzer.h 2009-03-21 14:18:11 UTC (rev 10357)
+++ branches/analysis_branch/src/analysis/vector/qgsgeometryanalyzer.h 2009-03-21 15:13:42 UTC (rev 10358)
@@ -55,7 +55,6 @@
/**
* Extract nodes from line and polygon vector layers and output them as
* points.
- *
* */
bool extractNodes( QgsVectorLayer* layer,
const QString& shapefileName,
@@ -111,7 +110,7 @@
QgsGeometry extractAsSingle( QgsGeometry& geometry );
QgsGeometry extractAsMulti( QgsGeometry& geometry );
QgsGeometry convertGeometry( QgsGeometry& geometry );
- QList<QPoint> extractPoints( QgsGeometry& geometry );
+ QgsPolyline extractPoints( QgsGeometry* geometry );
};
#endif //QGSVECTORANALYZER
More information about the QGIS-commit
mailing list