olivierdalang / VectorBender

VectorBender is a QGis plugin
GNU General Public License v3.0
37 stars 15 forks source link

Why the dependencies on matplotlib and scipy? #1

Closed giohappy closed 5 years ago

giohappy commented 10 years ago

Hi Olivier, thanks for your plugin. Giving a look to the code I wonder if we could avoid those dependencies, given that convex hull and delaunay are already available from other parts of QGIS. Did you use them for future developments?

olivierdalang commented 10 years ago

Hi ! Yes avoiding those would be really nice... Do you know how it's possible to access the already available algorithms from python ? At worst it's still possible to include the algorithms with the plugin...

giohappy commented 10 years ago

convexHull can be built from a QgsGeometry [1]. For Delaunay maybe the voronoy python implementation [2] in ftools could be ok (it's the porting of the Fortune's sweepline algorithm). Given that ftools is bundled (core plugin) it will always be there. The problem is that the tools/ folder inside fTools is not a module, so to obtain voronoy.py you should have to do something like:

import os,sys
import fTools
sys.path.append(os.path.abspath(os.path.dirname(fTools.__file__)+'/tools'))
import voronoy

[1] http://qgis.org/api/classQgsGeometry.html#a0cf0d95366ae2a1fb305a59742c35e12 [2] https://github.com/qgis/QGIS/blob/master/python/plugins/fTools/tools/voronoi.py

giohappy commented 10 years ago

PS: voronoy.py implements both the duals [1]

[1] https://github.com/qgis/QGIS/blob/master/python/plugins/fTools/tools/voronoi.py#L759

olivierdalang commented 10 years ago

Great thanks a lot ! I'll do this ASAP

olivierdalang commented 10 years ago

Ok scipy was easy to replace with QgsGeometry.convexHull(), but matplotlib's tri_api -(http://matplotlib.org/1.3.1/api/tri_api.html) has those nice "trifinders" which do all the job of finding in which triangle the points lies...

I'm no expert at python modules/dependencies etc, isn't there a way to ship only the needed .py files with the plugin ?