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"><<a href="mailto:edikaradumi@gmail.com">edikaradumi@gmail.com</a>></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 > 0 Then<br>
oInputLayer = inputDs.GetLayerByIndex(0)<br>
<br>
drv = Ogr.GetDriverByName("PostgreSQL")<br>
outputDs = drv.Open(ServerConnection, 1)<br>
'***********<br>
'the postgre table has multiple geometry columns<br>
'*************<br>
oOutputLayer =<br>
outputDs.GetLayerByName(CadastralZoneImportTable + "(polygon)")<br>
<br>
Dim i As Long<br>
<br>
oInputLayer.ResetReading()<br>
If oInputLayer.GetFeatureCount(1) > 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("cze_number")<br>
>= 0 Then<br>
oOutputFeature.SetField("cze_number",<br>
oInputFeature.GetFieldAsInteger("cze_number"))<br>
End If<br>
<br>
If oInputFeature.GetFieldIndex("cze_name")<br>
>= 0 Then<br>
oOutputFeature.SetField("cze_name",<br>
oInputFeature.GetFieldAsString("cze_name"))<br>
End If<br>
<br>
If oInputFeature.GetFieldIndex("bau_total")<br>
>= 0 Then<br>
oOutputFeature.SetField("bau_total",<br>
oInputFeature.GetFieldAsString("bau_total"))<br>
End If<br>
<br>
If oInputFeature.GetGeometryRef IsNot<br>
Nothing Then<br>
<br>
oOutputFeature.SetGeometryDirectly(oInputFeature.GetGeometryRef)<br>
End If<br>
'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("error importing file: " + 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>