<div dir="ltr">well thanks how can I run ogrinfo to get the structures of my geometries in a layer?<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Sep 12, 2013 at 11:01 PM, Even Rouault [via OSGeo.org] <span dir="ltr"><<a href="/user/SendEmail.jtp?type=node&node=5077594&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>></span> wrote:<br>
<blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="color:#777;font-size:12px;font-family:'Lucida Grande',Helvetica,Arial,sans-serif;padding:4px">
<a href="https://www.boxbe.com/overview" style="text-decoration:none;color:#5e96ea" target="_blank" rel="nofollow" link="external"><img alt="Boxbe" style="margin-left:0px;border:none" width="64px"></a>

<img>

  Even Rouault [via OSGeo.org] (<a href="/user/SendEmail.jtp?type=node&node=5077594&i=1" target="_top" rel="nofollow" link="external">[hidden email]</a>) is not on <a style="text-decoration:none;color:#5e96ea" href="https://www.boxbe.com/approved-list?tc_serial=15115454639&tc_rand=1523998204&utm_source=stf&utm_medium=email&utm_campaign=ANNO_MWTP&utm_content=001&token=3CWKDR1oB%2Fa1CY683nuayO4t02ptjHf6V8zz9sSw1BseghDtsirTIxCwhnGFOUGG&key=ePbkSKTVyU7IFMOXoR7%2BEadHh%2FSlMgX5aRPFT9Mq6Jw%3D" target="_blank" rel="nofollow" link="external">your Guest List</a>


    | <a style="text-decoration:none;color:#5e96ea" href="https://www.boxbe.com/anno?tc_serial=15115454639&tc_rand=1523998204&utm_source=stf&utm_medium=email&utm_campaign=ANNO_MWTP&utm_content=001&token=3CWKDR1oB%2Fa1CY683nuayO4t02ptjHf6V8zz9sSw1BseghDtsirTIxCwhnGFOUGG&key=ePbkSKTVyU7IFMOXoR7%2BEadHh%2FSlMgX5aRPFT9Mq6Jw%3D" target="_blank" rel="nofollow" link="external">Approve sender</a>
    | <a style="text-decoration:none;color:#5e96ea" href="https://www.boxbe.com/anno?tc_serial=15115454639&tc_rand=1523998204&utm_source=stf&utm_medium=email&utm_campaign=ANNO_MWTP&utm_content=001&dom&token=3CWKDR1oB%2Fa1CY683nuayO4t02ptjHf6V8zz9sSw1BseghDtsirTIxCwhnGFOUGG&key=ePbkSKTVyU7IFMOXoR7%2BEadHh%2FSlMgX5aRPFT9Mq6Jw%3D" target="_blank" rel="nofollow" link="external">Approve domain</a>
<br>

</div>
<br>

        Le jeudi 12 septembre 2013 19:56:11, sepideh a écrit :
<div><div class='shrinkable-quote'><br>> MyTest.rar <<a href="http://osgeo-org.1560.x6.nabble.com/file/n5077579/MyTest.rar" rel="nofollow" link="external" target="_blank">http://osgeo-org.1560.x6.nabble.com/file/n5077579/MyTest.rar</a>> 
<br>> I have uploaded my MyTest.shp created in ArcGIS. If you open it, you will
<br>> see that it has nine polygons and in the attribute table of the layer, I
<br>> have explained about the features of each polygon.  My problem is:  I'm
<br>> developing a Visual C++ MFC application with GDAL/OGR library that will
<br>> show shapefiles in an OpenGL window. And I have created this shapefile to
<br>> test some parts of my application. *My application will only support ESRI
<br>> shapefiles.*   As you know, the OGRPolygon class has only a member
<br>> function *getNumInteriorRings* and not such function for exterior rings. I
<br>> mean it supports multiple interior rings but not multiple exterior rings.
<br>> So I decided to fetch one of the rings of each polygon with
<br>> *getExteriorRing()* and the others with *getInteriorRing(int)* and decide
<br>> with *isClockwise()* method whether it is an exterior or interior ring.
<br>> This approch is best for the polygons with *FIDs : 0,1,2,3,4,5,6 * in my
<br>> MyTest.shp. When I use this code for them:  /int NumberOfInnerRings =
<br>> poPolygon
<br>> ->getNumInteriorRings();/  I get these results:  FID = 0 -> 5FID = 1 ->
<br>> 1FID = 2 -> 0FID = 3 -> 1FID = 4 -> 2FID = 5 -> 0FID = 6 -> 2  showing
<br>> that one of the rings has been accepted as exterior and the others as
<br>> interior polygons. You see that the polygons with the above FIDs are
<br>> simple polygons, multipart polygons and polygons with holls inside.  But
<br>> for the two other polygons this is not the case. These are polygons that
<br>> have islands in as you see in this link:
<br>> <a href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Creating_new_" rel="nofollow" link="external" target="_blank">http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Creating_new_</a></div>
> donut_holes_and_island_polygons/001t0000003p000000/
<br>> <<a href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Creating_ne" rel="nofollow" link="external" target="_blank">http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Creating_ne</a><br>
> w_donut_holes_and_island_polygons/001t0000003p000000/> I get these wrong
<br>> results for them as the number of Interior rings:  FID = 7 -> 1FID = 8 ->
<br>> 2  meaning that islands are not known niether as interior nor exterior
<br>> polygons!!!  Can you tell me how can I support islands with GDAL/OGR
<br>> library or introduce me another open source that does this?
</div><br>The shapefile displays correctly in QGIS which uses OGR to read Shapefile which 
<br>makes me think that the problem is not in OGR.
<br>Your above description is a bit confusing but my understanding is that your 
<br>problem comes from the fact that the shapefile has a mix of 2 distinct geometry 
<br>type :
<br>- POLYGON: they have always one exterior ring, and 0 or more interior ring
<br>- MULTIPOLYGON: that are maded of 0 or more polygons. On multipolygons, 
<br>getNumInteriorRings() cannot be used. You must iterate first over each polygon 
<br>part of the multipolygon
<br><br>You don't need to check the clockwise orientation to determine if a ring is 
<br>exterior or interior. This is already done by the OGR Shapefile driver.
<br><br>ogrinfo with summary mode will give you the structure of the geometries :
<br><br>$ ogrinfo MyTest -al -geom=summary
<br>INFO: Open of `MyTest'
<br>      using driver `ESRI Shapefile' successful.
<br><br>Layer name: MyTest
<br>Geometry: Polygon
<br>Feature Count: 9
<br>Extent: (-14519050.256578, -31065929.994238) - (26123782.221403, 
<br>8007498.521952)
<br>Layer SRS WKT:
<br>PROJCS["WGS_1984_UTM_Zone_39N",
<br>    GEOGCS["GCS_WGS_1984",
<br>        DATUM["WGS_1984",
<br>            SPHEROID["WGS_84",6378137.0,298.257223563]],
<br>        PRIMEM["Greenwich",0.0],
<br>        UNIT["Degree",0.0174532925199433]],
<br>    PROJECTION["Transverse_Mercator"],
<br>    PARAMETER["False_Easting",500000.0],
<br>    PARAMETER["False_Northing",0.0],
<br>    PARAMETER["Central_Meridian",51.0],
<br>    PARAMETER["Scale_Factor",0.9996],
<br>    PARAMETER["Latitude_Of_Origin",0.0],
<br>    UNIT["Meter",1.0]]
<br>Id: Integer (6.0)
<br>type_poly: String (50.0)
<br>OGRFeature(MyTest):0
<br>  Id (Integer) = 0
<br>  type_poly (String) = polygonWithFiveHolesInside
<br>  POLYGON : 22 points, 5 inner rings (11 points, 11 points, 17 points, 9 
<br>points, 6 points)
<br><br>OGRFeature(MyTest):1
<br>  Id (Integer) = 0
<br>  type_poly (String) = polygonWithTwoSeperateParts
<br>  MULTIPOLYGON : 2 geometries:
<br>POLYGON : 11 points
<br>POLYGON : 11 points
<br><br>OGRFeature(MyTest):2
<br>  Id (Integer) = 0
<br>  type_poly (String) = singlePolygon
<br>  POLYGON : 10 points
<br><br>OGRFeature(MyTest):3
<br>  Id (Integer) = 0
<br>  type_poly (String) = polygonWithOneHoleInside
<br>  POLYGON : 11 points, 1 inner rings (17 points)
<br><br>OGRFeature(MyTest):4
<br>  Id (Integer) = 0
<br>  type_poly (String) = polygonWithTwoHolesInside
<br>  POLYGON : 9 points, 2 inner rings (8 points, 6 points)
<br><br>OGRFeature(MyTest):5
<br>  Id (Integer) = 0
<br>  type_poly (String) = singlePolygon
<br>  POLYGON : 6 points
<br><br>OGRFeature(MyTest):6
<br>  Id (Integer) = 0
<br>  type_poly (String) = polygonWithThreeSeperateParts
<br>  MULTIPOLYGON : 3 geometries:
<br>POLYGON : 7 points
<br>POLYGON : 9 points
<br>POLYGON : 11 points
<br><br>OGRFeature(MyTest):7
<br>  Id (Integer) = 0
<br>  type_poly (String) = PolygonWithAnIslandInside
<br>  MULTIPOLYGON : 2 geometries:
<br>POLYGON : 9 points, 1 inner rings (9 points)
<br>POLYGON : 6 points
<br><br>OGRFeature(MyTest):8
<br>  Id (Integer) = 0
<br>  type_poly (String) = PolygonWithTwoIslandsInsideOneOfTheIslandsHasAHole
<br>  MULTIPOLYGON : 3 geometries:
<br>POLYGON : 7 points, 1 inner rings (6 points)
<br>POLYGON : 6 points, 1 inner rings (4 points)
<br>POLYGON : 6 points
<br><br>On the later,
<br>- the "main" polygon is "POLYGON : 7 points, 1 inner rings (6 points)"
<br>- the island with a hole is the "POLYGON : 6 points, 1 inner rings (4 points)" 
<br>- the other island is "POLYGON : 6 points"
<br><br><br>-- 
<br>Geospatial professional services
<br><a href="http://even.rouault.free.fr/services.html" rel="nofollow" link="external" target="_blank">http://even.rouault.free.fr/services.html</a><br>_______________________________________________
<br>gdal-dev mailing list
<br><a href="http://user/SendEmail.jtp?type=node&node=5077587&i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<br><a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="nofollow" link="external" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a>

        
        
        
        <br>
        <br>
        <hr color="#cccccc" noshade size="1">
        <div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif">
                <div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
                <a href="http://osgeo-org.1560.x6.nabble.com/How-can-I-support-polygons-with-islands-in-my-APPLICATION-USING-gdal-ogr-library-tp5077579p5077587.html" target="_blank" rel="nofollow" link="external">http://osgeo-org.1560.x6.nabble.com/How-can-I-support-polygons-with-islands-in-my-APPLICATION-USING-gdal-ogr-library-tp5077579p5077587.html</a>
        </div>
        <div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
                
                To unsubscribe from How can I support polygons with islands in my APPLICATION USING gdal/ogr library?, <a href="" target="_blank" rel="nofollow" link="external">click here</a>.<br>

                <a href="http://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" style="font:9px serif" target="_blank" link="external">NAML</a>
        </div>
<br></blockquote></div><br></div>


        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://osgeo-org.1560.x6.nabble.com/Re-How-can-I-support-polygons-with-islands-in-my-APPLICATION-USINGgdal-ogr-library-tp5077594.html">Re: How can I support polygons with islands in my APPLICATION USINGgdal/ogr library?</a><br/>
Sent from the <a href="http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html">GDAL - Dev mailing list archive</a> at Nabble.com.<br/>