Hi,<br><br>What is the detailed error message you get? <br>Could you provide some test data to reproduce this problem?<br>Have you tried with ogr2ogr to convert this data source from shapefile to postgis?<br><br>Best regards,<br>
<br>Tamas<br><br><br><br><div class="gmail_quote">2010/12/27 Edi.Karadumi <span dir="ltr">&lt;<a href="mailto:edikaradumi@gmail.com">edikaradumi@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
Hi everyone,<br>
im a new user to ogr and i have used c# binding and then converted them to<br>
use to my application in <a href="http://vb.net" target="_blank">vb.net</a>.<br>
Im making an application to import shape files to postgres. I have made the<br>
connection, imported the data, but i need to know the progress so i have<br>
used a loop to transfer the data. Also i have imported them to an existing<br>
layer in postgres, but its type is multipolygon and sometimes i have poligon<br>
so it throws an exception. I have read that exists some function<br>
forcetopolygon and forcetomultipolygon but i cant find them i c# bindings.<br>
can anyone help me? here is the code:<br>
<br>
Ogr.RegisterAll()<br>
<br>
                inputDs = Ogr.Open(filePath, 0)<br>
<br>
                If inputDs IsNot Nothing Then<br>
                    If inputDs.GetLayerCount &gt; 0 Then<br>
                        oInputLayer = inputDs.GetLayerByIndex(0)<br>
<br>
                        drv = Ogr.GetDriverByName(&quot;PostgreSQL&quot;)<br>
                        outputDs = drv.Open(ServerConnection, 1)<br>
                        &#39;***********<br>
                        &#39;the postgre table has multiple geometry columns<br>
                        &#39;*************<br>
                        oOutputLayer =<br>
outputDs.GetLayerByName(CadastralZoneImportTable + &quot;(polygon)&quot;)<br>
<br>
                        Dim i As Long<br>
<br>
                        oInputLayer.ResetReading()<br>
                        If oInputLayer.GetFeatureCount(1) &gt; 0 Then<br>
<br>
                            Dim MaxFeaturesCount =<br>
oInputLayer.GetFeatureCount(1)<br>
                            Dim j As Long = 0<br>
<br>
                            oOutputLayer.StartTransaction()<br>
                            For i = 0 To MaxFeaturesCount - 1<br>
                                oOutputFeature = New<br>
OSGeo.OGR.Feature(oOutputLayer.GetLayerDefn)<br>
                                oInputFeature = oInputLayer.GetNextFeature<br>
<br>
                                If oInputFeature.GetFieldIndex(&quot;cze_number&quot;)<br>
&gt;= 0 Then<br>
                                    oOutputFeature.SetField(&quot;cze_number&quot;,<br>
oInputFeature.GetFieldAsInteger(&quot;cze_number&quot;))<br>
                                End If<br>
<br>
                                If oInputFeature.GetFieldIndex(&quot;cze_name&quot;)<br>
&gt;= 0 Then<br>
                                    oOutputFeature.SetField(&quot;cze_name&quot;,<br>
oInputFeature.GetFieldAsString(&quot;cze_name&quot;))<br>
                                End If<br>
<br>
                                If oInputFeature.GetFieldIndex(&quot;bau_total&quot;)<br>
&gt;= 0 Then<br>
                                    oOutputFeature.SetField(&quot;bau_total&quot;,<br>
oInputFeature.GetFieldAsString(&quot;bau_total&quot;))<br>
                                End If<br>
<br>
                                If oInputFeature.GetGeometryRef IsNot<br>
Nothing Then<br>
<br>
oOutputFeature.SetGeometryDirectly(oInputFeature.GetGeometryRef)<br>
                                End If<br>
                                &#39;here throws the exception about the<br>
multipolygon<br>
                                oOutputLayer.CreateFeature(oOutputFeature)<br>
<br>
                                oOutputFeature.Dispose()<br>
                                oInputFeature.Dispose()<br>
<br>
                            Next<br>
<br>
                            If i = MaxFeaturesCount Then<br>
                                oOutputLayer.CommitTransaction()<br>
                            Else<br>
                                oOutputLayer.RollbackTransaction()<br>
                            End If<br>
<br>
                        End If<br>
<br>
                    End If<br>
                Else<br>
<br>
                    MsgBox(&quot;error importing file: &quot; + filePath,<br>
MsgBoxStyle.SystemModal + MsgBoxStyle.Information)<br>
<br>
                End If<br>
<font color="#888888">--<br>
View this message in context: <a href="http://osgeo-org.1803224.n2.nabble.com/C-Binding-ForceToMultiPolygon-tp5869504p5869504.html" target="_blank">http://osgeo-org.1803224.n2.nabble.com/C-Binding-ForceToMultiPolygon-tp5869504p5869504.html</a><br>

Sent from the GDAL - Dev mailing list archive at Nabble.com.<br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</font></blockquote></div><br><div style="visibility: hidden; left: -5000px; position: absolute; z-index: 9999; padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;" id="avg_ls_inline_popup">
</div>