I have probably trivial problem. I'm trying to use GEOS library. I have my functions using GEOS library in my own library. And I want to use this library in my QGIS plugin writen in C++. The problem is, that functions in my library work with geos::geom::Geometry, but in QGIS plugin, there is GEOSGeometry. I thought that it is the same thing, but it probably isn't.

Can anyone explain me the difference between these two and give me an advice, how to convert them to each other or tell me what I'm doing wrong? Thanks.

有帮助吗?

解决方案

GEOSGeometry is a typedef for the structure used in the C (not C++) API. It is stated on the official documentation that the use of the C API is preferred to the C++ API as it may be more stable (in terms of future changes).

I'm not sure if you can simply cast the structures (I'd advise against it). I suggest you use the C API instead of the C++ API.

其他提示

No, you can not simply cast between GEOS C API type GEOSGeometry and C++ API types from hierarchy rooted at geos::geom::Geometry class.

You can, however, convert your geometries using WKB as an interchange format, between the C API and the C++ API objects.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top