Skip to content
Permalink
Browse files

Also store x/y coordinates of nearest points on features when calcula…

…ting

nearest features

This can be useful, and is difficult to calculate later!
  • Loading branch information
nyalldawson committed Apr 2, 2019
1 parent 95af4d4 commit 59ed07891a6c7f87631a2d39f8291a365afcc38e
Showing with 624 additions and 137 deletions.
  1. +26 −2 python/plugins/processing/tests/testdata/expected/join_points_to_layers_discard.gml
  2. +24 −0 python/plugins/processing/tests/testdata/expected/join_points_to_layers_discard.xsd
  3. +36 −0 python/plugins/processing/tests/testdata/expected/join_to_nearest_self.gml
  4. +24 −0 python/plugins/processing/tests/testdata/expected/join_to_nearest_self.xsd
  5. +72 −0 python/plugins/processing/tests/testdata/expected/join_to_nearest_self_2.gml
  6. +24 −0 python/plugins/processing/tests/testdata/expected/join_to_nearest_self_2.xsd
  7. +36 −0 python/plugins/processing/tests/testdata/expected/nearest_lines_to_points_reprojected.gml
  8. +24 −0 python/plugins/processing/tests/testdata/expected/nearest_lines_to_points_reprojected.xsd
  9. +23 −53 python/plugins/processing/tests/testdata/expected/nearest_lines_to_polys.gml
  10. +24 −0 python/plugins/processing/tests/testdata/expected/nearest_lines_to_polys.xsd
  11. +49 −12 python/plugins/processing/tests/testdata/expected/nearest_points_to_lines.gml
  12. +24 −0 python/plugins/processing/tests/testdata/expected/nearest_points_to_lines.xsd
  13. +32 −60 python/plugins/processing/tests/testdata/expected/nearest_points_to_reproj_lines.gml
  14. +24 −0 python/plugins/processing/tests/testdata/expected/nearest_points_to_reproj_lines.xsd
  15. +38 −2 python/plugins/processing/tests/testdata/expected/nearest_polys_to_points.gml
  16. +24 −0 python/plugins/processing/tests/testdata/expected/nearest_polys_to_points.xsd
  17. +63 −3 python/plugins/processing/tests/testdata/expected/nearest_polys_to_points_options.gml
  18. +24 −0 python/plugins/processing/tests/testdata/expected/nearest_polys_to_points_options.xsd
  19. +33 −5 src/analysis/processing/qgsalgorithmjoinbynearest.cpp
@@ -16,15 +16,23 @@
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:fid_2>lines.2</ogr:fid_2>
<ogr:n>1</ogr:n>
<ogr:distance>0.915920625957996</ogr:distance>
<ogr:distance>0.915920625957997</ogr:distance>
<ogr:feature_x>1</ogr:feature_x>
<ogr:feature_y>1</ogr:feature_y>
<ogr:nearest_x>1.91292520517715</ogr:nearest_x>
<ogr:nearest_y>1.07401461212186</ogr:nearest_y>
</ogr:join_points_to_layers_discard>
</gml:featureMember>
<gml:featureMember>
<ogr:join_points_to_layers_discard fid="points.1">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3.13409350057012,2.74139110604333</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:fid_2>lines.2</ogr:fid_2>
<ogr:n>1</ogr:n>
<ogr:distance>0.860133820101952</ogr:distance>
<ogr:distance>0.860133820101953</ogr:distance>
<ogr:feature_x>3.13409350057012</ogr:feature_x>
<ogr:feature_y>2.74139110604333</ogr:feature_y>
<ogr:nearest_x>2.91690483120036</ogr:nearest_x>
<ogr:nearest_y>1.90912956639334</ogr:nearest_y>
</ogr:join_points_to_layers_discard>
</gml:featureMember>
<gml:featureMember>
@@ -33,6 +41,10 @@
<ogr:fid_2>lines.2</ogr:fid_2>
<ogr:n>1</ogr:n>
<ogr:distance>0.117399851996412</ogr:distance>
<ogr:feature_x>2</ogr:feature_x>
<ogr:feature_y>2</ogr:feature_y>
<ogr:nearest_x>2.01378272524878</ogr:nearest_x>
<ogr:nearest_y>2.11658799995495</ogr:nearest_y>
</ogr:join_points_to_layers_discard>
</gml:featureMember>
<gml:featureMember>
@@ -41,6 +53,10 @@
<ogr:fid_2>lines.2</ogr:fid_2>
<ogr:n>1</ogr:n>
<ogr:distance>0.945227772283215</ogr:distance>
<ogr:feature_x>3.68392246294185</ogr:feature_x>
<ogr:feature_y>0.961687571265678</ogr:feature_y>
<ogr:nearest_x>3.27743119266055</ogr:nearest_x>
<ogr:nearest_y>1.81504587155963</ogr:nearest_y>
</ogr:join_points_to_layers_discard>
</gml:featureMember>
<gml:featureMember>
@@ -49,6 +65,10 @@
<ogr:fid_2>lines.5</ogr:fid_2>
<ogr:n>1</ogr:n>
<ogr:distance>0.620215569426356</ogr:distance>
<ogr:feature_x>7.18198403648803</ogr:feature_x>
<ogr:feature_y>-1.26818700114025</ogr:feature_y>
<ogr:nearest_x>7.51395373866132</ogr:nearest_x>
<ogr:nearest_y>-1.79207961360757</ogr:nearest_y>
</ogr:join_points_to_layers_discard>
</gml:featureMember>
<gml:featureMember>
@@ -57,6 +77,10 @@
<ogr:fid_2>lines.1</ogr:fid_2>
<ogr:n>1</ogr:n>
<ogr:distance>0.210718358038768</ogr:distance>
<ogr:feature_x>0.220296465222349</ogr:feature_x>
<ogr:feature_y>-1.21071835803877</ogr:feature_y>
<ogr:nearest_x>0.220296465222349</ogr:nearest_x>
<ogr:nearest_y>-1</ogr:nearest_y>
</ogr:join_points_to_layers_discard>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -36,6 +36,30 @@
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="feature_x" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="feature_y" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="nearest_x" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="nearest_y" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
@@ -17,6 +17,10 @@
<ogr:fid_2>points.2</ogr:fid_2>
<ogr:n>1</ogr:n>
<ogr:distance>1.4142135623731</ogr:distance>
<ogr:feature_x>1</ogr:feature_x>
<ogr:feature_y>1</ogr:feature_y>
<ogr:nearest_x>2</ogr:nearest_x>
<ogr:nearest_y>2</ogr:nearest_y>
</ogr:join_to_nearest_self>
</gml:featureMember>
<gml:featureMember>
@@ -25,6 +29,10 @@
<ogr:fid_2>points.2</ogr:fid_2>
<ogr:n>1</ogr:n>
<ogr:distance>1.3549276143601</ogr:distance>
<ogr:feature_x>3.13409350057012</ogr:feature_x>
<ogr:feature_y>2.74139110604333</ogr:feature_y>
<ogr:nearest_x>2</ogr:nearest_x>
<ogr:nearest_y>2</ogr:nearest_y>
</ogr:join_to_nearest_self>
</gml:featureMember>
<gml:featureMember>
@@ -33,6 +41,10 @@
<ogr:fid_2>points.1</ogr:fid_2>
<ogr:n>1</ogr:n>
<ogr:distance>1.3549276143601</ogr:distance>
<ogr:feature_x>2</ogr:feature_x>
<ogr:feature_y>2</ogr:feature_y>
<ogr:nearest_x>3.13409350057012</ogr:nearest_x>
<ogr:nearest_y>2.74139110604333</ogr:nearest_y>
</ogr:join_to_nearest_self>
</gml:featureMember>
<gml:featureMember>
@@ -41,6 +53,10 @@
<ogr:fid_2>points.4</ogr:fid_2>
<ogr:n>1</ogr:n>
<ogr:distance>1.69120460054011</ogr:distance>
<ogr:feature_x>5.25860889395667</ogr:feature_x>
<ogr:feature_y>1.57856328392246</ogr:feature_y>
<ogr:nearest_x>3.68392246294185</ogr:nearest_x>
<ogr:nearest_y>0.961687571265678</ogr:nearest_y>
</ogr:join_to_nearest_self>
</gml:featureMember>
<gml:featureMember>
@@ -49,6 +65,10 @@
<ogr:fid_2>points.3</ogr:fid_2>
<ogr:n>1</ogr:n>
<ogr:distance>1.69120460054011</ogr:distance>
<ogr:feature_x>3.68392246294185</ogr:feature_x>
<ogr:feature_y>0.961687571265678</ogr:feature_y>
<ogr:nearest_x>5.25860889395667</ogr:nearest_x>
<ogr:nearest_y>1.57856328392246</ogr:nearest_y>
</ogr:join_to_nearest_self>
</gml:featureMember>
<gml:featureMember>
@@ -57,6 +77,10 @@
<ogr:fid_2>points.8</ogr:fid_2>
<ogr:n>1</ogr:n>
<ogr:distance>3.61692644124198</ogr:distance>
<ogr:feature_x>0.201140250855188</ogr:feature_x>
<ogr:feature_y>-4.82759407069555</ogr:feature_y>
<ogr:nearest_x>0.220296465222349</ogr:nearest_x>
<ogr:nearest_y>-1.21071835803877</ogr:nearest_y>
</ogr:join_to_nearest_self>
</gml:featureMember>
<gml:featureMember>
@@ -65,6 +89,10 @@
<ogr:fid_2>points.7</ogr:fid_2>
<ogr:n>1</ogr:n>
<ogr:distance>2.03648094068824</ogr:distance>
<ogr:feature_x>7.97126567844926</ogr:feature_x>
<ogr:feature_y>0.609122006841505</ogr:feature_y>
<ogr:nearest_x>7.18198403648803</ogr:nearest_x>
<ogr:nearest_y>-1.26818700114025</ogr:nearest_y>
</ogr:join_to_nearest_self>
</gml:featureMember>
<gml:featureMember>
@@ -73,6 +101,10 @@
<ogr:fid_2>points.6</ogr:fid_2>
<ogr:n>1</ogr:n>
<ogr:distance>2.03648094068824</ogr:distance>
<ogr:feature_x>7.18198403648803</ogr:feature_x>
<ogr:feature_y>-1.26818700114025</ogr:feature_y>
<ogr:nearest_x>7.97126567844926</ogr:nearest_x>
<ogr:nearest_y>0.609122006841505</ogr:nearest_y>
</ogr:join_to_nearest_self>
</gml:featureMember>
<gml:featureMember>
@@ -81,6 +113,10 @@
<ogr:fid_2>points.0</ogr:fid_2>
<ogr:n>1</ogr:n>
<ogr:distance>2.34418712152302</ogr:distance>
<ogr:feature_x>0.220296465222349</ogr:feature_x>
<ogr:feature_y>-1.21071835803877</ogr:feature_y>
<ogr:nearest_x>1</ogr:nearest_x>
<ogr:nearest_y>1</ogr:nearest_y>
</ogr:join_to_nearest_self>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -36,6 +36,30 @@
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="feature_x" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="feature_y" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="nearest_x" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="nearest_y" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>

0 comments on commit 59ed078

Please sign in to comment.
You can’t perform that action at this time.