geos创建点 线 面

1.点 

 geos::geom::Coordinate vertex(vertex_infos.at(i).x, vertex_infos.at(i).y, vertex_infos.at(i).z);
                        std::unique_ptr<geos::geom::Point> vertex_geom(geos::geom::GeometryFactory::getDefaultInstance()->createPoint(vertex));

多个点

std::vector<geos::geom::Coordinate> multi_point_coords;
std::unique_ptr<geos::geom::MultiPoint> trajectory_multi_point(geos::geom::GeometryFactory::getDefaultInstance()->createMultiPoint(std::move(multi_point_coords)));

2.线 和 线段

 std::unique_ptr<geos::geom::CoordinateArraySequence> linestring_coordArray = std::make_unique<geos::geom::CoordinateArraySequence>();
                                linestring_coordArray->add(c1);
                                linestring_coordArray->add(c2);
                                std::unique_ptr<geos::geom::LineString> line_string = geos::geom::GeometryFactory::getDefaultInstance()->createLineString(std::move(linestring_coordArray));
geos::geom::LineSegment line_seg(c1, c2); // geos::geom::Coordinate
std::vector<geos::geom::Coordinate> coordinates;
auto coordinates_copy = coordinates;
                auto coordinate_seq = geos::geom::CoordinateArraySequenceFactory::instance()->create(std::move(coordinates_copy));
                auto line_string = geos::geom::GeometryFactory::getDefaultInstance()->createLineString(std::move(coordinate_seq));
                auto buffer_geom = line_string->buffer(15);

                auto searchEnv = buffer_geom->getEnvelopeInternal();
                std::vector<void *> matched_vertex_infos;
                quad_tree.query(searchEnv, matched_vertex_infos);


geos::geom::LineSegment line_seg(coordinates[i], coordinates[i + 1]);

3.根据四个点创建面

geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create();
            std::unique_ptr<geos::geom::CoordinateArraySequence> coordinates = std::make_unique<geos::geom::CoordinateArraySequence>();
            geos::geom::Coordinate begPoint(FirstlineGeometry.at(i - 1).x_, FirstlineGeometry.at(i - 1).y_, FirstlineGeometry.at(i - 1).z_);
            geos::geom::Coordinate endPoint(FirstlineGeometry.at(i).x_, FirstlineGeometry.at(i).y_, FirstlineGeometry.at(i).z_);
            coordinates->add(begPoint);
            coordinates->add(endPoint);
            coordinates->add(endProjInfo._projectPoint);
            coordinates->add(begProjInfo._projectPoint);
            coordinates->add(begPoint);
            std::unique_ptr<geos::geom::LinearRing> ring = factory->createLinearRing(std::move(coordinates));
            std::unique_ptr<geos::geom::Polygon> cross_section_polygon = factory->createPolygon(std::move(ring));

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值