[Gdal-dev] Re: C# Geometry Classes?
Simon Perkins
sy at perkins.net
Thu Mar 22 03:06:20 EDT 2007
Hi Mateusz,
Thanks for the example - that helps a lot. I wasn't sure whether a
Polygon could be treated as a geometry collection like this...
Cheers,
Sy
Mateusz Loskot wrote:
>
> I hope following example will help you:
>
>
> ///////////////////////////////////////////////////////////////
> #include <iostream>
> #include <ogr_api.h>
> #include <cpl_port.h>
>
> int main()
> {
> using std::cout;
> using std::endl;
>
> // Polygon with 2 rings
> char* wkt = "POLYGON ((0 0 0,4 0 0,4 4 0,0 4 0,0 0 0), (1 1 0, 2 1
> 0, 2 2 0, 1 1 0))";
>
> OGRGeometryH g = NULL;
> OGRErr err = OGR_G_CreateFromWkt(&wkt, NULL, &g);
> cout << "Rings count: " << OGR_G_GetGeometryCount(g) << endl;
>
> // Ring 1
> OGRGeometryH ring1 = NULL;
> ring1 = OGR_G_GetGeometryRef(g, 0);
> cout << "Ring 1: " << OGR_G_GetPointCount(ring1) << endl;
>
> // Ring 2
> OGRGeometryH ring2 = NULL;
> ring2 = OGR_G_GetGeometryRef(g, 1);
> cout << "Ring 2: " << OGR_G_GetPointCount(ring2) << endl;
>
> OGR_G_DestroyGeometry(g);
> return 0;
> }
> ///////////////////////////////////////////////////////////////
>
> Cheers
>
More information about the Gdal-dev
mailing list