示例代码:
const char* wkt = "MultiPolygon(((12629713.75288644060492516 3896945.87303787842392921,13393072.26469473727047443 3171335.85906625585630536, 13481152.09298031032085419 3884363.0404256540350616, 12629713.75288644060492516 3896945.87303787842392921)))";
// cast because OGR_G_CreateFromWkt will move the pointer
char* pszWkt = (char*)wkt;
OGRSpatialReferenceH ref = OSRNewSpatialReference(NULL);
OGRGeometryH new_geom;
OSRSetAxisMappingStrategy(ref, OAMS_TRADITIONAL_GIS_ORDER);
OGRErr err = OGR_G_CreateFromWkt(&pszWkt, ref, &new_geom);
char* strWkt = NULL;
((OGRGeometry*)new_geom)->exportToWkt(&strWkt);
结果:
"MultiPolygon(((12629713.75288644060492516 3896945.87303787842392921,13393072.26469473727047443 3171335.85906625585630536, 13481152.09298031032085419 3884363.0404256540350616, 12629713.75288644060492516 3896945.87303787842392921)))"