SegmentStringUtil.h

00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2006 Refractions Research Inc.
00007  *
00008  * This is free software; you can redistribute and/or modify it under
00009  * the terms of the GNU Lesser General Public Licence as published
00010  * by the Free Software Foundation. 
00011  * See the COPYING file for more information.
00012  *
00013  *
00014  **********************************************************************
00015  *
00016  * Last port: noding/SegmentStringUtil.java rev. 1.2 (JTS-1.9)
00017  *
00018  **********************************************************************/
00019 
00020 #ifndef GEOS_NODING_SEGMENTSTRINGUTIL_H
00021 #define GEOS_NODING_SEGMENTSTRINGUTIL_H
00022 
00023 #include <geos/noding/NodedSegmentString.h>
00024 #include <geos/geom/LineString.h>
00025 #include <geos/geom/CoordinateSequence.h>
00026 #include <geos/geom/util/LinearComponentExtracter.h>
00027 
00028 namespace geos {
00029 namespace noding { // geos::noding
00030 
00037 class SegmentStringUtil
00038 {
00039 public:
00051         static void extractSegmentStrings(const geom::Geometry * g,
00052                                           SegmentString::ConstVect& segStr)
00053         {
00054                 geom::LineString::ConstVect lines;
00055                 geom::util::LinearComponentExtracter::getLines(*g, lines);
00056 
00057                 for (std::size_t i=0, n=lines.size(); i<n; i++)
00058                 {
00059                         geom::LineString* line = (geom::LineString*)(lines[i]);
00060 
00061                         // we take ownership of the coordinates here
00062                         // TODO: check if this can be optimized by getting
00063                         //       the internal CS.
00064                         geom::CoordinateSequence* pts = line->getCoordinates();
00065 
00066                         segStr.push_back(new NodedSegmentString(pts, g));
00067                 }
00068         }
00069 
00070 };
00071 
00072 } // geos::noding
00073 } // geos
00074 
00075 #endif // GEOS_NODING_SEGMENTSTRINGUTIL_H

Generated on 23 Sep 2013 for GEOS by  doxygen 1.4.7