Skip to content

Commit

Permalink
[FEATURE] Split minimum enclosing geometry algs into separate
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nyalldawson committed Sep 3, 2017
1 parent b6e3542 commit 85cd1c1
Show file tree
Hide file tree
Showing 9 changed files with 471 additions and 83 deletions.
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -23,18 +23,13 @@
<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>
<Name>radius</Name>
<ElementPath>radius</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>radius</Name>
<ElementPath>radius</ElementPath>
<Name>area</Name>
<ElementPath>area</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
Expand Down
Loading

0 comments on commit 85cd1c1

Please sign in to comment.