GEOS: SegmentStringUtil.h Source File

GEOS 3.3.8

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

SegmentStringUtil.h
1 /**********************************************************************
2 * $Id: SegmentStringUtil.h 2961 2010-03-29 12:17:37Z mloskot $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2006 Refractions Research Inc.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 *
15 **********************************************************************
16 *
17 * Last port: noding/SegmentStringUtil.java rev. 1.2 (JTS-1.9)
18 *
19 **********************************************************************/
20
21 #ifndef GEOS_NODING_SEGMENTSTRINGUTIL_H
22 #define GEOS_NODING_SEGMENTSTRINGUTIL_H
23
24 #include <geos/noding/NodedSegmentString.h>
25 #include <geos/geom/LineString.h>
26 #include <geos/geom/CoordinateSequence.h>
27 #include <geos/geom/util/LinearComponentExtracter.h>
28
29 namespace geos {
30 namespace noding { // geos::noding
31
38 class SegmentStringUtil
39 {
40 public:
59 static void extractSegmentStrings(const geom::Geometry * g,
60 SegmentString::ConstVect& segStr)
61 {
62 geom::LineString::ConstVect lines;
63 geom::util::LinearComponentExtracter::getLines(*g, lines);
64
65 for (std::size_t i=0, n=lines.size(); i<n; i++)
66 {
67 geom::LineString* line = (geom::LineString*)(lines[i]);
68
69 // we take ownership of the coordinates here
70 // TODO: check if this can be optimized by getting
71 // the internal CS.
72 geom::CoordinateSequence* pts = line->getCoordinates();
73
74 segStr.push_back(new NodedSegmentString(pts, g));
75 }
76 }
77
78 };
79
80 } // geos::noding
81 } // geos
82
83 #endif // GEOS_NODING_SEGMENTSTRINGUTIL_H
84 /**********************************************************************
85 * $Log$
86 **********************************************************************/
87