Elsevier

Computers & Graphics

Volume 25, Issue 1, February 2001, Pages 77-88
Computers & Graphics

Technical Section
Merging a set of polygons

https://doi.org/10.1016/S0097-8493(00)00109-6Get rights and content

Abstract

The paper presents a new algorithm for merging a set of polygons based on a sweep-line technique. The algorithm operates on simple polygons and a limited set of non-simple polygons considered as legal polygons. At first, the algorithm separates loops and rings of the polygons located at the odd levels of hierarchy. The sweeping process is then started separately for the loops and the rings. During sweeping the loops, the inner polygons are identified. They participate at filling the holes what is done in the second step. The main task of the sweeping process is to determine common vertices and overlapping edges. After that, merging of the polygons is realized by a walk-about of the edges. The expected time complexity of the algorithm is O(klogk),k=m+I where m represents the total number of vertices of all polygons in the input set, and I is the number of touching edges among polygons. At the end the efficiency of the algorithm is illustrated using data from geodesy.

Introduction

Polygons are the most frequently needed geometric entities used in 3D and 2D applications. In 3D, polygons are used to describe faces at boundary representation [1] while in 2D, polygons actually represent the final shape of objects. The applications vary from setting a layout of the furniture up to designing the true-type fonts. On polygons, different operations can be executed. The most elementary require only a few lines of code, as for example, determination if a point is inside a given polygon [2], or calculating the area of the polygon [3]. On the other hand, more complex tasks, as splitting the polygon by a polyline [4], determination of the polygon outlines [5], dividing the polygons into simpler polygons (e.g., polygon triangulation [6] or trapezoidation [7], [8]), or clipping the lines by a polygon [9], [10] require careful study and implementation of algorithms to achieve robust and efficient implementations. Among these, Boolean operations (a union, an intersection, and a difference) play a special role because of their areas of application. Although Boolean operations are extremely important, just a few efficient algorithms exist for their support [11], [12]. For convex polygons, for example, O’Rourke developed an efficient algorithm working in O(n+m) time (n and m are the numbers of both polygons vertices) [5]. For concave polygons, in the worst case, time complexity better than O(n×m)=O(n2),n>=m cannot be achieved. The core for improving the time complexity of the Boolean operations on concave polygons is a determination of intersection points between input polygons. Solutions working in O(klogk),k=m+n+I, where I is the actual number of intersection points, are described in [13], [14].

This paper deals with the problem of merging a set of polygons. Although merging the polygons is a special case of the union of polygons, this operation is very frequently needed in some applications. In geographic information systems (GIS), for example, polygons represent parcels, which do not overlap; they always touch at their borders. The algorithms for the Boolean union assume that polygons overlap partially, and touching is just a special case often not implemented carefully enough. The classical implementations of Boolean operations also accept only two polygons at the input. On the other hand, it is often required to merge more polygons with the same property (for example, we are looking for the parcels of the same owner, those covered by forest, or those which are overpopulated, etc.). In such cases, a huge number of polygons have to be considered and merged. A consecutive application of merging the pairs of polygons and their results works in O(p3), where p is the number of involved polygons. Considering that in the worse case the union between two polygons needs O(n×m)=O(n2) time, then such an approach is totally unacceptable in real situations.

This was the motivation to develop an algorithm, which merges the whole set of polygons at once. Because it is specially designed for the merging operation, it is optimised for this task. The paper is divided into seven sections. Section 2 introduces employed vocabulary and annotations. The algorithm is explained in Section 3. Section 4 deals with non-simple polygons, and Section 5 with the estimation of time complexity of the algorithm, respectively. Practical results are given in Section 6. Finally, in Section 7 the conclusions are drawn.

Section snippets

Background

Let us have n points p0,p1,…,pn−1 in the plane and n line segments l0=p0p1, l1=p1p2, ln−1=pn−1p0 connecting these points. They determine a simple polygon if [5]:

  • the neighbouring line segments meet at only one common point,

  • non-neighbouring line segments do not have any point in common (they do not intersect neither touch).

The line segments are considered as polygon edges and the points where these line segments meet as vertices of a polygon.

Any polygon not satisfying these two conditions is

The merging algorithm

The algorithm for merging the set of legal polygons consists of the following main steps:

  • forming the separated lists of oriented polygons loops and rings,

  • merging the loops,

  • maintaining the holes, and

  • inserting the holes into the merged loops.

In the continuation, these steps are described in detail.

Repairing “ill polygons”

The majority of algorithms operating on polygons work correctly only with simple polygons. However, in practice, non-simple (or “ill”) polygons may appear because of mistake in the input data. Such polygons have to be detected, automatically repaired, if possible, or removed from the further consideration with a notice to the user. Because of the area of application (GIS), we have to expand the set of acceptable polygons and we have considered them as legal polygons (see Section 2). If a

Time complexity estimation of merging algorithm

To analyse the presented merging algorithm regarding time complexity, the annotation introduced in Section 2 is used. The analysis follows the steps of the algorithm explained in Section 3:

(a)Forming the list of oriented loops and rings. In the beginning, two lists are generated: ListOfLoops and ListOfHoles. There are n polygons in the set Π with J holes and therefore, this step is finished in linear time O(n+J).
(b)Sweeping the loops and removing the inner polygons. At first, all mΠ polygons

Practical results

The presented merging algorithm has been developed for a software company specialised in geographic applications and it has been successfully used for more than a year. As known, GIS systems contain geometric and alphanumeric information. The groups of polygons are created regarding a key obtained form the alphanumeric data. During the run-time, the algorithm reads the group of polygons from the database, performs the merging, and stores the merged polygons back to the database (ESRI database

Conclusions

The paper considers a new algorithm for merging a set of polygons. Although merging is just a special case of the Boolean union, it is often needed in practice. For example, in geodesic information systems polygons represent pieces of land and these pieces do not overlap — they just touch. Having in mind this special case, an efficient algorithm has been developed using a sweep-line acceleration technique. The algorithm is described in details in Section 3. At the input, the algorithm accepts

Acknowledgements

This work was carried out partially within bilateral Slovene-Czech project Algorithms for Computer Graphics, Computational Geometry and Visualization in Parallel and Distributed Processing (ME-259). It has also been supported by the Slovene GIS company IGEA, d.o.o. And, nevertheless, the author would like to thank the anonymous referees for useful suggestions to improve the paper.

References (19)

There are more references available in the full text version of this article.

Cited by (15)

  • A geometric and topological system for supporting agricultural subsidies in Slovenia

    2009, Computers and Electronics in Agriculture
    Citation Excerpt :

    These operations are relatively simple when implementing, although some care has to be taken to prevent incorrect actions by users. Algorithmically more demanding are those operations from the second group where typical operations are, for example, polygon splitting (Cigale and Žalik, 1999), polygon merging (Klajnšek and Žalik, 2005; Žalik, 2001), polygon clipping (Greiner and Horman, 1998; Skala, 1993), and Boolean operations (Liu et al., 2007; Vatti, 1992). The geometrical and topological system (GTS) supports geometrical and topological operations on polygons and GUAUs.

  • Optimal design of flat patterns for 3D folded structures by unfolding with topological validation

    2007, CAD Computer Aided Design
    Citation Excerpt :

    Intersection detection between two simple polygons has been an important research field of computational geometry. The techniques applied in this work are the point location query and the sweep-line algorithm, the working principles of which can be found in [35] and [36], respectively. Together they can be used to detect both types of overlapping (Fig. 6(c) and (d)).

  • UrbanEvolver: Function-Aware Urban Layout Regeneration

    2024, International Journal of Computer Vision
  • Polygon Merge: A Geometric Algorithm Verified Using PVS

    2021, Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics)
  • Parallel Simulation Calculation and Visualization Technology of Network Radar System Actual Detection Power in Urban Building Environment

    2019, ICSIDP 2019 - IEEE International Conference on Signal, Information and Data Processing 2019
View all citing articles on Scopus
View full text