File Coverage

/usr/local/lib/perl5/site_perl/5.26.1/x86_64-linux/CPP/geos.x/i/geos/noding/SegmentStringUtil.h
Criterion Covered Total %
statement 8 8 100.0
branch 6 10 60.0
condition n/a
subroutine n/a
pod n/a
total 14 18 77.7


line stmt bran cond sub pod time code
1             /**********************************************************************
2             *
3             * GEOS - Geometry Engine Open Source
4             * http://geos.osgeo.org
5             *
6             * Copyright (C) 2006 Refractions Research Inc.
7             *
8             * This is free software; you can redistribute and/or modify it under
9             * the terms of the GNU Lesser General Public Licence as published
10             * by the Free Software Foundation.
11             * See the COPYING file for more information.
12             *
13             *
14             **********************************************************************
15             *
16             * Last port: noding/SegmentStringUtil.java rev. 1.2 (JTS-1.9)
17             *
18             **********************************************************************/
19              
20             #ifndef GEOS_NODING_SEGMENTSTRINGUTIL_H
21             #define GEOS_NODING_SEGMENTSTRINGUTIL_H
22              
23             #include
24             #include
25             #include
26             #include
27              
28             namespace geos {
29             namespace noding { // geos::noding
30              
31             /** \brief
32             * Utility methods for processing {@link SegmentString}s.
33             *
34             * @author Martin Davis
35             *
36             */
37             class SegmentStringUtil
38             {
39             public:
40             /** \brief
41             * Extracts all linear components from a given {@link Geometry}
42             * to {@link SegmentString}s.
43             *
44             * The SegmentString data item is set to be the source Geometry.
45             *
46             * @param geom the geometry to extract from
47             * @param segStr a List of SegmentStrings (output parameter).
48             * Ownership of elements pushed to the vector
49             * is transferred to caller.
50             */
51 1           static void extractSegmentStrings(const geom::Geometry * g,
52             SegmentString::ConstVect& segStr)
53             {
54 2           geom::LineString::ConstVect lines;
55 1 50         geom::util::LinearComponentExtracter::getLines(*g, lines);
56              
57 2 100         for (std::size_t i=0, n=lines.size(); i
58             {
59 1           geom::LineString* line = (geom::LineString*)(lines[i]);
60              
61             // we take ownership of the coordinates here
62             // TODO: check if this can be optimized by getting
63             // the internal CS.
64 1 50         geom::CoordinateSequence* pts = line->getCoordinates();
65              
66 1 50         segStr.push_back(new NodedSegmentString(pts, g));
    50          
67             }
68 1           }
69              
70             };
71              
72             } // geos::noding
73             } // geos
74              
75             #endif // GEOS_NODING_SEGMENTSTRINGUTIL_H