[Gdal-dev] newbie question : OGR Polygon extracting problem...

Frank Warmerdam warmerdam at pobox.com
Fri Nov 11 10:05:48 EST 2005


On 11/11/05, Aykut KOÇAK <aykutkocak at superonline.com> wrote:
>  Dear all,
>
>  since couple of days I am learning how to use OGR library adn gat some
> problems about Polygons and MultiPolygons. I have searched the list's
> archive and found some replies to similar questions  (
> http://lists.maptools.org/pipermail/gdal-dev/2004-February/002095.html,
> http://lists.maptools.org/pipermail/gdal-dev/2004-May/002713.html)
> which did not solve my problem yet. So, I have added my experiment source
> code in C and I will be very glad if somebody help me about my mistakes with
> in the code.

Aykut,

The program looks reasonably sound.  I made the
following changes and was able get a good dump.  Note
that the first geometry is index "0".

warmerda at gdal2200[45]% diff test1.c test1.c_original
121c121
<         if (iGeometryCount > 0) {
---
>         if (iTotalPoint > 0) {
124c124
<         for ( iGeometry=0;iGeometry<iGeometryCount;iGeometry++) {
---
>         for ( iGeometry=1;iGeometry<iGeometryCount;iGeometry++) {

I would also note that there are container geometry types,
like multipolygon that your approach won't work for.  You
pretty much need a sub-function that can recurse for walking
down the geometry tree.  Otherwise you won't be able to
handle all the geometry types.  But what you have will
report simple point, line and polygon objects properly.

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list