コード例 #1
0
ファイル: polygon2line.cpp プロジェクト: 52North/IlwisCore
void Polygon2Line::extractBoundary(const UPGeometry& g, quint32& record){
        const geos::geom::Geometry *geom1 = g.get();
        std::vector<geos::geom::CoordinateSequence *> coords = GeometryHelper::geometry2coords(geom1);
        geos::geom::Geometry *geometry;
        if ( coords.size() == 1)
            geometry = _outputfeatures->geomfactory()->createLineString(coords[0]);

        else if ( coords.size() > 1){
            std::vector<geos::geom::Geometry *> lines;
            for(int i=0; i < coords.size(); ++i)
                lines.push_back(_outputfeatures->geomfactory()->createLineString(coords[i]));
            geometry = _outputfeatures->geomfactory()->createMultiLineString(lines);
        }

        if ( geometry){
            SPFeatureI outfeature = _outputfeatures->newFeature(geometry);
            if (_singleId){
                outfeature->setCell(0,0);
            }else {
                outfeature->setCell(0, record);
            }
        }
}