[FEATURE] Split minimum enclosing geometry algs into separate

feature based algorithms

Instead of algorithms which handle both whole layers/groups
of features/individual features, we leave the whole layer
and group of features handling to the "Minimum bounding
geometry" algorithm.

The feature-by-feature algorithms are now native c++
algorithms.

This affects:
- bounding boxes
- convex hulls
- minimum enclosing circle
- minimum oriented rectangles
This commit is contained in:
Nyall Dawson 2017-09-03 19:26:04 +10:00
parent b6e35428e2
commit 85cd1c1673
9 changed files with 479 additions and 91 deletions

View File

@ -0,0 +1,42 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>convex_hull_by_feature</Name>
<ElementPath>convex_hull_by_feature</ElementPath>
<!--POLYGON-->
<GeometryType>3</GeometryType>
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>6</FeatureCount>
<ExtentXMin>-1.00000</ExtentXMin>
<ExtentXMax>10.00000</ExtentXMax>
<ExtentYMin>-3.00000</ExtentYMin>
<ExtentYMax>6.00000</ExtentYMax>
</DatasetSpecificInfo>
<PropertyDefn>
<Name>intval</Name>
<ElementPath>intval</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
<PropertyDefn>
<Name>floatval</Name>
<ElementPath>floatval</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>area</Name>
<ElementPath>area</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>perimeter</Name>
<ElementPath>perimeter</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>name</Name>
<ElementPath>name</ElementPath>
<Type>String</Type>
<Width>5</Width>
</PropertyDefn>
</GMLFeatureClass>
</GMLFeatureClassList>

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=""
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>-1</gml:X><gml:Y>-3</gml:Y></gml:coord>
<gml:coord><gml:X>10</gml:X><gml:Y>6</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ogr:convex_hull_by_feature fid="polys.4">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>6,-3 2.4,-1.0 3.8,2.2 6,1 6,-3</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:intval>120</ogr:intval>
<ogr:floatval>-100291.43213</ogr:floatval>
<ogr:area>11.560000</ogr:area>
<ogr:perimeter>14.117095</ogr:perimeter>
</ogr:convex_hull_by_feature>
</gml:featureMember>
<gml:featureMember>
<ogr:convex_hull_by_feature fid="polys.1">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5.2,3.8 4,4 5.4,5.0 6,4 5.2,3.8</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:intval>-33</ogr:intval>
<ogr:floatval>0</ogr:floatval>
<ogr:name>Aaaaa</ogr:name>
<ogr:area>1.200000</ogr:area>
<ogr:perimeter>4.927829</ogr:perimeter>
</ogr:convex_hull_by_feature>
</gml:featureMember>
<gml:featureMember>
<ogr:convex_hull_by_feature fid="polys.0">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-1,-1 -1,3 3,3 3,2 2,-1 -1,-1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:intval>33</ogr:intval>
<ogr:floatval>44.12346</ogr:floatval>
<ogr:name>aaaaa</ogr:name>
<ogr:area>14.500000</ogr:area>
<ogr:perimeter>15.162278</ogr:perimeter>
</ogr:convex_hull_by_feature>
</gml:featureMember>
<gml:featureMember>
<ogr:convex_hull_by_feature fid="polys.3">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>6.4,-3.0 6.8,1.8 10,1 9.6,-2.2 6.4,-3.0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:intval>0</ogr:intval>
<ogr:name>ASDF</ogr:name>
<ogr:area>12.800000</ogr:area>
<ogr:perimeter>14.638510</ogr:perimeter>
</ogr:convex_hull_by_feature>
</gml:featureMember>
<gml:featureMember>
<ogr:convex_hull_by_feature fid="polys.2">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1.6,4.8 2,6 3,6 1.6,4.8</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:floatval>0.123</ogr:floatval>
<ogr:name>bbaaa</ogr:name>
<ogr:area>0.600000</ogr:area>
<ogr:perimeter>4.108820</ogr:perimeter>
</ogr:convex_hull_by_feature>
</gml:featureMember>
<gml:featureMember>
<ogr:convex_hull_by_feature fid="polys.5">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>6,-3 2.4,-1.0 3.8,2.2 6,1 6,-3</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:intval>2</ogr:intval>
<ogr:floatval>3.33</ogr:floatval>
<ogr:name>elim</ogr:name>
<ogr:area>11.560000</ogr:area>
<ogr:perimeter>14.117095</ogr:perimeter>
</ogr:convex_hull_by_feature>
</gml:featureMember>
</ogr:FeatureCollection>

View File

@ -7,7 +7,7 @@
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>6</FeatureCount>
<ExtentXMin>-1.81766</ExtentXMin>
<ExtentXMin>-1.82843</ExtentXMin>
<ExtentXMax>10.59982</ExtentXMax>
<ExtentYMin>-3.43247</ExtentYMin>
<ExtentYMax>6.32190</ExtentYMax>
@ -22,21 +22,16 @@
<ElementPath>floatval</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>center_x</Name>
<ElementPath>center_x</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>center_y</Name>
<ElementPath>center_y</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>radius</Name>
<ElementPath>radius</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>area</Name>
<ElementPath>area</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>name</Name>
<ElementPath>name</ElementPath>

View File

@ -6,72 +6,66 @@
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>-1.817664105611035</gml:X><gml:Y>-3.43247280352443</gml:Y></gml:coord>
<gml:coord><gml:X>-1.82842712474619</gml:X><gml:Y>-3.43247280352443</gml:Y></gml:coord>
<gml:coord><gml:X>10.59981974229994</gml:X><gml:Y>6.321903675995209</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ogr:enclosing_circles_each fid="polys.4">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3.8,2.2 4.26819673362059,2.35151315326536 4.75559048978224,2.4194229717016 5.24737205583712,2.40166604983954 5.72859889775413,2.29878192276454 6.18464918145415,2.11389667261588 6.60166604983954,1.85262794416288 6.96697865638513,1.52291425551124 7.26948716239812,1.13477379024745 7.5,0.7 7.65151315326536,0.23180326637941 7.7194229717016,-0.255590489782239 7.70166604983954,-0.747372055837116 7.59878192276454,-1.22859889775413 7.41389667261588,-1.68464918145415 7.15262794416288,-2.10166604983954 6.82291425551124,-2.46697865638513 6.43477379024745,-2.76948716239812 6.0,-3.0 5.53180326637941,-3.15151315326536 5.04440951021776,-3.2194229717016 4.55262794416288,-3.20166604983954 4.07140110224587,-3.09878192276454 3.61535081854585,-2.91389667261588 3.19833395016046,-2.65262794416288 2.83302134361487,-2.32291425551124 2.53051283760188,-1.93477379024745 2.3,-1.5 2.14848684673464,-1.03180326637941 2.0805770282984,-0.544409510217762 2.09833395016046,-0.052627944162882 2.20121807723546,0.428598897754127 2.38610332738412,0.884649181454149 2.64737205583712,1.30166604983954 2.97708574448876,1.66697865638513 3.36522620975255,1.96948716239812 3.8,2.2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3.8,2.2 4.03079076324299,2.28597753206096 4.26819673362059,2.35151315326536 4.51041110834858,2.39610809796435 4.75559048978224,2.4194229717016 5.00186891478551,2.42128033421006 5.24737205583712,2.40166604983954 5.49023148579483,2.36072939513753 5.72859889775413,2.29878192276454 5.96066017177982,2.21629509039023 6.18464918145415,2.11389667261588 6.39886123516523,1.99236598323061 6.60166604983954,1.85262794416288 6.79152015838052,1.69574604626613 6.96697865638513,1.52291425551124 7.12670619873881,1.33544792618453 7.26948716239812,1.13477379024745 7.39423489801611,0.922419099044831 7.5,0.7 7.58597753206096,0.469209236757009 7.65151315326536,0.23180326637941 7.69610809796435,-0.010411108348578 7.7194229717016,-0.255590489782239 7.72128033421006,-0.501868914785503 7.70166604983954,-0.747372055837116 7.66072939513753,-0.990231485794827 7.59878192276454,-1.22859889775413 7.51629509039023,-1.46066017177982 7.41389667261588,-1.68464918145415 7.29236598323061,-1.89886123516523 7.15262794416288,-2.10166604983954 6.99574604626613,-2.29152015838052 6.82291425551124,-2.46697865638513 6.63544792618453,-2.6267061987388 6.43477379024745,-2.76948716239812 6.22241909904483,-2.89423489801611 6.0,-3.0 5.76920923675701,-3.08597753206096 5.53180326637941,-3.15151315326536 5.28958889165142,-3.19610809796435 5.04440951021776,-3.2194229717016 4.7981310852145,-3.22128033421006 4.55262794416288,-3.20166604983954 4.30976851420517,-3.16072939513753 4.07140110224587,-3.09878192276454 3.83933982822018,-3.01629509039023 3.61535081854585,-2.91389667261588 3.40113876483477,-2.79236598323061 3.19833395016046,-2.65262794416288 3.00847984161948,-2.49574604626613 2.83302134361487,-2.32291425551124 2.67329380126119,-2.13544792618453 2.53051283760188,-1.93477379024745 2.40576510198389,-1.72241909904483 2.3,-1.5 2.21402246793904,-1.26920923675701 2.14848684673464,-1.03180326637941 2.10389190203565,-0.789588891651422 2.0805770282984,-0.544409510217762 2.07871966578994,-0.298131085214498 2.09833395016046,-0.052627944162882 2.13927060486247,0.190231485794829 2.20121807723546,0.428598897754127 2.28370490960977,0.660660171779822 2.38610332738412,0.884649181454149 2.50763401676939,1.09886123516523 2.64737205583712,1.30166604983954 2.80425395373387,1.49152015838052 2.97708574448876,1.66697865638513 3.16455207381547,1.82670619873881 3.36522620975255,1.96948716239812 3.57758090095517,2.09423489801611 3.8,2.2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:intval>120</ogr:intval>
<ogr:floatval>-100291.43213</ogr:floatval>
<ogr:center_x>4.9</ogr:center_x>
<ogr:center_y>-0.4</ogr:center_y>
<ogr:radius>2.82311884269862</ogr:radius>
<ogr:radius>2.823119</ogr:radius>
<ogr:area>25.038493</ogr:area>
</ogr:enclosing_circles_each>
</gml:featureMember>
<gml:featureMember>
<ogr:enclosing_circles_each fid="polys.1">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5.0,5.08319489631876 5.17420296559052,5.06795411167699 5.34311286222252,5.02269484128082 5.50159744815938,4.94879226515894 5.64484124945447,4.8484918756903 5.7684918756903,4.72484124945447 5.86879226515894,4.58159744815938 5.94269484128082,4.42311286222252 5.98795411167699,4.25420296559052 6.00319489631876,4.08 5.98795411167699,3.90579703440948 5.94269484128082,3.73688713777748 5.86879226515894,3.57840255184062 5.7684918756903,3.43515875054553 5.64484124945447,3.3115081243097 5.50159744815938,3.21120773484106 5.34311286222252,3.13730515871918 5.17420296559052,3.09204588832301 5.0,3.07680510368124 4.82579703440948,3.09204588832301 4.65688713777748,3.13730515871918 4.49840255184062,3.21120773484106 4.35515875054553,3.3115081243097 4.2315081243097,3.43515875054553 4.13120773484106,3.57840255184062 4.05730515871918,3.73688713777748 4.01204588832301,3.90579703440948 3.99680510368124,4.08 4.01204588832301,4.25420296559052 4.05730515871918,4.42311286222252 4.13120773484106,4.58159744815938 4.2315081243097,4.72484124945447 4.35515875054553,4.8484918756903 4.49840255184062,4.94879226515894 4.65688713777748,5.02269484128082 4.82579703440948,5.06795411167699 5.0,5.08319489631876</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5.0,5.08319489631876 5.08743419630932,5.07937743686544 5.17420296559052,5.06795411167699 5.25964594511694,5.04901185915567 5.34311286222252,5.02269484128082 5.42396848326937,4.98920334644911 5.50159744815938,4.94879226515894 5.57540895359607,4.90176915013979 5.64484124945447,4.8484918756903 5.70936591403873,4.78936591403873 5.7684918756903,4.72484124945447 5.82176915013979,4.65540895359607 5.86879226515894,4.58159744815938 5.90920334644911,4.50396848326937 5.94269484128082,4.42311286222252 5.96901185915567,4.33964594511694 5.98795411167699,4.25420296559052 5.99937743686544,4.16743419630932 6.00319489631876,4.08 5.99937743686544,3.99256580369068 5.98795411167699,3.90579703440948 5.96901185915567,3.82035405488306 5.94269484128082,3.73688713777748 5.90920334644911,3.65603151673063 5.86879226515894,3.57840255184062 5.82176915013979,3.50459104640393 5.7684918756903,3.43515875054553 5.70936591403873,3.37063408596127 5.64484124945447,3.3115081243097 5.57540895359607,3.25823084986021 5.50159744815938,3.21120773484106 5.42396848326937,3.17079665355089 5.34311286222252,3.13730515871918 5.25964594511694,3.11098814084433 5.17420296559052,3.09204588832301 5.08743419630932,3.08062256313456 5.0,3.07680510368124 4.91256580369068,3.08062256313456 4.82579703440948,3.09204588832301 4.74035405488306,3.11098814084433 4.65688713777748,3.13730515871918 4.57603151673063,3.17079665355089 4.49840255184062,3.21120773484106 4.42459104640393,3.25823084986021 4.35515875054553,3.3115081243097 4.29063408596127,3.37063408596127 4.2315081243097,3.43515875054553 4.17823084986021,3.50459104640393 4.13120773484106,3.57840255184062 4.09079665355089,3.65603151673063 4.05730515871918,3.73688713777748 4.03098814084433,3.82035405488306 4.01204588832301,3.90579703440948 4.00062256313456,3.99256580369068 3.99680510368124,4.08 4.00062256313456,4.16743419630932 4.01204588832301,4.25420296559052 4.03098814084433,4.33964594511694 4.05730515871918,4.42311286222252 4.09079665355089,4.50396848326937 4.13120773484106,4.58159744815938 4.17823084986021,4.65540895359607 4.2315081243097,4.72484124945447 4.29063408596127,4.78936591403873 4.35515875054553,4.8484918756903 4.42459104640393,4.90176915013979 4.49840255184062,4.94879226515894 4.57603151673063,4.98920334644911 4.65688713777748,5.02269484128082 4.74035405488306,5.04901185915567 4.82579703440948,5.06795411167699 4.91256580369068,5.07937743686544 5.0,5.08319489631876</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:intval>-33</ogr:intval>
<ogr:floatval>0</ogr:floatval>
<ogr:name>Aaaaa</ogr:name>
<ogr:center_x>5</ogr:center_x>
<ogr:center_y>4.08</ogr:center_y>
<ogr:radius>1.00319489631876</ogr:radius>
<ogr:radius>1.003195</ogr:radius>
<ogr:area>3.161699</ogr:area>
</ogr:enclosing_circles_each>
</gml:featureMember>
<gml:featureMember>
<ogr:enclosing_circles_each fid="polys.0">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3.0,3.0 3.31691186135828,2.62231915069056 3.56342552822315,2.19534495492048 3.73205080756888,1.73205080756888 3.81766410561104,1.24651366686488 3.81766410561104,0.753486333135122 3.73205080756888,0.267949192431123 3.56342552822315,-0.195344954920481 3.31691186135828,-0.622319150690556 3.0,-1.0 2.62231915069056,-1.31691186135828 2.19534495492048,-1.56342552822315 1.73205080756888,-1.73205080756888 1.24651366686488,-1.81766410561103 0.753486333135123,-1.81766410561103 0.267949192431122,-1.73205080756888 -0.195344954920479,-1.56342552822315 -0.622319150690555,-1.31691186135828 -1.0,-1.0 -1.31691186135828,-0.622319150690556 -1.56342552822315,-0.195344954920479 -1.73205080756888,0.267949192431122 -1.81766410561103,0.753486333135123 -1.81766410561103,1.24651366686488 -1.73205080756888,1.73205080756888 -1.56342552822316,2.19534495492048 -1.31691186135828,2.62231915069056 -1.0,3.0 -0.622319150690556,3.31691186135828 -0.195344954920481,3.56342552822315 0.267949192431124,3.73205080756888 0.753486333135123,3.81766410561104 1.24651366686488,3.81766410561104 1.73205080756888,3.73205080756888 2.19534495492048,3.56342552822316 2.62231915069056,3.31691186135828 3.0,3.0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3.0,3.0 3.16670088167881,2.81807791068817 3.31691186135828,2.62231915069056 3.44948974278318,2.4142135623731 3.56342552822315,2.19534495492048 3.6578520975547,1.9673790505919 3.73205080756888,1.73205080756888 3.78545696128008,1.49115121587589 3.81766410561104,1.24651366686488 3.82842712474619,1.0 3.81766410561104,0.753486333135122 3.78545696128008,0.508848784124109 3.73205080756888,0.267949192431123 3.6578520975547,0.032620949408098 3.56342552822315,-0.195344954920481 3.44948974278318,-0.414213562373096 3.31691186135828,-0.622319150690556 3.16670088167881,-0.818077910688175 3.0,-1.0 2.81807791068817,-1.16670088167881 2.62231915069056,-1.31691186135828 2.4142135623731,-1.44948974278318 2.19534495492048,-1.56342552822315 1.9673790505919,-1.6578520975547 1.73205080756888,-1.73205080756888 1.49115121587589,-1.78545696128008 1.24651366686488,-1.81766410561103 1.0,-1.82842712474619 0.753486333135123,-1.81766410561103 0.508848784124109,-1.78545696128008 0.267949192431122,-1.73205080756888 0.032620949408099,-1.6578520975547 -0.195344954920479,-1.56342552822315 -0.414213562373095,-1.44948974278318 -0.622319150690555,-1.31691186135828 -0.818077910688175,-1.16670088167881 -1.0,-1.0 -1.16670088167881,-0.818077910688175 -1.31691186135828,-0.622319150690556 -1.44948974278318,-0.414213562373095 -1.56342552822315,-0.195344954920479 -1.6578520975547,0.032620949408099 -1.73205080756888,0.267949192431122 -1.78545696128008,0.508848784124108 -1.81766410561103,0.753486333135123 -1.82842712474619,1.0 -1.81766410561103,1.24651366686488 -1.78545696128008,1.49115121587589 -1.73205080756888,1.73205080756888 -1.6578520975547,1.9673790505919 -1.56342552822316,2.19534495492048 -1.44948974278318,2.4142135623731 -1.31691186135828,2.62231915069056 -1.16670088167881,2.81807791068817 -1.0,3.0 -0.818077910688175,3.16670088167881 -0.622319150690556,3.31691186135828 -0.414213562373096,3.44948974278318 -0.195344954920481,3.56342552822315 0.032620949408098,3.6578520975547 0.267949192431124,3.73205080756888 0.508848784124109,3.78545696128008 0.753486333135123,3.81766410561104 1.0,3.82842712474619 1.24651366686488,3.81766410561104 1.49115121587589,3.78545696128008 1.73205080756888,3.73205080756888 1.9673790505919,3.6578520975547 2.19534495492048,3.56342552822316 2.4142135623731,3.44948974278318 2.62231915069056,3.31691186135828 2.81807791068817,3.16670088167881 3.0,3.0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:intval>33</ogr:intval>
<ogr:floatval>44.12346</ogr:floatval>
<ogr:name>aaaaa</ogr:name>
<ogr:center_x>1</ogr:center_x>
<ogr:center_y>1</ogr:center_y>
<ogr:radius>2.82842712474619</ogr:radius>
<ogr:radius>2.828427</ogr:radius>
<ogr:area>25.132741</ogr:area>
</ogr:enclosing_circles_each>
</gml:featureMember>
<gml:featureMember>
<ogr:enclosing_circles_each fid="polys.3">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>7.8734693877551,2.02022790556525 8.3468951585034,1.97880851760375 8.80593612677252,1.85580886086324 9.23664456502752,1.65496621767295 9.62593361532103,1.38238309011494 9.96197492684963,1.04634177858634 10.2345580544076,0.657052728292829 10.4354006975979,0.226344290037822 10.5584003543384,-0.232696678231291 10.5998197422999,-0.706122448979591 10.5584003543384,-1.17954821972789 10.4354006975979,-1.638589187997 10.2345580544076,-2.06929762625201 9.96197492684963,-2.45858667654552 9.62593361532103,-2.79462798807412 9.23664456502752,-3.06721111563213 8.80593612677252,-3.26805375882242 8.3468951585034,-3.39105341556293 7.8734693877551,-3.43247280352443 7.4000436170068,-3.39105341556293 6.94100264873769,-3.26805375882242 6.51029421048268,-3.06721111563213 6.12100516018918,-2.79462798807412 5.78496384866057,-2.45858667654552 5.51238072110256,-2.06929762625201 5.31153807791227,-1.63858918799701 5.18853842117176,-1.17954821972789 5.14711903321026,-0.70612244897959 5.18853842117176,-0.23269667823129 5.31153807791227,0.226344290037823 5.51238072110256,0.65705272829283 5.78496384866057,1.04634177858634 6.12100516018918,1.38238309011494 6.51029421048268,1.65496621767295 6.94100264873769,1.85580886086324 7.4000436170068,1.97880851760375 7.8734693877551,2.02022790556525</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>7.8734693877551,2.02022790556525 8.1110864778958,2.00985331935853 8.3468951585034,1.97880851760375 8.57910078313332,1.92732976998763 8.80593612677252,1.85580886086324 9.02567483548898,1.76479010753453 9.23664456502752,1.65496621767295 9.43723970835934,1.52717301739383 9.62593361532103,1.38238309011494 9.80129021134411,1.22169837460941 9.96197492684963,1.04634177858634 10.1067648541285,0.85764787162465 10.2345580544076,0.657052728292829 10.3443819442692,0.446082998754287 10.4354006975979,0.226344290037822 10.5069216067223,-0.000491053601378 10.5584003543384,-0.232696678231291 10.5894451560932,-0.468505358838895 10.5998197422999,-0.706122448979591 10.5894451560932,-0.943739539120288 10.5584003543384,-1.17954821972789 10.5069216067223,-1.4117538443578 10.4354006975979,-1.638589187997 10.3443819442692,-1.85832789671347 10.2345580544076,-2.06929762625201 10.1067648541285,-2.26989276958383 9.96197492684963,-2.45858667654552 9.80129021134411,-2.6339432725686 9.62593361532103,-2.79462798807412 9.43723970835934,-2.93941791535301 9.23664456502752,-3.06721111563213 9.02567483548898,-3.17703500549371 8.80593612677252,-3.26805375882242 8.57910078313332,-3.33957466794681 8.3468951585034,-3.39105341556293 8.1110864778958,-3.42209821731771 7.8734693877551,-3.43247280352443 7.63585229761441,-3.42209821731771 7.4000436170068,-3.39105341556293 7.16783799237689,-3.33957466794681 6.94100264873769,-3.26805375882242 6.72126394002122,-3.17703500549371 6.51029421048268,-3.06721111563213 6.30969906715086,-2.93941791535301 6.12100516018918,-2.79462798807412 5.9456485641661,-2.63394327256859 5.78496384866057,-2.45858667654552 5.64017392138168,-2.26989276958383 5.51238072110256,-2.06929762625201 5.40255683124098,-1.85832789671347 5.31153807791227,-1.63858918799701 5.24001716878788,-1.4117538443578 5.18853842117176,-1.17954821972789 5.15749361941698,-0.943739539120287 5.14711903321026,-0.70612244897959 5.15749361941698,-0.468505358838894 5.18853842117176,-0.23269667823129 5.24001716878788,-0.000491053601377 5.31153807791227,0.226344290037823 5.40255683124098,0.446082998754288 5.51238072110256,0.65705272829283 5.64017392138168,0.85764787162465 5.78496384866057,1.04634177858634 5.9456485641661,1.22169837460941 6.12100516018918,1.38238309011494 6.30969906715086,1.52717301739383 6.51029421048268,1.65496621767295 6.72126394002122,1.76479010753453 6.94100264873769,1.85580886086324 7.16783799237689,1.92732976998763 7.4000436170068,1.97880851760375 7.63585229761441,2.00985331935853 7.8734693877551,2.02022790556525</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:intval>0</ogr:intval>
<ogr:name>ASDF</ogr:name>
<ogr:center_x>7.8734693877551</ogr:center_x>
<ogr:center_y>-0.706122448979591</ogr:center_y>
<ogr:radius>2.72635035454484</ogr:radius>
<ogr:radius>2.726350</ogr:radius>
<ogr:area>23.351415</ogr:area>
</ogr:enclosing_circles_each>
</gml:featureMember>
<gml:featureMember>
<ogr:enclosing_circles_each fid="polys.2">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3,6 3.0935543337087,5.86933092744047 3.16299692054554,5.72440147214358 3.20621778264911,5.56961524227066 3.22190367599521,5.40967533909081 3.20957799265196,5.24944145562864 3.16961524227066,5.09378221735089 3.10322967279951,4.94742725144526 3.01243837617418,4.81482347949161 2.9,4.7 2.76933092744047,4.6064456662913 2.62440147214358,4.53700307945446 2.46961524227066,4.49378221735089 2.30967533909081,4.47809632400479 2.14944145562864,4.49042200734804 1.99378221735089,4.53038475772934 1.84742725144526,4.59677032720049 1.71482347949161,4.68756162382582 1.6,4.8 1.5064456662913,4.93066907255953 1.43700307945446,5.07559852785642 1.39378221735089,5.23038475772934 1.37809632400479,5.39032466090919 1.39042200734804,5.55055854437136 1.43038475772934,5.70621778264911 1.49677032720049,5.85257274855473 1.58756162382582,5.98517652050839 1.7,6.1 1.83066907255953,6.1935543337087 1.97559852785642,6.26299692054554 2.13038475772934,6.30621778264911 2.29032466090919,6.32190367599521 2.45055854437136,6.30957799265196 2.60621778264911,6.26961524227066 2.75257274855473,6.20322967279951 2.88517652050839,6.11243837617418 3,6</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3,6 3.04962973431282,5.93670779893169 3.0935543337087,5.86933092744047 3.13143950546386,5.79838216420168 3.16299692054554,5.72440147214358 3.18798640797007,5.6479518890035 3.20621778264911,5.56961524227066 3.21755229281292,5.48998772112766 3.22190367599521,5.40967533909081 3.21923881554251,5.32928932188135 3.20957799265196,5.24944145562864 3.19299473201913,5.17073943080833 3.16961524227066,5.09378221735089 3.13961745544048,5.01915550611876 3.10322967279951,4.94742725144526 3.0607288273452,4.87914334865916 3.01243837617418,4.81482347949161 2.95872583877841,4.75495715698437 2.9,4.7 2.83670779893169,4.65037026568718 2.76933092744047,4.6064456662913 2.69838216420168,4.56856049453614 2.62440147214358,4.53700307945446 2.5479518890035,4.51201359202993 2.46961524227066,4.49378221735089 2.38998772112766,4.48244770718708 2.30967533909081,4.47809632400479 2.22928932188134,4.48076118445749 2.14944145562864,4.49042200734804 2.07073943080833,4.50700526798087 1.99378221735089,4.53038475772934 1.91915550611876,4.56038254455952 1.84742725144526,4.59677032720049 1.77914334865916,4.63927117265479 1.71482347949161,4.68756162382582 1.65495715698437,4.74127416122159 1.6,4.8 1.55037026568718,4.86329220106831 1.5064456662913,4.93066907255953 1.46856049453614,5.00161783579832 1.43700307945446,5.07559852785642 1.41201359202993,5.1520481109965 1.39378221735089,5.23038475772934 1.38244770718708,5.31001227887234 1.37809632400479,5.39032466090919 1.38076118445749,5.47071067811865 1.39042200734804,5.55055854437136 1.40700526798087,5.62926056919167 1.43038475772934,5.70621778264911 1.46038254455952,5.78084449388124 1.49677032720049,5.85257274855473 1.53927117265479,5.92085665134084 1.58756162382582,5.98517652050839 1.64127416122159,6.04504284301563 1.7,6.1 1.76329220106831,6.14962973431282 1.83066907255953,6.1935543337087 1.90161783579832,6.23143950546386 1.97559852785642,6.26299692054554 2.0520481109965,6.28798640797008 2.13038475772934,6.30621778264911 2.21001227887234,6.31755229281292 2.29032466090919,6.32190367599521 2.37071067811865,6.31923881554251 2.45055854437136,6.30957799265196 2.52926056919167,6.29299473201913 2.60621778264911,6.26961524227066 2.68084449388124,6.23961745544048 2.75257274855473,6.20322967279951 2.82085665134084,6.16072882734521 2.88517652050839,6.11243837617418 2.94504284301563,6.05872583877841 3,6</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:floatval>0.123</ogr:floatval>
<ogr:name>bbaaa</ogr:name>
<ogr:center_x>2.3</ogr:center_x>
<ogr:center_y>5.4</ogr:center_y>
<ogr:radius>0.921954445729289</ogr:radius>
<ogr:radius>0.921954</ogr:radius>
<ogr:area>2.670354</ogr:area>
</ogr:enclosing_circles_each>
</gml:featureMember>
<gml:featureMember>
<ogr:enclosing_circles_each fid="polys.5">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3.8,2.2 4.26819673362059,2.35151315326536 4.75559048978224,2.4194229717016 5.24737205583712,2.40166604983954 5.72859889775413,2.29878192276454 6.18464918145415,2.11389667261588 6.60166604983954,1.85262794416288 6.96697865638513,1.52291425551124 7.26948716239812,1.13477379024745 7.5,0.7 7.65151315326536,0.23180326637941 7.7194229717016,-0.255590489782239 7.70166604983954,-0.747372055837116 7.59878192276454,-1.22859889775413 7.41389667261588,-1.68464918145415 7.15262794416288,-2.10166604983954 6.82291425551124,-2.46697865638513 6.43477379024745,-2.76948716239812 6.0,-3.0 5.53180326637941,-3.15151315326536 5.04440951021776,-3.2194229717016 4.55262794416288,-3.20166604983954 4.07140110224587,-3.09878192276454 3.61535081854585,-2.91389667261588 3.19833395016046,-2.65262794416288 2.83302134361487,-2.32291425551124 2.53051283760188,-1.93477379024745 2.3,-1.5 2.14848684673464,-1.03180326637941 2.0805770282984,-0.544409510217762 2.09833395016046,-0.052627944162882 2.20121807723546,0.428598897754127 2.38610332738412,0.884649181454149 2.64737205583712,1.30166604983954 2.97708574448876,1.66697865638513 3.36522620975255,1.96948716239812 3.8,2.2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3.8,2.2 4.03079076324299,2.28597753206096 4.26819673362059,2.35151315326536 4.51041110834858,2.39610809796435 4.75559048978224,2.4194229717016 5.00186891478551,2.42128033421006 5.24737205583712,2.40166604983954 5.49023148579483,2.36072939513753 5.72859889775413,2.29878192276454 5.96066017177982,2.21629509039023 6.18464918145415,2.11389667261588 6.39886123516523,1.99236598323061 6.60166604983954,1.85262794416288 6.79152015838052,1.69574604626613 6.96697865638513,1.52291425551124 7.12670619873881,1.33544792618453 7.26948716239812,1.13477379024745 7.39423489801611,0.922419099044831 7.5,0.7 7.58597753206096,0.469209236757009 7.65151315326536,0.23180326637941 7.69610809796435,-0.010411108348578 7.7194229717016,-0.255590489782239 7.72128033421006,-0.501868914785503 7.70166604983954,-0.747372055837116 7.66072939513753,-0.990231485794827 7.59878192276454,-1.22859889775413 7.51629509039023,-1.46066017177982 7.41389667261588,-1.68464918145415 7.29236598323061,-1.89886123516523 7.15262794416288,-2.10166604983954 6.99574604626613,-2.29152015838052 6.82291425551124,-2.46697865638513 6.63544792618453,-2.6267061987388 6.43477379024745,-2.76948716239812 6.22241909904483,-2.89423489801611 6.0,-3.0 5.76920923675701,-3.08597753206096 5.53180326637941,-3.15151315326536 5.28958889165142,-3.19610809796435 5.04440951021776,-3.2194229717016 4.7981310852145,-3.22128033421006 4.55262794416288,-3.20166604983954 4.30976851420517,-3.16072939513753 4.07140110224587,-3.09878192276454 3.83933982822018,-3.01629509039023 3.61535081854585,-2.91389667261588 3.40113876483477,-2.79236598323061 3.19833395016046,-2.65262794416288 3.00847984161948,-2.49574604626613 2.83302134361487,-2.32291425551124 2.67329380126119,-2.13544792618453 2.53051283760188,-1.93477379024745 2.40576510198389,-1.72241909904483 2.3,-1.5 2.21402246793904,-1.26920923675701 2.14848684673464,-1.03180326637941 2.10389190203565,-0.789588891651422 2.0805770282984,-0.544409510217762 2.07871966578994,-0.298131085214498 2.09833395016046,-0.052627944162882 2.13927060486247,0.190231485794829 2.20121807723546,0.428598897754127 2.28370490960977,0.660660171779822 2.38610332738412,0.884649181454149 2.50763401676939,1.09886123516523 2.64737205583712,1.30166604983954 2.80425395373387,1.49152015838052 2.97708574448876,1.66697865638513 3.16455207381547,1.82670619873881 3.36522620975255,1.96948716239812 3.57758090095517,2.09423489801611 3.8,2.2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:intval>2</ogr:intval>
<ogr:floatval>3.33</ogr:floatval>
<ogr:name>elim</ogr:name>
<ogr:center_x>4.9</ogr:center_x>
<ogr:center_y>-0.4</ogr:center_y>
<ogr:radius>2.82311884269862</ogr:radius>
<ogr:radius>2.823119</ogr:radius>
<ogr:area>25.038493</ogr:area>
</ogr:enclosing_circles_each>
</gml:featureMember>
</ogr:FeatureCollection>

View File

@ -22,21 +22,6 @@
<ElementPath>floatval</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>area</Name>
<ElementPath>area</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>perimeter</Name>
<ElementPath>perimeter</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>angle</Name>
<ElementPath>angle</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>width</Name>
<ElementPath>width</ElementPath>
@ -47,6 +32,21 @@
<ElementPath>height</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>angle</Name>
<ElementPath>angle</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>area</Name>
<ElementPath>area</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>perimeter</Name>
<ElementPath>perimeter</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>name</Name>
<ElementPath>name</ElementPath>

View File

@ -16,11 +16,11 @@
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>6,-3 7.69811320754717,0.056603773584906 3.80943396226415,2.21698113207547 2.11132075471698,-0.839622641509436 6,-3</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:intval>120</ogr:intval>
<ogr:floatval>-100291.43213</ogr:floatval>
<ogr:area>15.5547169811321</ogr:area>
<ogr:perimeter>15.8902367081648</ogr:perimeter>
<ogr:angle>119.054604099077</ogr:angle>
<ogr:width>3.49662910448615</ogr:width>
<ogr:height>4.44848924959627</ogr:height>
<ogr:width>3.496629</ogr:width>
<ogr:height>4.448489</ogr:height>
<ogr:angle>119.054604</ogr:angle>
<ogr:area>15.554717</ogr:area>
<ogr:perimeter>15.890237</ogr:perimeter>
</ogr:oriented_bounds>
</gml:featureMember>
<gml:featureMember>
@ -29,11 +29,11 @@
<ogr:intval>-33</ogr:intval>
<ogr:floatval>0</ogr:floatval>
<ogr:name>Aaaaa</ogr:name>
<ogr:area>2.16470588235294</ogr:area>
<ogr:perimeter>6.11189775091559</ogr:perimeter>
<ogr:angle>165.963756532073</ogr:angle>
<ogr:width>1.94028500029066</ogr:width>
<ogr:height>1.11566387516713</ogr:height>
<ogr:width>1.940285</ogr:width>
<ogr:height>1.115664</ogr:height>
<ogr:angle>165.963757</ogr:angle>
<ogr:area>2.164706</ogr:area>
<ogr:perimeter>6.111898</ogr:perimeter>
</ogr:oriented_bounds>
</gml:featureMember>
<gml:featureMember>
@ -42,11 +42,11 @@
<ogr:intval>33</ogr:intval>
<ogr:floatval>44.12346</ogr:floatval>
<ogr:name>aaaaa</ogr:name>
<ogr:area>16</ogr:area>
<ogr:perimeter>16</ogr:perimeter>
<ogr:angle>90</ogr:angle>
<ogr:width>4</ogr:width>
<ogr:height>4</ogr:height>
<ogr:width>4.000000</ogr:width>
<ogr:height>4.000000</ogr:height>
<ogr:angle>90.000000</ogr:angle>
<ogr:area>16.000000</ogr:area>
<ogr:perimeter>16.000000</ogr:perimeter>
</ogr:oriented_bounds>
</gml:featureMember>
<gml:featureMember>
@ -54,11 +54,11 @@
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>6.4,-3.0 9.64413793103449,-3.27034482758621 10.0441379310345,1.52965517241379 6.8,1.8 6.4,-3.0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:intval>0</ogr:intval>
<ogr:name>ASDF</ogr:name>
<ogr:area>15.68</ogr:area>
<ogr:perimeter>16.1440412835671</ogr:perimeter>
<ogr:angle>4.76364169072617</ogr:angle>
<ogr:width>3.25538281026661</ogr:width>
<ogr:height>4.81663783151692</ogr:height>
<ogr:width>3.255383</ogr:width>
<ogr:height>4.816638</ogr:height>
<ogr:angle>4.763642</ogr:angle>
<ogr:area>15.680000</ogr:area>
<ogr:perimeter>16.144041</ogr:perimeter>
</ogr:oriented_bounds>
</gml:featureMember>
<gml:featureMember>
@ -66,11 +66,11 @@
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1.36470588235294,4.94117647058824 2.1,4.5 3.0,6.0 2.26470588235294,6.44117647058824 1.36470588235294,4.94117647058824</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:floatval>0.123</ogr:floatval>
<ogr:name>bbaaa</ogr:name>
<ogr:area>1.5</ogr:area>
<ogr:perimeter>5.21355698833227</ogr:perimeter>
<ogr:angle>30.9637565320735</ogr:angle>
<ogr:width>0.857492925712544</ogr:width>
<ogr:height>1.74928556845359</ogr:height>
<ogr:width>0.857493</ogr:width>
<ogr:height>1.749286</ogr:height>
<ogr:angle>30.963757</ogr:angle>
<ogr:area>1.500000</ogr:area>
<ogr:perimeter>5.213557</ogr:perimeter>
</ogr:oriented_bounds>
</gml:featureMember>
<gml:featureMember>
@ -79,11 +79,11 @@
<ogr:intval>2</ogr:intval>
<ogr:floatval>3.33</ogr:floatval>
<ogr:name>elim</ogr:name>
<ogr:area>15.5547169811321</ogr:area>
<ogr:perimeter>15.8902367081648</ogr:perimeter>
<ogr:angle>119.054604099077</ogr:angle>
<ogr:width>3.49662910448615</ogr:width>
<ogr:height>4.44848924959627</ogr:height>
<ogr:width>3.496629</ogr:width>
<ogr:height>4.448489</ogr:height>
<ogr:angle>119.054604</ogr:angle>
<ogr:area>15.554717</ogr:area>
<ogr:perimeter>15.890237</ogr:perimeter>
</ogr:oriented_bounds>
</gml:featureMember>
</ogr:FeatureCollection>

View File

@ -610,7 +610,7 @@ tests:
name: expected/multi_to_single.gml
type: vector
- algorithm: qgis:boundingboxes
- algorithm: native:boundingboxes
name: Bounding boxes for lines
params:
INPUT:
@ -621,7 +621,7 @@ tests:
name: expected/lines_bounds.gml
type: vector
- algorithm: qgis:boundingboxes
- algorithm: native:boundingboxes
name: Bounding boxes for multilines
params:
INPUT:
@ -632,7 +632,7 @@ tests:
name: expected/multiline_bounds.gml
type: vector
- algorithm: qgis:boundingboxes
- algorithm: native:boundingboxes
name: Bounding boxes for multipolygons
params:
INPUT:
@ -643,7 +643,7 @@ tests:
name: expected/multipoly_bounds.gml
type: vector
- algorithm: qgis:boundingboxes
- algorithm: native:boundingboxes
name: Bounding boxes for points
params:
INPUT:
@ -654,7 +654,7 @@ tests:
name: expected/point_bounds.gml
type: vector
- algorithm: qgis:boundingboxes
- algorithm: native:boundingboxes
name: Bounding boxes for polygons
params:
INPUT:
@ -665,7 +665,7 @@ tests:
name: expected/poly_bounds.gml
type: vector
- algorithm: qgis:boundingboxes
- algorithm: native:boundingboxes
name: Bounding boxes for multipoints
params:
INPUT:
@ -2241,10 +2241,9 @@ tests:
hash: fe6e018be13c5a3c17f3f4d0f0dc7686c628cb440b74c4642aa0c939
type: rasterhash
- algorithm: qgis:orientedminimumboundingbox
- algorithm: native:orientedminimumboundingbox
name: Oriented minimum bounding box polys
params:
BY_FEATURE: true
INPUT:
name: custom/oriented_bbox.gml
type: vector
@ -3240,7 +3239,7 @@ tests:
name: expected/raster_extent.gml
type: vector
- algorithm: qgis:minimalenclosingcircle
- algorithm: native:minimumenclosingcircle
name: Minimal enclosing circle each features
params:
BY_FEATURE: true
@ -3421,3 +3420,14 @@ tests:
fields:
fid: skip
id: skip
- algorithm: native:convexhull
name: Convex hull by feature
params:
INPUT:
name: custom/oriented_bbox.gml
type: vector
results:
OUTPUT:
name: expected/convex_hull_by_feature.gml
type: vector

View File

@ -68,6 +68,10 @@ void QgsNativeAlgorithms::loadAlgorithms()
addAlgorithm( new QgsSubdivideAlgorithm() );
addAlgorithm( new QgsTransformAlgorithm() );
addAlgorithm( new QgsRemoveNullGeometryAlgorithm() );
addAlgorithm( new QgsBoundingBoxAlgorithm() );
addAlgorithm( new QgsOrientedMinimumBoundingBoxAlgorithm() );
addAlgorithm( new QgsMinimumEnclosingCircleAlgorithm() );
addAlgorithm( new QgsConvexHullAlgorithm() );
}
void QgsCentroidAlgorithm::initAlgorithm( const QVariantMap & )
@ -1087,4 +1091,175 @@ QVariantMap QgsRemoveNullGeometryAlgorithm::processAlgorithm( const QVariantMap
}
QString QgsBoundingBoxAlgorithm::shortHelpString() const
{
return QObject::tr( "This algorithm calculates the bounding box (envelope) of each feature in an input layer." );
}
QgsBoundingBoxAlgorithm *QgsBoundingBoxAlgorithm::createInstance() const
{
return new QgsBoundingBoxAlgorithm();
}
QgsFields QgsBoundingBoxAlgorithm::outputFields( const QgsFields &inputFields ) const
{
QgsFields fields = inputFields;
fields.append( QgsField( QStringLiteral( "width" ), QVariant::Double, QString(), 20, 6 ) );
fields.append( QgsField( QStringLiteral( "height" ), QVariant::Double, QString(), 20, 6 ) );
fields.append( QgsField( QStringLiteral( "area" ), QVariant::Double, QString(), 20, 6 ) );
fields.append( QgsField( QStringLiteral( "perimeter" ), QVariant::Double, QString(), 20, 6 ) );
return fields;
}
QgsFeature QgsBoundingBoxAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingFeedback * )
{
QgsFeature f = feature;
if ( f.hasGeometry() )
{
QgsRectangle bounds = f.geometry().boundingBox();
QgsGeometry outputGeometry = QgsGeometry::fromRect( bounds );
f.setGeometry( outputGeometry );
QgsAttributes attrs = f.attributes();
attrs << bounds.width()
<< bounds.height()
<< bounds.area()
<< bounds.perimeter();
f.setAttributes( attrs );
}
return f;
}
QString QgsOrientedMinimumBoundingBoxAlgorithm::shortHelpString() const
{
return QObject::tr( "This algorithm calculates the minimum area rotated rectangle which covers each feature in an input layer." );
}
QgsOrientedMinimumBoundingBoxAlgorithm *QgsOrientedMinimumBoundingBoxAlgorithm::createInstance() const
{
return new QgsOrientedMinimumBoundingBoxAlgorithm();
}
QgsFields QgsOrientedMinimumBoundingBoxAlgorithm::outputFields( const QgsFields &inputFields ) const
{
QgsFields fields = inputFields;
fields.append( QgsField( QStringLiteral( "width" ), QVariant::Double, QString(), 20, 6 ) );
fields.append( QgsField( QStringLiteral( "height" ), QVariant::Double, QString(), 20, 6 ) );
fields.append( QgsField( QStringLiteral( "angle" ), QVariant::Double, QString(), 20, 6 ) );
fields.append( QgsField( QStringLiteral( "area" ), QVariant::Double, QString(), 20, 6 ) );
fields.append( QgsField( QStringLiteral( "perimeter" ), QVariant::Double, QString(), 20, 6 ) );
return fields;
}
QgsFeature QgsOrientedMinimumBoundingBoxAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingFeedback * )
{
QgsFeature f = feature;
if ( f.hasGeometry() )
{
double area = 0;
double angle = 0;
double width = 0;
double height = 0;
QgsGeometry outputGeometry = f.geometry().orientedMinimumBoundingBox( area, angle, width, height );
f.setGeometry( outputGeometry );
QgsAttributes attrs = f.attributes();
attrs << width
<< height
<< angle
<< area
<< 2 * width + 2 * height;
f.setAttributes( attrs );
}
return f;
}
void QgsMinimumEnclosingCircleAlgorithm::initParameters( const QVariantMap & )
{
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "SEGMENTS" ), QObject::tr( "Number of segments in circles" ), QgsProcessingParameterNumber::Integer,
72, false, 8, 100000 ) );
}
QString QgsMinimumEnclosingCircleAlgorithm::shortHelpString() const
{
return QObject::tr( "This algorithm calculates the minimum enclosing circle which covers each feature in an input layer." );
}
QgsMinimumEnclosingCircleAlgorithm *QgsMinimumEnclosingCircleAlgorithm::createInstance() const
{
return new QgsMinimumEnclosingCircleAlgorithm();
}
QgsFields QgsMinimumEnclosingCircleAlgorithm::outputFields( const QgsFields &inputFields ) const
{
QgsFields fields = inputFields;
fields.append( QgsField( QStringLiteral( "radius" ), QVariant::Double, QString(), 20, 6 ) );
fields.append( QgsField( QStringLiteral( "area" ), QVariant::Double, QString(), 20, 6 ) );
return fields;
}
bool QgsMinimumEnclosingCircleAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
{
mSegments = parameterAsInt( parameters, QStringLiteral( "SEGMENTS" ), context );
return true;
}
QgsFeature QgsMinimumEnclosingCircleAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingFeedback * )
{
QgsFeature f = feature;
if ( f.hasGeometry() )
{
double radius = 0;
QgsPointXY center;
QgsGeometry outputGeometry = f.geometry().minimalEnclosingCircle( center, radius, mSegments );
f.setGeometry( outputGeometry );
QgsAttributes attrs = f.attributes();
attrs << radius
<< M_PI *radius *radius;
f.setAttributes( attrs );
}
return f;
}
QString QgsConvexHullAlgorithm::shortHelpString() const
{
return QObject::tr( "This algorithm calculates the convex hull for each feature in an input layer." );
}
QgsConvexHullAlgorithm *QgsConvexHullAlgorithm::createInstance() const
{
return new QgsConvexHullAlgorithm();
}
QgsFields QgsConvexHullAlgorithm::outputFields( const QgsFields &inputFields ) const
{
QgsFields fields = inputFields;
fields.append( QgsField( QStringLiteral( "area" ), QVariant::Double, QString(), 20, 6 ) );
fields.append( QgsField( QStringLiteral( "perimeter" ), QVariant::Double, QString(), 20, 6 ) );
return fields;
}
QgsFeature QgsConvexHullAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingFeedback *feedback )
{
QgsFeature f = feature;
if ( f.hasGeometry() )
{
QgsGeometry outputGeometry = f.geometry().convexHull();
if ( !outputGeometry )
feedback->reportError( outputGeometry.lastError() );
f.setGeometry( outputGeometry );
if ( outputGeometry )
{
QgsAttributes attrs = f.attributes();
attrs << outputGeometry.geometry()->area()
<< outputGeometry.geometry()->perimeter();
f.setAttributes( attrs );
}
}
return f;
}
///@endcond

View File

@ -323,6 +323,107 @@ class QgsRemoveNullGeometryAlgorithm : public QgsProcessingAlgorithm
};
/**
* Native bounding boxes algorithm.
*/
class QgsBoundingBoxAlgorithm : public QgsProcessingFeatureBasedAlgorithm
{
public:
QgsBoundingBoxAlgorithm() = default;
QString name() const override { return QStringLiteral( "boundingboxes" ); }
QString displayName() const override { return QObject::tr( "Bounding boxes" ); }
virtual QStringList tags() const override { return QObject::tr( "bounding,boxes,envelope,rectangle,extent" ).split( ',' ); }
QString group() const override { return QObject::tr( "Vector geometry" ); }
QString shortHelpString() const override;
QgsBoundingBoxAlgorithm *createInstance() const override SIP_FACTORY;
protected:
QString outputName() const override { return QObject::tr( "Bounds" ); }
QgsWkbTypes::Type outputWkbType( QgsWkbTypes::Type ) const override { return QgsWkbTypes::Polygon; }
QgsFields outputFields( const QgsFields &inputFields ) const override;
QgsFeature processFeature( const QgsFeature &feature, QgsProcessingFeedback *feedback ) override;
};
/**
* Native minimum oriented bounding box algorithm.
*/
class QgsOrientedMinimumBoundingBoxAlgorithm : public QgsProcessingFeatureBasedAlgorithm
{
public:
QgsOrientedMinimumBoundingBoxAlgorithm() = default;
QString name() const override { return QStringLiteral( "orientedminimumboundingbox" ); }
QString displayName() const override { return QObject::tr( "Oriented minimum bounding box" ); }
virtual QStringList tags() const override { return QObject::tr( "bounding,boxes,envelope,rectangle,extent,oriented,angle" ).split( ',' ); }
QString group() const override { return QObject::tr( "Vector geometry" ); }
QString shortHelpString() const override;
QgsOrientedMinimumBoundingBoxAlgorithm *createInstance() const override SIP_FACTORY;
protected:
QString outputName() const override { return QObject::tr( "Bounding boxes" ); }
QgsWkbTypes::Type outputWkbType( QgsWkbTypes::Type ) const override { return QgsWkbTypes::Polygon; }
QgsFields outputFields( const QgsFields &inputFields ) const override;
QgsFeature processFeature( const QgsFeature &feature, QgsProcessingFeedback *feedback ) override;
};
/**
* Native minimum enclosing circle algorithm.
*/
class QgsMinimumEnclosingCircleAlgorithm : public QgsProcessingFeatureBasedAlgorithm
{
public:
QgsMinimumEnclosingCircleAlgorithm() = default;
void initParameters( const QVariantMap &configuration = QVariantMap() ) override;
QString name() const override { return QStringLiteral( "minimumenclosingcircle" ); }
QString displayName() const override { return QObject::tr( "Minimum enclosing circles" ); }
virtual QStringList tags() const override { return QObject::tr( "minimum,circle,ellipse,extent,bounds,bounding" ).split( ',' ); }
QString group() const override { return QObject::tr( "Vector geometry" ); }
QString shortHelpString() const override;
QgsMinimumEnclosingCircleAlgorithm *createInstance() const override SIP_FACTORY;
protected:
QString outputName() const override { return QObject::tr( "Minimum enclosing circles" ); }
QgsWkbTypes::Type outputWkbType( QgsWkbTypes::Type ) const override { return QgsWkbTypes::Polygon; }
QgsFields outputFields( const QgsFields &inputFields ) const override;
bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
QgsFeature processFeature( const QgsFeature &feature, QgsProcessingFeedback *feedback ) override;
private:
int mSegments = 72;
};
/**
* Native convex hull algorithm.
*/
class QgsConvexHullAlgorithm : public QgsProcessingFeatureBasedAlgorithm
{
public:
QgsConvexHullAlgorithm() = default;
QString name() const override { return QStringLiteral( "convexhull" ); }
QString displayName() const override { return QObject::tr( "Convex hull" ); }
virtual QStringList tags() const override { return QObject::tr( "convex,hull,bounds,bounding" ).split( ',' ); }
QString group() const override { return QObject::tr( "Vector geometry" ); }
QString shortHelpString() const override;
QgsConvexHullAlgorithm *createInstance() const override SIP_FACTORY;
protected:
QString outputName() const override { return QObject::tr( "Convex hulls" ); }
QgsWkbTypes::Type outputWkbType( QgsWkbTypes::Type ) const override { return QgsWkbTypes::Polygon; }
QgsFields outputFields( const QgsFields &inputFields ) const override;
QgsFeature processFeature( const QgsFeature &feature, QgsProcessingFeedback *feedback ) override;
};
///@endcond PRIVATE
#endif // QGSNATIVEALGORITHMS_H