[QGIS Commit] r10305 -
branches/analysis_branch/src/plugins/interpolation
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Thu Mar 19 14:05:23 EDT 2009
Author: mhugent
Date: 2009-03-19 14:05:23 -0400 (Thu, 19 Mar 2009)
New Revision: 10305
Removed:
branches/analysis_branch/src/plugins/interpolation/TriangleInterpolator.cc
branches/analysis_branch/src/plugins/interpolation/TriangleInterpolator.h
branches/analysis_branch/src/plugins/interpolation/Triangulation.cc
branches/analysis_branch/src/plugins/interpolation/Triangulation.h
branches/analysis_branch/src/plugins/interpolation/Vector3D.cc
branches/analysis_branch/src/plugins/interpolation/Vector3D.h
branches/analysis_branch/src/plugins/interpolation/qgisinterpolator.h
branches/analysis_branch/src/plugins/interpolation/qgsgridfilewriter.cpp
branches/analysis_branch/src/plugins/interpolation/qgsgridfilewriter.h
branches/analysis_branch/src/plugins/interpolation/qgsidwinterpolator.cpp
branches/analysis_branch/src/plugins/interpolation/qgsidwinterpolator.h
branches/analysis_branch/src/plugins/interpolation/qgsinterpolator.cpp
branches/analysis_branch/src/plugins/interpolation/qgsinterpolator.h
branches/analysis_branch/src/plugins/interpolation/qgstininterpolator.cpp
branches/analysis_branch/src/plugins/interpolation/qgstininterpolator.h
Log:
Remove more classes that went into analysis lib
Deleted: branches/analysis_branch/src/plugins/interpolation/TriangleInterpolator.cc
===================================================================
--- branches/analysis_branch/src/plugins/interpolation/TriangleInterpolator.cc 2009-03-19 17:57:05 UTC (rev 10304)
+++ branches/analysis_branch/src/plugins/interpolation/TriangleInterpolator.cc 2009-03-19 18:05:23 UTC (rev 10305)
@@ -1,3 +0,0 @@
-#include "TriangleInterpolator.h"
-
-//empty file, all methods are inline
Deleted: branches/analysis_branch/src/plugins/interpolation/TriangleInterpolator.h
===================================================================
--- branches/analysis_branch/src/plugins/interpolation/TriangleInterpolator.h 2009-03-19 17:57:05 UTC (rev 10304)
+++ branches/analysis_branch/src/plugins/interpolation/TriangleInterpolator.h 2009-03-19 18:05:23 UTC (rev 10305)
@@ -1,42 +0,0 @@
-/***************************************************************************
- TriangleInterpolator.h - description
- -------------------
- copyright : (C) 2004 by Marco Hugentobler
- email : mhugent at geo.unizh.ch
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#ifndef TINTERPOLATOR_H
-#define TINTERPOLATOR_H
-
-#include <Point3D.h>
-#include <Vector3D.h>
-
-/**This is an interface for interpolator classes for triangulations*/
-class TriangleInterpolator
-{
- public:
- virtual ~TriangleInterpolator() {}
- /**Calculates the normal vector and assigns it to vec*/
- virtual bool calcNormVec( double x, double y, Vector3D* result ) = 0;
- /**Performs a linear interpolation in a triangle and assigns the x-,y- and z-coordinates to point*/
- virtual bool calcPoint( double x, double y, Point3D* result ) = 0;
-};
-
-#endif
-
-
-
-
-
-
-
-
Deleted: branches/analysis_branch/src/plugins/interpolation/Triangulation.cc
===================================================================
--- branches/analysis_branch/src/plugins/interpolation/Triangulation.cc 2009-03-19 17:57:05 UTC (rev 10304)
+++ branches/analysis_branch/src/plugins/interpolation/Triangulation.cc 2009-03-19 18:05:23 UTC (rev 10305)
@@ -1,3 +0,0 @@
-#include "Triangulation.h"
-
-//empty file (abstract class)
Deleted: branches/analysis_branch/src/plugins/interpolation/Triangulation.h
===================================================================
--- branches/analysis_branch/src/plugins/interpolation/Triangulation.h 2009-03-19 17:57:05 UTC (rev 10304)
+++ branches/analysis_branch/src/plugins/interpolation/Triangulation.h 2009-03-19 18:05:23 UTC (rev 10305)
@@ -1,98 +0,0 @@
-/***************************************************************************
- Triangulation.h - description
- -------------------
- copyright : (C) 2004 by Marco Hugentobler
- email : mhugent at geo.unizh.ch
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#ifndef TRIANGULATION_H
-#define TRIANGULATION_H
-
-#include <QList>
-#include "Line3D.h"
-#include "Vector3D.h"
-#include <qpainter.h>
-#include "Line3D.h"
-#include <TriangleInterpolator.h>
-
-/**Interface for Triangulation classes*/
-class Triangulation
-{
- public:
- /**Enumeration describing the behaviour, if two forced lines cross. SnappingType_VERTICE means, that the second inserted forced line is snapped to the closest vertice of the first inserted forced line. DELETE_FIRST means, that the status of the first inserted forced line is reset to that of a normal edge (so that the second inserted forced line remain and the first not*/
- enum forcedCrossBehaviour {SnappingType_VERTICE, DELETE_FIRST, INSERT_VERTICE};
- virtual ~Triangulation();
- /**Adds a line (e.g. a break-, structure- or an isoline) to the triangulation*/
- virtual void addLine( Line3D* line, bool breakline ) = 0;
- /**Adds a point to the triangulation*/
- virtual int addPoint( Point3D* p ) = 0;
- /**Calculates the normal at a point on the surface and assigns it to 'result'. Returns true in case of success and flase in case of failure*/
- virtual bool calcNormal( double x, double y, Vector3D* result ) = 0;
- /**Performs a consistency check, remove this later*/
- virtual void performConsistencyTest() = 0;
- /**Calculates x-, y and z-value of the point on the surface and assigns it to 'result'. Returns true in case of success and flase in case of failure*/
- virtual bool calcPoint( double x, double y, Point3D* result ) = 0;
- /**Returns a pointer to the point with number i. Any virtual points must have the number -1*/
- virtual Point3D* getPoint( unsigned int i ) const = 0;
- /**Finds out, in which triangle the point with coordinates x and y is and assigns the numbers of the vertices to 'n1', 'n2' and 'n3' and the vertices to 'p1', 'p2' and 'p3'*/
- virtual bool getTriangle( double x, double y, Point3D* p1, int* n1, Point3D* p2, int* n2, Point3D* p3, int* n3 ) = 0;
- /**Finds out, in which triangle the point with coordinates x and y is and assigns the points at the vertices to 'p1', 'p2' and 'p3*/
- virtual bool getTriangle( double x, double y, Point3D* p1, Point3D* p2, Point3D* p3 ) = 0;
- /**Returns the number of the point opposite to the triangle points p1, p2 (which have to be on a halfedge)*/
- virtual int getOppositePoint( int p1, int p2 ) = 0;
- /**Returns the largest x-coordinate value of the bounding box*/
- virtual double getXMax() const = 0;
- /**Returns the smallest x-coordinate value of the bounding box*/
- virtual double getXMin() const = 0;
- /**Returns the largest y-coordinate value of the bounding box*/
- virtual double getYMax() const = 0;
- /**Returns the smallest x-coordinate value of the bounding box*/
- virtual double getYMin() const = 0;
- /**Returns the number of points*/
- virtual int getNumberOfPoints() const = 0;
- /**Returns a pointer to a value list with the information of the triangles surrounding (counterclockwise) a point. Four integer values describe a triangle, the first three are the number of the half edges of the triangle and the fourth is -10, if the third (and most counterclockwise) edge is a breakline, and -20 otherwise. The value list has to be deleted by the code which called the method. Any virtual point needs to have the number -1*/
- virtual QList<int>* getSurroundingTriangles( int pointno ) = 0;
- /**Returns a value list with the numbers of the four points, which would be affected by an edge swap. This function is e.g. needed by NormVecDecorator to know the points, for which the normals have to be recalculated. The list has to be deleted by the code which calls this method*/
- virtual QList<int>* getPointsAroundEdge( double x, double y ) = 0;
- /**draws the points, edges and the forced lines*/
- //virtual void draw(QPainter* p, double xlowleft, double ylowleft, double xupright, double yupright, double width, double height) const=0;
- /**Sets the behaviour of the triangulation in case of crossing forced lines*/
- virtual void setForcedCrossBehaviour( Triangulation::forcedCrossBehaviour b ) = 0;
- /**Sets the color of the normal edges*/
- virtual void setEdgeColor( int r, int g, int b ) = 0;
- /**Sets the color of the forced edges*/
- virtual void setForcedEdgeColor( int r, int g, int b ) = 0;
- /**Sets the color of the breaklines*/
- virtual void setBreakEdgeColor( int r, int g, int b ) = 0;
- /**Sets an interpolator object*/
- virtual void setTriangleInterpolator( TriangleInterpolator* interpolator ) = 0;
- /**Eliminates the horizontal triangles by swapping*/
- virtual void eliminateHorizontalTriangles() = 0;
- /**Adds points to make the triangles better shaped (algorithm of ruppert)
- \param tin the triangulation or decorator which interpolates the elevation*/
- virtual void ruppertRefinement() = 0;
- /**Returns true, if the point with coordinates x and y is inside the convex hull and false otherwise*/
- virtual bool pointInside( double x, double y ) = 0;
- /**Reads the content of a taff-file*/
- //virtual bool readFromTAFF(QString fileName)=0;
- /**Saves the content to a taff file*/
- //virtual bool saveToTAFF(QString fileName) const=0;
- /**Swaps the edge which is closest to the point with x and y coordinates (if this is possible)*/
- virtual bool swapEdge( double x, double y ) = 0;
-};
-
-inline Triangulation::~Triangulation()
-{
-
-}
-
-#endif
Deleted: branches/analysis_branch/src/plugins/interpolation/Vector3D.cc
===================================================================
--- branches/analysis_branch/src/plugins/interpolation/Vector3D.cc 2009-03-19 17:57:05 UTC (rev 10304)
+++ branches/analysis_branch/src/plugins/interpolation/Vector3D.cc 2009-03-19 18:05:23 UTC (rev 10305)
@@ -1,48 +0,0 @@
-/***************************************************************************
- Vector3D.cc - description
- -------------------
- copyright : (C) 2004 by Marco Hugentobler
- email : mhugent at geo.unizh.ch
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include "Vector3D.h"
-
-double Vector3D::getLength() const
-{
- return sqrt( getX()*getX() + getY()*getY() + getZ()*getZ() );
-}
-
-void Vector3D::standardise()
-{
- double length = getLength();
- setX( getX() / length );
- setY( getY() / length );
- setZ( getZ() / length );
-}
-
-Vector3D& Vector3D::operator=( const Vector3D & v )
-{
- mX = v.mX;
- mY = v.mY;
- mZ = v.mZ;
- return ( *this );
-}
-
-bool Vector3D::operator==( const Vector3D& v )
-{
- return ( mX == v.getX() && mY == v.getY() && mZ == v.getZ() );
-}
-
-bool Vector3D::operator!=( const Vector3D& v )
-{
- return ( !(( *this ) == v ) );
-}
Deleted: branches/analysis_branch/src/plugins/interpolation/Vector3D.h
===================================================================
--- branches/analysis_branch/src/plugins/interpolation/Vector3D.h 2009-03-19 17:57:05 UTC (rev 10304)
+++ branches/analysis_branch/src/plugins/interpolation/Vector3D.h 2009-03-19 18:05:23 UTC (rev 10305)
@@ -1,149 +0,0 @@
-/***************************************************************************
- Vector3D.h - description
- -------------------
- copyright : (C) 2004 by Marco Hugentobler
- email : mhugent at geo.unizh.ch
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#ifndef VECTOR3D_H
-#define VECTOR3D_H
-
-#include <cmath>
-
-class Vector3D
- /**
- Class Vector3D represents a 3D-Vector, capable to store x-,y- and z-coordinates in double values. In fact, the class is the same as Point3D. The name 'vector' makes it easier to understand the programms.
- */
-
-{
- protected:
- /**X-component of the vector*/
- double mX;
- /**Y-component of the vector*/
- double mY;
- /**Z-component of the vector*/
- double mZ;
-
- public:
- /**Constructor taking the three components as arguments*/
- Vector3D( double x, double y, double z );
- /**Default constructor*/
- Vector3D();
- /**Copy constructor*/
- Vector3D( const Vector3D& v );
- /**Destructor*/
- ~Vector3D();
- Vector3D& operator=( const Vector3D& v );
- bool operator==( const Vector3D& v );
- bool operator!=( const Vector3D& v );
- /**Returns the x-component of the vector*/
- double getX() const;
- /**Returns the y-component of the vector*/
- double getY() const;
- /**Returns the z-component of the vector*/
- double getZ() const;
- /**Returns the length of the vector*/
- double getLength() const;
- /**Sets the x-component of the vector*/
- void setX( double x );
- /**Sets the y-component of the vector*/
- void setY( double y );
- /**Sets the z-component of the vector*/
- void setZ( double z );
- /**Standardises the vector*/
- void standardise();
-};
-
-//------------------------------------------constructors------------------------------------
-
-inline Vector3D::Vector3D( double x, double y, double z ) : mX( x ), mY( y ), mZ( z )
-{
-
-}
-
-inline Vector3D::Vector3D() : mX( 0 ), mY( 0 ), mZ( 0 )//using a list
-{
-
-}
-
-inline Vector3D::~Vector3D()
-{
-
-}
-
-//-------------------------------------------setter and getters-------------------------------
-
-inline double Vector3D::getX() const
-{
- return mX;
-}
-
-inline double Vector3D::getY() const
-{
- return mY;
-}
-
-inline double Vector3D::getZ() const
-{
- return mZ;
-}
-
-inline void Vector3D::setX( double x )
-{
- mX = x;
-}
-
-inline void Vector3D::setY( double y )
-{
- mY = y;
-}
-
-inline void Vector3D::setZ( double z )
-{
- mZ = z;
-}
-
-#endif
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Deleted: branches/analysis_branch/src/plugins/interpolation/qgisinterpolator.h
===================================================================
--- branches/analysis_branch/src/plugins/interpolation/qgisinterpolator.h 2009-03-19 17:57:05 UTC (rev 10304)
+++ branches/analysis_branch/src/plugins/interpolation/qgisinterpolator.h 2009-03-19 18:05:23 UTC (rev 10305)
@@ -1,71 +0,0 @@
-/***************************************************************************
- qgsinterpolator.h
- ------------------------
- begin : March 10, 2008
- copyright : (C) 2008 by Marco Hugentobler
- email : marco dot hugentobler at karto dot baug dot ethz dot ch
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#ifndef QGSINTERPOLATOR_H
-#define QGSINTERPOLATOR_H
-
-#include <QVector>
-
-class QgsVectorLayer;
-
-struct vertexData
-{
- double x;
- double y;
- double z;
-};
-
-/**Interface class for interpolations. Interpolators take
-the vertices of a vector layer as base data. The z-Value
-can be an attribute or the z-coordinates in case of 25D types*/
-class QgsInterpolator
-{
- public:
- QgsInterpolator( QgsVectorLayer* vlayer );
-
- virtual ~QgsInterpolator();
-
- /**Calculates interpolation value for map coordinates x, y
- @param x x-coordinate (in map units)
- @param y y-coordinate (in map units)
- @param result out: interpolation result
- @return 0 in case of success*/
- virtual int interpolatePoint( double x, double y, double& result ) = 0;
-
- /**Use the z-coord of 25D for interpolation*/
- void enableZCoordInterpolation() {useZCoord = true;}
-
- /**Use a vector attribute as interpolation value*/
- void enableAttributeValueInterpolation( int attribute );
-
- protected:
- /**Caches the vertex and value data from the provider. All the vertex data
- will be held in virtual memory
- @return 0 in case of success*/
- int cacheBaseData();
-
- QVector<vertexData> mCachedBaseData;
-
- private:
- QgsInterpolator(); //forbidden
- QgsVectorLayer* mVectorLayer;
-
- bool zCoordInterpolation;
- int mValueAttribute;
-};
-
-#endif
Deleted: branches/analysis_branch/src/plugins/interpolation/qgsgridfilewriter.cpp
===================================================================
--- branches/analysis_branch/src/plugins/interpolation/qgsgridfilewriter.cpp 2009-03-19 17:57:05 UTC (rev 10304)
+++ branches/analysis_branch/src/plugins/interpolation/qgsgridfilewriter.cpp 2009-03-19 18:05:23 UTC (rev 10305)
@@ -1,120 +0,0 @@
-/***************************************************************************
- qgsgridfilewriter.cpp
- ---------------------
- begin : Marco 10, 2008
- copyright : (C) 2008 by Marco Hugentobler
- email : marco dot hugentobler at karto dot baug dot ethz dot ch
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include "qgsgridfilewriter.h"
-#include "qgsinterpolator.h"
-#include <QFile>
-#include <QProgressDialog>
-
-QgsGridFileWriter::QgsGridFileWriter( QgsInterpolator* i, QString outputPath, QgsRectangle extent, int nCols, int nRows ): mInterpolator( i ), mOutputFilePath( outputPath ), mInterpolationExtent( extent ), mNumColumns( nCols ), mNumRows( nRows )
-{
- mCellSizeX = ( mInterpolationExtent.xMaximum() - mInterpolationExtent.xMinimum() ) / mNumColumns;
- mCellSizeY = ( mInterpolationExtent.yMaximum() - mInterpolationExtent.yMinimum() ) / mNumRows;
-}
-
-QgsGridFileWriter::QgsGridFileWriter(): mInterpolator( 0 )
-{
-
-}
-
-QgsGridFileWriter::~QgsGridFileWriter()
-{
-
-}
-
-int QgsGridFileWriter::writeFile( bool showProgressDialog )
-{
- QFile outputFile( mOutputFilePath );
-
- if ( !outputFile.open( QFile::WriteOnly ) )
- {
- return 1;
- }
-
- if ( !mInterpolator )
- {
- outputFile.remove();
- return 2;
- }
-
- QTextStream outStream( &outputFile );
- outStream.setRealNumberPrecision( 8 );
- writeHeader( outStream );
-
- double currentYValue = mInterpolationExtent.yMaximum();
- double currentXValue;
- double interpolatedValue;
-
- QProgressDialog* progressDialog = 0;
- if ( showProgressDialog )
- {
- progressDialog = new QProgressDialog( QObject::tr( "Interpolating..." ), QObject::tr( "Abort" ), 0, mNumRows, 0 );
- progressDialog->setWindowModality( Qt::WindowModal );
- }
-
- for ( int i = 0; i < mNumRows; ++i )
- {
- currentXValue = mInterpolationExtent.xMinimum();
- for ( int j = 0; j < mNumColumns; ++j )
- {
- if ( mInterpolator->interpolatePoint( currentXValue, currentYValue, interpolatedValue ) == 0 )
- {
- outStream << interpolatedValue << " ";
- }
- else
- {
- outStream << "-9999 ";
- }
- currentXValue += mCellSizeX;
- }
- outStream << endl;
- currentYValue -= mCellSizeY;
-
- if ( showProgressDialog )
- {
- if ( progressDialog->wasCanceled() )
- {
- outputFile.remove();
- return 3;
- }
- progressDialog->setValue( i );
- }
- }
-
- delete progressDialog;
- return 0;
-}
-
-int QgsGridFileWriter::writeHeader( QTextStream& outStream )
-{
- outStream << "NCOLS " << mNumColumns << endl;
- outStream << "NROWS " << mNumRows << endl;
- outStream << "XLLCORNER " << mInterpolationExtent.xMinimum() << endl;
- outStream << "YLLCORNER " << mInterpolationExtent.yMinimum() << endl;
- if ( mCellSizeX == mCellSizeY ) //standard way
- {
- outStream << "CELLSIZE " << mCellSizeX << endl;
- }
- else //this is supported by GDAL but probably not by other products
- {
- outStream << "DX " << mCellSizeX << endl;
- outStream << "DY " << mCellSizeY << endl;
- }
- outStream << "NODATA_VALUE -9999" << endl;
-
- return 0;
-}
Deleted: branches/analysis_branch/src/plugins/interpolation/qgsgridfilewriter.h
===================================================================
--- branches/analysis_branch/src/plugins/interpolation/qgsgridfilewriter.h 2009-03-19 17:57:05 UTC (rev 10304)
+++ branches/analysis_branch/src/plugins/interpolation/qgsgridfilewriter.h 2009-03-19 18:05:23 UTC (rev 10305)
@@ -1,56 +0,0 @@
-/***************************************************************************
- qgsgridfilewriter.h
- --------------------
- begin : March 10, 2008
- copyright : (C) 2008 by Marco Hugentobler
- email : marco dot hugentobler at karto dot baug dot ethz dot ch
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#ifndef QGSGRIDFILEWRITER_H
-#define QGSGRIDFILEWRITER_H
-
-#include "qgsrectangle.h"
-#include <QString>
-#include <QTextStream>
-
-class QgsInterpolator;
-
-/**A class that does interpolation to a grid and writes the results to an ascii grid*/
-//todo: extend such that writing to other file types is possible
-class QgsGridFileWriter
-{
- public:
- QgsGridFileWriter( QgsInterpolator* i, QString outputPath, QgsRectangle extent, int nCols, int nRows );
- ~QgsGridFileWriter();
-
- /**Writes the grid file.
- @param showProgressDialog shows a dialog with the possibility to cancel
- @return 0 in case of success*/
-
- int writeFile( bool showProgressDialog = false );
-
- private:
-
- QgsGridFileWriter(); //forbidden
- int writeHeader( QTextStream& outStream );
-
- QgsInterpolator* mInterpolator;
- QString mOutputFilePath;
- QgsRectangle mInterpolationExtent;
- int mNumColumns;
- int mNumRows;
-
- double mCellSizeX;
- double mCellSizeY;
-};
-
-#endif
Deleted: branches/analysis_branch/src/plugins/interpolation/qgsidwinterpolator.cpp
===================================================================
--- branches/analysis_branch/src/plugins/interpolation/qgsidwinterpolator.cpp 2009-03-19 17:57:05 UTC (rev 10304)
+++ branches/analysis_branch/src/plugins/interpolation/qgsidwinterpolator.cpp 2009-03-19 18:05:23 UTC (rev 10305)
@@ -1,67 +0,0 @@
-/***************************************************************************
- qgsidwinterpolator.cpp
- ----------------------
- begin : Marco 10, 2008
- copyright : (C) 2008 by Marco Hugentobler
- email : marco dot hugentobler at karto dot baug dot ethz dot ch
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include "qgsidwinterpolator.h"
-#include <cmath>
-#include <limits>
-
-QgsIDWInterpolator::QgsIDWInterpolator( const QList<QgsVectorLayer*>& vlayers ): QgsInterpolator( vlayers ), mDistanceCoefficient( 2.0 )
-{
-
-}
-
-QgsIDWInterpolator::QgsIDWInterpolator(): QgsInterpolator( QList<QgsVectorLayer*>() ), mDistanceCoefficient( 2.0 )
-{
-
-}
-
-QgsIDWInterpolator::~QgsIDWInterpolator()
-{
-
-}
-
-int QgsIDWInterpolator::interpolatePoint( double x, double y, double& result )
-{
- if ( !mDataIsCached )
- {
- cacheBaseData();
- }
-
- double currentWeight;
- double distance;
-
- double sumCounter = 0;
- double sumDenominator = 0;
-
- QVector<vertexData>::iterator vertex_it = mCachedBaseData.begin();
-
- for ( ; vertex_it != mCachedBaseData.end(); ++vertex_it )
- {
- distance = sqrt(( vertex_it->x - x ) * ( vertex_it->x - x ) + ( vertex_it->y - y ) * ( vertex_it->y - y ) );
- if (( distance - 0 ) < std::numeric_limits<double>::min() )
- {
- result = vertex_it->z;
- return 0;
- }
- currentWeight = 1 / ( pow( distance, mDistanceCoefficient ) );
- sumCounter += ( currentWeight * vertex_it->z );
- sumDenominator += currentWeight;
- }
-
- result = sumCounter / sumDenominator;
- return 0;
-}
Deleted: branches/analysis_branch/src/plugins/interpolation/qgsidwinterpolator.h
===================================================================
--- branches/analysis_branch/src/plugins/interpolation/qgsidwinterpolator.h 2009-03-19 17:57:05 UTC (rev 10304)
+++ branches/analysis_branch/src/plugins/interpolation/qgsidwinterpolator.h 2009-03-19 18:05:23 UTC (rev 10305)
@@ -1,48 +0,0 @@
-/***************************************************************************
- qgsidwinterpolator.h
- --------------------
- begin : March 10, 2008
- copyright : (C) 2008 by Marco Hugentobler
- email : marco dot hugentobler at karto dot baug dot ethz dot ch
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#ifndef QGSIDWINTERPOLATOR_H
-#define QGSIDWINTERPOLATOR_H
-
-#include "qgsinterpolator.h"
-
-class QgsIDWInterpolator: public QgsInterpolator
-{
- public:
- QgsIDWInterpolator( const QList<QgsVectorLayer*>& vlayers );
- ~QgsIDWInterpolator();
-
- /**Calculates interpolation value for map coordinates x, y
- @param x x-coordinate (in map units)
- @param y y-coordinate (in map units)
- @param result out: interpolation result
- @return 0 in case of success*/
- int interpolatePoint( double x, double y, double& result );
-
- void setDistanceCoefficient( double p ) {mDistanceCoefficient = p;}
-
- private:
-
- QgsIDWInterpolator(); //forbidden
-
- /**The parameter that sets how the values are weighted with distance.
- Smaller values mean sharper peaks at the data points. The default is a
- value of 2*/
- double mDistanceCoefficient;
-};
-
-#endif
Deleted: branches/analysis_branch/src/plugins/interpolation/qgsinterpolator.cpp
===================================================================
--- branches/analysis_branch/src/plugins/interpolation/qgsinterpolator.cpp 2009-03-19 17:57:05 UTC (rev 10304)
+++ branches/analysis_branch/src/plugins/interpolation/qgsinterpolator.cpp 2009-03-19 18:05:23 UTC (rev 10305)
@@ -1,369 +0,0 @@
-/***************************************************************************
- qgsinterpolator.cpp
- -------------------
- begin : Marco 10, 2008
- copyright : (C) 2008 by Marco Hugentobler
- email : marco dot hugentobler at karto dot baug dot ethz dot ch
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include "qgsinterpolator.h"
-#include "qgsvectordataprovider.h"
-#include "qgsgeometry.h"
-#ifndef Q_OS_MACX
-#include <cmath>
-#else
-#include <math.h>
-#endif
-#ifdef _MSC_VER
-#include <float.h>
-#define isnan(f) _isnan(f)
-#endif
-
-QgsInterpolator::QgsInterpolator( const QList<QgsVectorLayer*>& vlayers ): mDataIsCached( false ), mVectorLayers( vlayers ), zCoordInterpolation( false ), mValueAttribute( -1 )
-{
-
-}
-
-QgsInterpolator::QgsInterpolator()
-{
-
-}
-
-QgsInterpolator::~QgsInterpolator()
-{
-
-}
-
-void QgsInterpolator::enableAttributeValueInterpolation( int attribute )
-{
- mValueAttribute = attribute;
- zCoordInterpolation = false;
-}
-
-int QgsInterpolator::cacheBaseData()
-{
- if ( mVectorLayers.size() < 1 )
- {
- return 0;
- }
-
- //reserve initial memory for 100000 vertices
- mCachedBaseData.clear();
- mCachedBaseData.reserve( 100000 );
-
- QList<QgsVectorLayer*>::iterator v_it = mVectorLayers.begin();
-
- for ( ; v_it != mVectorLayers.end(); ++v_it )
- {
- if (( *v_it ) == 0 )
- {
- continue;
- }
-
- QgsVectorDataProvider* provider = ( *v_it )->dataProvider();
- if ( !provider )
- {
- return 2;
- }
-
- QgsAttributeList attList;
- if ( !zCoordInterpolation )
- {
- attList.push_back( mValueAttribute );
- }
-
- provider->select( attList );
-
- QgsFeature theFeature;
- double attributeValue = 0.0;
- bool attributeConversionOk = false;
-
- while ( provider->nextFeature( theFeature ) )
- {
- if ( !zCoordInterpolation )
- {
- QgsAttributeMap attMap = theFeature.attributeMap();
- QgsAttributeMap::const_iterator att_it = attMap.find( mValueAttribute );
- if ( att_it == attMap.end() ) //attribute not found, something must be wrong
- {
- return 3;
- }
- attributeValue = att_it.value().toDouble(&attributeConversionOk);
- if(!attributeConversionOk || isnan(attributeValue)) //don't consider vertices with attributes like 'nan' for the interpolation
- {
- continue;
- }
- }
-
- if ( addVerticesToCache( theFeature.geometry(), attributeValue ) != 0 )
- {
- return 3;
- }
- }
- }
-
- return 0;
-}
-
-int QgsInterpolator::addVerticesToCache( QgsGeometry* geom, double attributeValue )
-{
- if ( !geom )
- {
- return 1;
- }
-
- bool hasZValue = false;
- unsigned char* currentWkbPtr = geom->asWkb();
- vertexData theVertex; //the current vertex
-
- QGis::WkbType wkbType = geom->wkbType();
- switch ( wkbType )
- {
- case QGis::WKBPoint25D:
- hasZValue = true;
- case QGis::WKBPoint:
- {
- currentWkbPtr += ( 1 + sizeof( int ) );
- theVertex.x = *(( double * )( currentWkbPtr ) );
- currentWkbPtr += sizeof( double );
- theVertex.y = *(( double * )( currentWkbPtr ) );
- if ( zCoordInterpolation && hasZValue )
- {
- currentWkbPtr += sizeof( double );
- theVertex.z = *(( double * )( currentWkbPtr ) );
- }
- else
- {
- theVertex.z = attributeValue;
- }
- mCachedBaseData.push_back( theVertex );
- break;
- }
- case QGis::WKBLineString25D:
- hasZValue = true;
- case QGis::WKBLineString:
- {
- currentWkbPtr += ( 1 + sizeof( int ) );
- int* npoints = ( int* )currentWkbPtr;
- currentWkbPtr += sizeof( int );
- for ( int index = 0;index < *npoints;++index )
- {
- theVertex.x = *(( double * )( currentWkbPtr ) );
- currentWkbPtr += sizeof( double );
- theVertex.y = *(( double * )( currentWkbPtr ) );
- currentWkbPtr += sizeof( double );
- if ( zCoordInterpolation && hasZValue ) //skip z-coordinate for 25D geometries
- {
- theVertex.z = *(( double * )( currentWkbPtr ) );
- currentWkbPtr += sizeof( double );
- }
- else
- {
- theVertex.z = attributeValue;
- }
- mCachedBaseData.push_back( theVertex );
- }
- break;
- }
-#if 0
- case QGis::WKBPolygon25D:
- hasZValue = true;
- case QGis::WKBPolygon:
- {
- int* nrings = ( int* )( mGeometry + 5 );
- int* npoints;
- unsigned char* ptr = mGeometry + 9;
- for ( int index = 0;index < *nrings;++index )
- {
- npoints = ( int* )ptr;
- ptr += sizeof( int );
- for ( int index2 = 0;index2 < *npoints;++index2 )
- {
- tempx = ( double* )ptr;
- ptr += sizeof( double );
- tempy = ( double* )ptr;
- if ( point.sqrDist( *tempx, *tempy ) < actdist )
- {
- x = *tempx;
- y = *tempy;
- actdist = point.sqrDist( *tempx, *tempy );
- vertexnr = vertexcounter;
- //assign the rubber band indices
- if ( index2 == 0 )
- {
- beforeVertex = vertexcounter + ( *npoints - 2 );
- afterVertex = vertexcounter + 1;
- }
- else if ( index2 == ( *npoints - 1 ) )
- {
- beforeVertex = vertexcounter - 1;
- afterVertex = vertexcounter - ( *npoints - 2 );
- }
- else
- {
- beforeVertex = vertexcounter - 1;
- afterVertex = vertexcounter + 1;
- }
- }
- ptr += sizeof( double );
- if ( hasZValue ) //skip z-coordinate for 25D geometries
- {
- ptr += sizeof( double );
- }
- ++vertexcounter;
- }
- }
- break;
- }
- case QGis::WKBMultiPoint25D:
- hasZValue = true;
- case QGis::WKBMultiPoint:
- {
- unsigned char* ptr = mGeometry + 5;
- int* npoints = ( int* )ptr;
- ptr += sizeof( int );
- for ( int index = 0;index < *npoints;++index )
- {
- ptr += ( 1 + sizeof( int ) ); //skip endian and point type
- tempx = ( double* )ptr;
- tempy = ( double* )( ptr + sizeof( double ) );
- if ( point.sqrDist( *tempx, *tempy ) < actdist )
- {
- x = *tempx;
- y = *tempy;
- actdist = point.sqrDist( *tempx, *tempy );
- vertexnr = index;
- }
- ptr += ( 2 * sizeof( double ) );
- if ( hasZValue ) //skip z-coordinate for 25D geometries
- {
- ptr += sizeof( double );
- }
- }
- break;
- }
- case QGis::WKBMultiLineString25D:
- hasZValue = true;
- case QGis::WKBMultiLineString:
- {
- unsigned char* ptr = mGeometry + 5;
- int* nlines = ( int* )ptr;
- int* npoints = 0;
- ptr += sizeof( int );
- for ( int index = 0;index < *nlines;++index )
- {
- ptr += ( sizeof( int ) + 1 );
- npoints = ( int* )ptr;
- ptr += sizeof( int );
- for ( int index2 = 0;index2 < *npoints;++index2 )
- {
- tempx = ( double* )ptr;
- ptr += sizeof( double );
- tempy = ( double* )ptr;
- ptr += sizeof( double );
- if ( point.sqrDist( *tempx, *tempy ) < actdist )
- {
- x = *tempx;
- y = *tempy;
- actdist = point.sqrDist( *tempx, *tempy );
- vertexnr = vertexcounter;
-
- if ( index2 == 0 )//assign the rubber band indices
- {
- beforeVertex = -1;
- }
- else
- {
- beforeVertex = vertexnr - 1;
- }
- if ( index2 == ( *npoints ) - 1 )
- {
- afterVertex = -1;
- }
- else
- {
- afterVertex = vertexnr + 1;
- }
- }
- if ( hasZValue ) //skip z-coordinate for 25D geometries
- {
- ptr += sizeof( double );
- }
- ++vertexcounter;
- }
- }
- break;
- }
- case QGis::WKBMultiPolygon25D:
- hasZValue = true;
- case QGis::WKBMultiPolygon:
- {
- unsigned char* ptr = mGeometry + 5;
- int* npolys = ( int* )ptr;
- int* nrings;
- int* npoints;
- ptr += sizeof( int );
- for ( int index = 0;index < *npolys;++index )
- {
- ptr += ( 1 + sizeof( int ) ); //skip endian and polygon type
- nrings = ( int* )ptr;
- ptr += sizeof( int );
- for ( int index2 = 0;index2 < *nrings;++index2 )
- {
- npoints = ( int* )ptr;
- ptr += sizeof( int );
- for ( int index3 = 0;index3 < *npoints;++index3 )
- {
- tempx = ( double* )ptr;
- ptr += sizeof( double );
- tempy = ( double* )ptr;
- if ( point.sqrDist( *tempx, *tempy ) < actdist )
- {
- x = *tempx;
- y = *tempy;
- actdist = point.sqrDist( *tempx, *tempy );
- vertexnr = vertexcounter;
-
- //assign the rubber band indices
- if ( index3 == 0 )
- {
- beforeVertex = vertexcounter + ( *npoints - 2 );
- afterVertex = vertexcounter + 1;
- }
- else if ( index3 == ( *npoints - 1 ) )
- {
- beforeVertex = vertexcounter - 1;
- afterVertex = vertexcounter - ( *npoints - 2 );
- }
- else
- {
- beforeVertex = vertexcounter - 1;
- afterVertex = vertexcounter + 1;
- }
- }
- ptr += sizeof( double );
- if ( hasZValue ) //skip z-coordinate for 25D geometries
- {
- ptr += sizeof( double );
- }
- ++vertexcounter;
- }
- }
- }
- break;
- }
-#endif //0
- default:
- break;
- }
- return 0;
-}
Deleted: branches/analysis_branch/src/plugins/interpolation/qgsinterpolator.h
===================================================================
--- branches/analysis_branch/src/plugins/interpolation/qgsinterpolator.h 2009-03-19 17:57:05 UTC (rev 10304)
+++ branches/analysis_branch/src/plugins/interpolation/qgsinterpolator.h 2009-03-19 18:05:23 UTC (rev 10305)
@@ -1,94 +0,0 @@
-/***************************************************************************
- qgsinterpolator.h
- ------------------------
- begin : March 10, 2008
- copyright : (C) 2008 by Marco Hugentobler
- email : marco dot hugentobler at karto dot baug dot ethz dot ch
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#ifndef QGSINTERPOLATOR_H
-#define QGSINTERPOLATOR_H
-
-#include <QVector>
-
-class QgsVectorLayer;
-class QgsGeometry;
-
-struct vertexData
-{
- double x;
- double y;
- double z;
-};
-
-/**Interface class for interpolations. Interpolators take
-the vertices of a vector layer as base data. The z-Value
-can be an attribute or the z-coordinates in case of 25D types*/
-class QgsInterpolator
-{
- public:
- /**Describes the type of input data*/
- enum InputType
- {
- POINTS,
- STRUCTURE_LINES,
- BREAK_LINES
- };
-
- QgsInterpolator( const QList<QgsVectorLayer*>& vlayers );
-
- virtual ~QgsInterpolator();
-
- /**Calculates interpolation value for map coordinates x, y
- @param x x-coordinate (in map units)
- @param y y-coordinate (in map units)
- @param result out: interpolation result
- @return 0 in case of success*/
- virtual int interpolatePoint( double x, double y, double& result ) = 0;
-
- /**Use the z-coord of 25D for interpolation*/
- void enableZCoordInterpolation() {zCoordInterpolation = true;}
-
- /**Use a vector attribute as interpolation value*/
- void enableAttributeValueInterpolation( int attribute );
-
- /**Creates a vector layer that can be added to the main map, e.g. TIN edges for triangle interpolation.
- Mouse clicks in the main map can be tracked and used for configuration (e.g. edge swaping). Default implementation does
- nothing.*/
- virtual QgsVectorLayer* createVectorLayer() const {return 0;}
-
- protected:
- /**Caches the vertex and value data from the provider. All the vertex data
- will be held in virtual memory
- @return 0 in case of success*/
- int cacheBaseData();
-
- QVector<vertexData> mCachedBaseData;
-
- /**Flag that tells if the cache already has been filled*/
- bool mDataIsCached;
-
- private:
- QgsInterpolator(); //forbidden
- /**Helper method that adds the vertices of a geometry to the mCachedBaseData
- @param geom the geometry
- @param attributeValue the attribute value for interpolation (if not interpolated from z-coordinate)
- @return 0 in case of success*/
- int addVerticesToCache( QgsGeometry* geom, double attributeValue );
-
- QList<QgsVectorLayer*> mVectorLayers;
-
- bool zCoordInterpolation;
- int mValueAttribute;
-};
-
-#endif
Deleted: branches/analysis_branch/src/plugins/interpolation/qgstininterpolator.cpp
===================================================================
--- branches/analysis_branch/src/plugins/interpolation/qgstininterpolator.cpp 2009-03-19 17:57:05 UTC (rev 10304)
+++ branches/analysis_branch/src/plugins/interpolation/qgstininterpolator.cpp 2009-03-19 18:05:23 UTC (rev 10305)
@@ -1,79 +0,0 @@
-/***************************************************************************
- qgstininterpolator.cpp
- ----------------------
- begin : March 10, 2008
- copyright : (C) 2008 by Marco Hugentobler
- email : marco dot hugentobler at karto dot baug dot ethz dot ch
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include "qgstininterpolator.h"
-#include "DualEdgeTriangulation.h"
-#include "LinTriangleInterpolator.h"
-#include "Point3D.h"
-#include "qgssinglesymbolrenderer.h"
-#include "qgsvectorlayer.h"
-
-QgsTINInterpolator::QgsTINInterpolator( const QList<QgsVectorLayer*>& inputData ): QgsInterpolator( inputData ), mTriangulation( 0 ), mTriangleInterpolator( 0 ), mIsInitialized( false )
-{
-}
-
-QgsTINInterpolator::~QgsTINInterpolator()
-{
- delete mTriangulation;
- delete mTriangleInterpolator;
-}
-
-int QgsTINInterpolator::interpolatePoint( double x, double y, double& result )
-{
- if ( !mIsInitialized )
- {
- initialize();
- }
-
- if ( !mTriangleInterpolator )
- {
- return 1;
- }
-
- Point3D r;
- if ( !mTriangleInterpolator->calcPoint( x, y, &r ) )
- {
- return 2;
- }
- result = r.getZ();
- return 0;
-}
-
-void QgsTINInterpolator::initialize()
-{
- if ( !mDataIsCached )
- {
- cacheBaseData();
- }
-
- //create DualEdgeTriangulation
-
- DualEdgeTriangulation* theDualEdgeTriangulation = new DualEdgeTriangulation( mCachedBaseData.size(), 0 );
- mTriangulation = theDualEdgeTriangulation;
-
- //add all the vertices to the triangulation
- QVector<vertexData>::const_iterator vertex_it = mCachedBaseData.constBegin();
- for ( ; vertex_it != mCachedBaseData.constEnd(); ++vertex_it )
- {
- Point3D* thePoint = new Point3D( vertex_it->x, vertex_it->y, vertex_it->z );
- mTriangulation->addPoint( thePoint );
- }
-
- mTriangleInterpolator = new LinTriangleInterpolator( theDualEdgeTriangulation );
-
- mIsInitialized = true;
-}
Deleted: branches/analysis_branch/src/plugins/interpolation/qgstininterpolator.h
===================================================================
--- branches/analysis_branch/src/plugins/interpolation/qgstininterpolator.h 2009-03-19 17:57:05 UTC (rev 10304)
+++ branches/analysis_branch/src/plugins/interpolation/qgstininterpolator.h 2009-03-19 18:05:23 UTC (rev 10305)
@@ -1,48 +0,0 @@
-/***************************************************************************
- qgstininterpolator.h
- --------------------
- begin : March 10, 2008
- copyright : (C) 2008 by Marco Hugentobler
- email : marco dot hugentobler at karto dot baug dot ethz dot ch
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#ifndef QGSTININTERPOLATOR_H
-#define QGSTININTERPOLATOR_H
-
-#include "qgsinterpolator.h"
-
-class Triangulation;
-class TriangleInterpolator;
-
-/**Interpolation in a triangular irregular network*/
-class QgsTINInterpolator: public QgsInterpolator
-{
- public:
- QgsTINInterpolator( const QList<QgsVectorLayer*>& inputData );
- ~QgsTINInterpolator();
-
- /**Calculates interpolation value for map coordinates x, y
- @param x x-coordinate (in map units)
- @param y y-coordinate (in map units)
- @param result out: interpolation result
- @return 0 in case of success*/
- int interpolatePoint( double x, double y, double& result );
-
- private:
- Triangulation* mTriangulation;
- TriangleInterpolator* mTriangleInterpolator;
- bool mIsInitialized;
-
- void initialize();
-};
-
-#endif
More information about the QGIS-commit
mailing list