Quantum GIS API Documentation
1.8
|
00001 /*************************************************************************** 00002 qgsgeometryanalyzer.h - QGIS Tools for vector geometry analysis 00003 ------------------- 00004 begin : 19 March 2009 00005 copyright : (C) Carson Farmer 00006 email : [email protected] 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef QGSGEOMETRYANALYZERH 00019 #define QGSGEOMETRYANALYZERH 00020 00021 #include "qgsvectorlayer.h" 00022 #include "qgsfield.h" 00023 #include "qgsfeature.h" 00024 #include "qgsgeometry.h" 00025 #include "qgsfield.h" 00026 #include "qgsdistancearea.h" 00027 00028 class QgsVectorFileWriter; 00029 class QProgressDialog; 00030 00031 00036 class ANALYSIS_EXPORT QgsGeometryAnalyzer 00037 { 00038 public: 00039 00048 bool simplify( QgsVectorLayer* layer, const QString& shapefileName, double tolerance, 00049 bool onlySelectedFeatures = false, QProgressDialog* p = 0 ); 00050 00058 bool centroids( QgsVectorLayer* layer, const QString& shapefileName, 00059 bool onlySelectedFeatures = false, QProgressDialog* p = 0 ); 00060 00067 bool extent( QgsVectorLayer* layer, const QString& shapefileName, bool onlySelectedFeatures = false, QProgressDialog* p = 0 ); 00068 00078 bool buffer( QgsVectorLayer* layer, const QString& shapefileName, double bufferDistance, 00079 bool onlySelectedFeatures = false, bool dissolve = false, int bufferDistanceField = -1, QProgressDialog* p = 0 ); 00080 00089 bool convexHull( QgsVectorLayer* layer, const QString& shapefileName, bool onlySelectedFeatures = false, 00090 int uniqueIdField = -1, QProgressDialog* p = 0 ); 00091 00100 bool dissolve( QgsVectorLayer* layer, const QString& shapefileName, bool onlySelectedFeatures = false, 00101 int uniqueIdField = -1, QProgressDialog* p = 0 ); 00102 00120 bool eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer* eventLayer, int lineField, int eventField, QList<int>& unlocatedFeatureIds, const QString& outputLayer, 00121 const QString& outputFormat, int locationField1, int locationField2 = -1, int offsetField = -1, double offsetScale = 1.0, 00122 bool forceSingleGeometry = false, QgsVectorDataProvider* memoryProvider = 0, QProgressDialog* p = 0 ); 00123 00125 QgsGeometry* locateBetweenMeasures( double fromMeasure, double toMeasure, QgsGeometry* lineGeom ); 00128 QgsGeometry* locateAlongMeasure( double measure, QgsGeometry* lineGeom ); 00129 00130 private: 00131 00132 QList<double> simpleMeasure( QgsGeometry* geometry ); 00133 double perimeterMeasure( QgsGeometry* geometry, QgsDistanceArea& measure ); 00135 void simplifyFeature( QgsFeature& f, QgsVectorFileWriter* vfw, double tolerance ); 00137 void centroidFeature( QgsFeature& f, QgsVectorFileWriter* vfw ); 00139 void bufferFeature( QgsFeature& f, int nProcessedFeatures, QgsVectorFileWriter* vfw, bool dissolve, QgsGeometry** dissolveGeometry, 00140 double bufferDistance, int bufferDistanceField ); 00142 void convexFeature( QgsFeature& f, int nProcessedFeatures, QgsGeometry** dissolveGeometry ); 00144 void dissolveFeature( QgsFeature& f, int nProcessedFeatures, QgsGeometry** dissolveGeometry ); 00145 00146 //helper functions for event layer 00147 void addEventLayerFeature( QgsFeature& feature, QgsGeometry* geom, QgsGeometry* lineGeom, QgsVectorFileWriter* fileWriter, QgsFeatureList& memoryFeatures, int offsetField = -1, double offsetScale = 1.0, 00148 bool forceSingleType = false ); 00153 void createOffsetGeometry( QgsGeometry* geom, QgsGeometry* lineGeom, double offset ); 00154 QgsPoint createPointOffset( double x, double y, double dist, QgsGeometry* lineGeom ) const; 00155 unsigned char* locateBetweenWkbString( unsigned char* ptr, QgsMultiPolyline& result, double fromMeasure, double toMeasure ); 00156 unsigned char* locateAlongWkbString( unsigned char* ptr, QgsMultiPoint& result, double measure ); 00157 static bool clipSegmentByRange( double x1, double y1, double m1, double x2, double y2, double m2, double range1, double range2, QgsPoint& pt1, QgsPoint& pt2, bool& secondPointClipped ); 00158 static void locateAlongSegment( double x1, double y1, double m1, double x2, double y2, double m2, double measure, bool& pt1Ok, QgsPoint& pt1, bool& pt2Ok, QgsPoint& pt2 ); 00159 }; 00160 #endif //QGSVECTORANALYZER