Skip to content

Commit

Permalink
work in progress, loosely related to #3.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrasca committed Jan 5, 2017
1 parent 1d146e1 commit 0519b1d
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 158 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
*/*/*~
help/build
.noseids

resources.py
Binary file added ghini-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ghini-22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ghini-24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ghini-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ghini-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ghini-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 16 additions & 13 deletions ghini_tree_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,16 @@ def run(self):
result = self.dlg.exec_()
# See if OK was pressed
if result:
## these values should come from the layer
points = {
'13': {'id': '13', 'type': 'Point', 'coordinates': [690514,720254]},
'14': {'id': '14', 'type': 'Point', 'coordinates': [690514,720408]},
'15': {'id': '15', 'type': 'Point', 'coordinates': [690514,720562]},
'22': {'id': '22', 'type': 'Point', 'coordinates': [690360,720100]},
'32': {'id': '32', 'type': 'Point', 'coordinates': [690206,720100]},
'42': {'id': '42', 'type': 'Point', 'coordinates': [690052,720100]},
'51': {'id': '51', 'type': 'Point', 'coordinates': [689898,719946]},
'55': {'id': '55', 'type': 'Point', 'coordinates': [689898,720562]},
}
## we should check there is an active layer
layer = self.iface.activeLayer()
## get reference points from the layer
points = {}
for feature in layer.getFeatures():
# target coordinates system should come from layer
transf = QgsCoordinateTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3117))
easting_northing = transf.transform(feature.geometry().asPoint())
point_id = feature['id']
points[point_id] = {'id': point_id, 'coordinates': easting_northing}

## these values should come from the input files
distances = {
Expand Down Expand Up @@ -262,18 +261,22 @@ def run(self):
heap.reprioritize(neighbour)

## layer name should be from active layer
layer = QgsMapLayerRegistry.instance().mapLayers()['beacons20170101115312666']
layer.startEditing()

## source coordinate reference system should be from active layer
transf = QgsCoordinateTransform(QgsCoordinateReferenceSystem(3117), QgsCoordinateReferenceSystem(4326))

featureList = []
## now add the computed points to the layer
for (x, y) in [p['coordinates'] for p in points.values() if p['computed']]:
for p in [p for p in points.values() if p['computed']]:
x, y = p['coordinates']
feature = QgsFeature()
layerPoint = transf.transform(QgsPoint(x, y))
feature.setGeometry(QgsGeometry.fromPoint(layerPoint))
try:
feature['id'] = p['id']
except Exception, e:
print type(e), e
featureList.append(feature)

layer.dataProvider().addFeatures(featureList)
Expand Down
114 changes: 80 additions & 34 deletions ghini_tree_position_dialog_base.ui
Original file line number Diff line number Diff line change
@@ -1,33 +1,79 @@
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DistanceMatrixToCoordsDialogBase</class>
<widget class="QDialog" name="DistanceMatrixToCoordsDialogBase" >
<property name="geometry" >
<widget class="QDialog" name="DistanceMatrixToCoordsDialogBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>249</width>
<height>115</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>GhiniTreePositioner</string>
</property>
<widget class="QDialogButtonBox" name="button_box" >
<property name="geometry" >
<rect>
<x>30</x>
<y>240</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QSplitter" name="splitter_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QLabel" name="label">
<property name="text">
<string>select the mutual distances file</string>
</property>
</widget>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QLineEdit" name="lineEdit">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>9999</width>
<height>9999</height>
</size>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>browse</string>
</property>
</widget>
</widget>
<widget class="QDialogButtonBox" name="button_box">
<property name="maximumSize">
<size>
<width>5000</width>
<height>32</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
Expand All @@ -37,13 +83,13 @@
<receiver>DistanceMatrixToCoordsDialogBase</receiver>
<slot>accept()</slot>
<hints>
<hint type="source_label" >
<x>248</x>
<y>254</y>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destination_label" >
<x>157</x>
<y>274</y>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
Expand All @@ -53,13 +99,13 @@
<receiver>DistanceMatrixToCoordsDialogBase</receiver>
<slot>reject()</slot>
<hints>
<hint type="source_label" >
<x>316</x>
<y>260</y>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destination_label" >
<x>286</x>
<y>274</y>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
Expand Down
111 changes: 0 additions & 111 deletions resources.py

This file was deleted.

0 comments on commit 0519b1d

Please sign in to comment.