• No results found

Data Storage and Persistence

In document DiplThesisJena07 (Page 50-56)

Data efficiency is an important aspect in a geometry since thousands of objects may be instantiated to represent a whole map. It is a typical problem of GIS that large datasets cannot be completely loaded into memory due to their large size. There are generally two approaches to address this problem:

• All data is held in the memory. The internal structure of the data model implementation tries to avoid many object instantiations and prefers aggre- gations instead of inheritance. Simple data is directly stored instead of using support classes. For instance, a coordinate sequence can directly store the coordinate values instead of holding a list of coordinate wrapping objects.

• Data is made persistent (i.e. will be stored in files or a database) on a certain level in order to release memory.

The first approach is used in the SFS. It specifies a Well known structure (WKS) which defines how to encapsulate elementary and geometric data within geomet- ric objects. Implementation experiments [Chu01] showed that this is an effective technique to enhance the capacity of a geometry, i.e. to use the computer memory more efficiently. Another memory consuming point is the storing of geometric objects’ attributes. It is a design decision whether they are calculated at instan- tiation of the object and stored, or only calculated on demand. This decision depends on the importance and the frequency of use of the attribute. Objects in this implementation only store itsenvelopeas a fixed attribute, other characteristics like length, parameterization or centroid are calculated on demand.

Most of today’s GIS geometries follow the second approach. The computer’s memory is relieved by storing the data of geometric data in files or databases. [KBS91] reports of modern access methods on spatial databases. This implemen- tation distinguishes between two types of data which can either be held in memory or try to realize persistence:

• spatial properties and attributes of geometric objects • temporary data generated by spatial analysis operations

A persistence is not implemented in this work. For future development, the implementation provides two possibilities in order to realize persistence to relieve memory:

• Within the factories: All instantiations of geometric objects are performed through the factories. The method implementations of those could con- sider persistence by storing the object’s properties and attributes in a file or database.

• Use of collection factories: At some parts of the implementation lists or collections are fetched from acollection factory which satisfies the interface CollectionFactory. The point array, for instance, receives a list to hold its positions from such a collection factory. The methods in these factories, which actually instantiate the lists in memory, could be implemented in a persistent manner. The native Java listinterface supports to fetch list ele- ments separately.

5 Geometry Data model

This chapter discusses the data model defined by the Feature Geometry Abstract Specification and the aspects relevant for its implementation. The FGAS describes geometric objects in up to three Euclidean dimensions. The objective of this work is to provide a FGAS implementation for operations on two dimensional objects. Thus, the data typesSolid, SolidBoundary and the associated Shell are not aimed at being implemented in this work as they exclusively serve to represent 3d data. However, all implemented geometric objects are capable of storing data in three dimensions. The architecture of the implementation allows for easily extension of the model by three dimensional operators as the project’s long-term objective is to support full functionality in three dimensions.

The FGAS separates the geometric objects into four packages: primitives,aggre- gates,complexesand auxiliarycoordinates. The first three types are direct subclasses of the Geometry root object(see figure 5.1) and are composed of data types of the coordinate package. The appendix D gives a complete overview of the imple- mented classes and methods.

5.1 Geometry Root Object

A Geometry (Geometry in GeoAPI, GM_Object in FGAS) represents a geometric entity and is the root class of the geometric primitives. It is a direct subclass of a TransfiniteSet. It contains the three type categories primitives, aggregates and complexes. Figure 5.1 demonstrates the hierarchy of the data model and its rela- tionships.

The operation defined for this abstract root object must be implemented for all instantiable subclasses. That arePoint, Curve,Surface,CurveBoundary, Surface- Boundary and Ringin the Primitivepackage, CompositePoint, CompositeCurve and CompositeSurfacein theComplexpackage, andMultiPoint,MultiCurve,MultiSurface

andMultiPrimitivein theAggregatepackage.

A Geometry holds certain characteristics which are accessed by according meth- ods. These are listed as follows.

Boundary. A geometric object is limited by its boundary. Boundary objects are subclasses of theComplexclass. Complexes contain their boundary. However, the boundary of aBoundaryobject is always empty, because the object is either closed (like rings or shells) or it is a point or composed of points. The boundaries for the different data types are discussed below.

Simplicity. A geometric object can besimpleor non-simple. Simple means, that there is no interior point intersection or self-tangency. The only intersection allowed is the intersection of boundary points, for instance in the end points of line segments which form a curve. Examples of simple and non-simple curves and surfaces are given in figure 3.4 and figure 3.6.

IsCycle. This method returnstruein case the boundary of the object is empty. Other specifications use the termisClosedas well. However, the term isClosedis ambiguous since it could also be mixed up with the meaning of closed sets. The termisCycleis rarer. Instances of the classesBoundary,Ring,Point,CompositePoint andMultiPoint are always cyclic, because their boundary is empty. In all other cases the value of the boundary will be verified to return the result:

isCycle() = boundary().isEmpty()

Closure. The FGAS separates its objects in primitives, aggregates and com- plexes. Primitives and aggregates do not contain their boundary, but complexes do. The closure of a geometric objecto1 is the union of the interior and the bound-

ary of this object:o1.closure=o1.interior∪o1.boundary. The specification defines

the method for all GM_Objects:Complex getClosure()

The closure method converts primitives into topologically equal complexes which include their boundary:

• Point: Topologically equivalent to CompositePoint. • Curve: Topologically equivalent to CompositeCurve. • Surface: Topologically equivalent to CompositeSurface.

• Any Complex (CompositePoint, CompositeCurve, CompositeSurface): Since all Complexes already contain their boundary, a closure operation on complexes will return the same object instance.

• Ring,CurveBoundary,SurfaceBoundary: returns the same object instance, since these objects are subclasses of Complex.

• Aggregate: The FGAS does not specify a correspondend data type to repre- sent separated point sets which contain their boundaries. This is a lack in the FGAS. A possible solution thereto is presented in chapter 8.

MBRegion. The minimum bounding region (MB region) is the primitiverepresen- tation of an envelope. The implemented method always returns aSurface which forms a rectangle with the vertices of the according envelope. The implementation only handles 2D data.

Representative Point. Therepresentative pointof an object should be a position which lies on the object as well as being representative for it. The FGAS suggests the centroid to be the representative point, if it lies on the object. However, the calculation of the object’s centroid and the following test whether the centroid lies on the object or not may be performance intensive. As a result of that, the implemented method only uses this procedure for surfaces. The centroid is, in case of:

• Point,CompositePoint: the point itself. • MultiPoint: the first point of the set.

• Curve,CompositeCurve,Ring: the point located in the middle of the curve, i.e. the point along the curve with the parameterization 0.5.

• Ring: the start point of the ring (because the start point is part of the object as a ring’s boundary is empty).

• MultiCurve: the representative point of the first curve of the set.

• Surface: in general, the centroid of the surface can be used as the representa- tive point, if it lays on the object. If the centroid does not lay on the object, another point which lies on the surface has to be found. One possibility to find such a point is a heuristic to test points close to the boundary of the sur- face or points between the boundary and the centroid. Unfortunately, such

approaches do not guarantee a certain running time. The implementation in this work does not provide such an approach, but returns the start point of the exterior ring of the surface boundary (which is not part of the object since surfaces do not contain their).

• MultiSurface, CompositeSurface: the representative point of the first surface within the collection which defines the MultiSurface/CompositeSurface. For a CompositeSurface, another possibility is to return a boundary point, because the boundary is part of the complex.

• CurveBoundary: the start point.

• SurfaceBoundary: the start point of the exterior ring.

In addition to these spatial and geometric characteristics, the FGAS defines oper- ators to determine the spatial relationship (such as equals, contains, intersects) and set theoretic operations (such as intersection, union, difference, symmetric differ- ence) between two geometric objects. Those analysis functions are thoroughly dis- cussed in chapter 6.

In document DiplThesisJena07 (Page 50-56)