<table><tr><td style="">tandon created this revision.<br />tandon added reviewers: nienhueser, rahn.<br />tandon added a subscriber: nienhueser.<br />tandon set the repository for this revision to R34 Marble.<br />tandon added a project: Marble.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D3747" rel="noreferrer">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>The older buildings merger was using DBSCAN clustering algorithm to identify building clusters and was then merging all the buildings in a particular cluster into a single building. However, this approach was resulting in formation of irregular buildings/polygons.</p>

<p>This new buildings merger, instead of finding cluster of buildings, is finding buildings which share a common boundary and all the buildings which share a common boundary are then merged into a single building.</p>

<p>The algorithm was suggested to me by <a href="https://phabricator.kde.org/p/nienhueser/" style="
              border-color: #f1f7ff;
              color: #19558d;
              background-color: #f1f7ff;
                border: 1px solid transparent;
                border-radius: 3px;
                font-weight: bold;
                padding: 0 4px;" rel="noreferrer">@nienhueser</a></p>

<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>The idea is to construct a graph where each node is a building and two nodes are connected by an edge in case they share a common point. This could be done by using a QHash<GeoDataCoordinates, QSet<GeoDataPlacemark*> > which would be filled by iterating over all outer boundaries of the building polygons. Afterwards this data structure would have to be converted to a graph. An adjacency matrix might be an easy way to represent/construct it. In the last step the clustering could be performed in that graph: all nodes connected by edges are a cluster.</p></blockquote>

<p>After forming the graph, the program is finding strongly connected components to identify the buildings which share a common boundary. Each graph component is then merged into a single building. This is done via edge-contraction, i.e. the program takes two adjacent nodes(buildings) of a graph and merges them into a single node. It keeps on doing this for a component till a single node/building is reached.</p>

<p>However, some problems are still persisting-</p>

<p>In-spite of having common boundaries, QPolygonF::united() is not merging two adjacent buildings correctly.<br />
In order to circumvent this problem, I used clipper libraries union method. This corrected the above problem, but lead to disappearance of many building blocks.</p>

<p>Original <br />
<a href="https://phabricator.kde.org/F832602" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;" rel="noreferrer">F832602: sample.png</a></p>

<p>Merged using QPolygonF::united()<br />
Buildings not getting merged properly<br />
<a href="https://phabricator.kde.org/F832609" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;" rel="noreferrer">F832609: qpol.png</a></p>

<p>Merged using clipper library union method<br />
Buildings getting merged but some buildings disappear<br />
<a href="https://phabricator.kde.org/F832610" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;" rel="noreferrer">F832610: clipp.png</a></p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R34 Marble</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D3747" rel="noreferrer">https://phabricator.kde.org/D3747</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>tools/vectorosm-tilecreator/BuildingBlock.cpp<br />
tools/vectorosm-tilecreator/BuildingBlock.h<br />
tools/vectorosm-tilecreator/BuildingMerger.cpp<br />
tools/vectorosm-tilecreator/BuildingMerger.h<br />
tools/vectorosm-tilecreator/CMakeLists.txt<br />
tools/vectorosm-tilecreator/vectorosm-tilecreator.cpp</div></div></div><br /><div><strong>EMAIL PREFERENCES</strong><div><a href="https://phabricator.kde.org/settings/panel/emailpreferences/" rel="noreferrer">https://phabricator.kde.org/settings/panel/emailpreferences/</a></div></div><br /><div><strong>To: </strong>tandon, nienhueser, rahn<br /><strong>Cc: </strong>nienhueser, mnafees, shentey, chaz6, dkolozsvari, cmihalache, rahn, marble-devel<br /></div>