<div dir="ltr">Dheeraj,<div><br></div><div>I noticed you are talking about the layer level geometry functions, which hasn't been updated in the C# bindings yet. I'll add the necessary implementation shorly. Also added a ticket to track the changes: <a href="http://trac.osgeo.org/gdal/ticket/5264">http://trac.osgeo.org/gdal/ticket/5264</a></div>
<div><br></div><div>Best regards,</div><div><br></div><div>Tamas</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/10 Dheeraj Reddy Mamidi <span dir="ltr"><<a href="mailto:drmamidi@rothwellgroup.com" target="_blank">drmamidi@rothwellgroup.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Tamas,<div><br></div><div>Sorry the sample code had wrong data source names. Here is the corrected sample code..</div>
<div><br></div><div><br></div><div><div class="im"><div style="font-family:arial,sans-serif;font-size:13px">
<div>var spatialReference = new OSGeo.OSR.SpatialReference("");</div><div>spatialReference.ImportFromProj4("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");</div><div><br></div><div>var driver = OSGeo.OGR.Ogr.GetDriverByName("ESRI Shapefile");<br>
</div></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div></div><div style="font-family:arial,sans-serif;font-size:13px"><div class="im"><div>DataSource dataSourceToIntersectOn = driver.Open(@"C:\Temp\gdal_32\Polygon.shp", 0);</div>
</div><div>Layer layerToIntersectOn = dataSourceToIntersectOn.GetLayerByIndex(0);</div></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><div class="im">
<div>DataSource dataSourceToIntersect = driver.Open(@"C:\Temp\gdal_32\Polyline.shp", 0);</div>
</div><div>Layer layerToIntersect = dataSourceToIntersect.GetLayerByIndex(0);</div></div><div class="im"><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
<div>var intersectedShapeData = driver.CreateDataSource(@"C:\Temp\gdal_32", new string[] { });</div>
<div>wkbGeometryType wkbGeometryType = layerOriginal.GetLayerDefn().GetGeomType();</div><div>Layer intersectedLayer = intersectedShapeData.CreateLayer("intersection", spatialReference, wkbGeometryType, new string[] { });</div>
</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div></div><div style="font-family:arial,sans-serif;font-size:13px"><div class="im"><div>OSGeo.OGR.SWIGTYPE_p_void callback_data = new OSGeo.OGR.SWIGTYPE_p_void(new IntPtr(5), false, layerToIntersect);</div>
<div><br></div><div>OSGeo.OGR.SWIGTYPE_p_GDALProgressFunc callback = new SWIGTYPE_p_GDALProgressFunc(new IntPtr(5), false, layerToIntersect);</div><div><br></div><div>layerToIntersect.Intersection(layerToIntersectOn, intersectedLayer, new string[] { "SKIP_FAILURES=YES" }, callback, callback_data); // Line where it fails</div>
<div><br></div><div><br></div></div><div>Thanks,</div><div>Dheeraj</div></div></div><div class="gmail_extra"><div><div class="h5"><br><br><div class="gmail_quote">On Thu, Oct 10, 2013 at 1:16 PM, Dheeraj Reddy Mamidi <span dir="ltr"><<a href="mailto:drmamidi@rothwellgroup.com" target="_blank">drmamidi@rothwellgroup.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Tamas,<div><br></div><div>Thanks for your response. In fact I don't require progress notification, but I am not able to ignore those arguments (pass them as null). If I pass them as null I get error <span style="font-size:13px;white-space:pre-wrap;font-family:verdana,sans-serif">"Attempt to </span><span style="font-size:13px;white-space:pre-wrap;font-family:verdana,sans-serif">dereference null GDALProgressFunc". </span>If I just pass those arguments initializing them they way I am doing below in the sample code, I get "<span style="font-family:verdana,sans-serif;font-size:12px;line-height:15.703125px;white-space:pre-wrap">Attempted to read or write protected memory. This is often an indication that other memory is corrupt.</span>" error. </div>
<div><br></div><div>I am using Gdal 1.10 library.</div><div><br></div><div>Here is the sample code..</div><div><br></div><div><div><div>var spatialReference = new OSGeo.OSR.SpatialReference("");</div><div>spatialReference.ImportFromProj4("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");</div>
<div><br></div><div>var driver = OSGeo.OGR.Ogr.GetDriverByName("ESRI Shapefile");<br></div></div><div><br></div><div><div>DataSource dataSourceToIntersectOn = driver.Open(@"C:\Temp\gdal_32\Polygon.shp", 0);</div>
<div>Layer layerToIntersectOn = dataSourceCookieCutter.GetLayerByIndex(0);</div></div><div><br></div><div><div>DataSource dataSourceToIntersect = driver.Open(@"C:\Temp\gdal_32\Polyline.shp", 0);</div><div>Layer layerToIntersect = dataSourceOriginal.GetLayerByIndex(0);</div>
</div><div><br></div><div><div>var intersectedShapeData = driver.CreateDataSource(@"C:\Temp\gdal_32", new string[] { });</div><div>wkbGeometryType wkbGeometryType = layerOriginal.GetLayerDefn().GetGeomType();</div>
<div>Layer intersectedLayer = intersectedShapeData.CreateLayer("intersection", spatialReference, wkbGeometryType, new string[] { });</div></div><div><br></div><div><div>OSGeo.OGR.SWIGTYPE_p_void callback_data = new OSGeo.OGR.SWIGTYPE_p_void(new IntPtr(5), false, layerToIntersect);</div>
<div><br></div><div>OSGeo.OGR.SWIGTYPE_p_GDALProgressFunc callback = new SWIGTYPE_p_GDALProgressFunc(new IntPtr(5), false, layerToIntersect);</div><div><br></div><div>layerToIntersect.Intersection(layerToIntersectOn, intersectedLayer, new string[] { "SKIP_FAILURES=YES" }, callback, callback_data); // Line where it fails</div>
</div><div><br></div><div><br></div><div>The data that I am trying to intersect (shapefiles are attached).</div><div><br></div><div><br></div><div>Thanks,</div><div>Dheeraj</div><div><br></div><div><br></div><div><br></div>
</div><div class="gmail_extra"><div><div><br><br><div class="gmail_quote">On Thu, Oct 10, 2013 at 12:33 PM, Tamas Szekeres <span dir="ltr"><<a href="mailto:szekerest@gmail.com" target="_blank">szekerest@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dheeraj,<div><br></div><div>I don't think the <span style="font-size:12.727272033691406px;white-space:pre-wrap;font-family:verdana,sans-serif">OSGeo.OGR.Layer.Intersection supports progress notification. You might probably have encountered a bug which should be fixed. Do you have a sample code to reproduce this issue? I would specifically interested in the actual geometries have been passed to the function.</span></div>
<div><span style="font-size:12.727272033691406px;white-space:pre-wrap;font-family:verdana,sans-serif"><br></span></div><div><span style="font-size:12.727272033691406px;white-space:pre-wrap;font-family:verdana,sans-serif">Best regards,</span></div>
<div><span style="font-size:12.727272033691406px;white-space:pre-wrap;font-family:verdana,sans-serif"><br></span></div><div><span style="font-size:12.727272033691406px;white-space:pre-wrap;font-family:verdana,sans-serif">Tamas</span></div>
<div><span style="font-size:12.727272033691406px;white-space:pre-wrap;font-family:verdana,sans-serif"><br></span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div>2013/10/10 Dheeraj Reddy Mamidi <span dir="ltr"><<a href="mailto:drmamidi@rothwellgroup.com" target="_blank">drmamidi@rothwellgroup.com</a>></span><br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><font face="verdana, sans-serif">Hi list,</font><div><font face="verdana, sans-serif"><br clear="all">
</font><div>
<font face="verdana, sans-serif">I have troubles with C# bindings of OGR. <span style="white-space:pre-wrap">I was trying to perform intersection on two feature classes (shape file formats) </span><span style="white-space:pre-wrap">using OSGeo.OGR.Layer.Intersection(), but have problems making it work. </span><span style="line-height:1.3em;font-size:0.93em;white-space:pre-wrap">I keep getting an error saying </span></font><span style="line-height:1.3em;font-size:0.93em;white-space:pre-wrap;font-family:verdana,sans-serif">"AccessViolationException was unhandled. Attempted to read or write protected memory. This is often an indication that other memory is corrupt.</span></div>
<div><span style="line-height:1.3em;font-size:0.93em;white-space:pre-wrap;font-family:verdana,sans-serif"><br></span></div><div><font face="verdana, sans-serif"><span style="white-space:pre-wrap">Is the above error something to do with </span><span style="white-space:pre-wrap">SWIGTYPE_p_GDALProgressFunc callback </span><span style="white-space:pre-wrap">and OSGeo.OGR.SWIGTYPE_p_void callback_data arguments? </span></font><span style="white-space:pre-wrap;font-family:verdana,sans-serif">I tried passing those parameters null as suggested by some in the forums but</span><span style="white-space:pre-wrap;font-family:verdana,sans-serif"> I keep getting the error "Attempt to </span><span style="white-space:pre-wrap;font-family:verdana,sans-serif">dereference null GDALProgressFunc". I am not sure what that means. </span></div>
<div><span style="white-space:pre-wrap;font-family:verdana,sans-serif"><br></span></div><div><span style="white-space:pre-wrap;font-family:verdana,sans-serif">And when I instantiate callback as new </span><font color="#000000" face="verdana, sans-serif"><span style="white-space:pre-wrap">SWIGTYPE_p_GDALProgressFunc() and new callback_data as new SWIGTYPE_p_void(), I don't get error </span></font><span style="white-space:pre-wrap;font-family:verdana,sans-serif">Attempt to </span><span style="white-space:pre-wrap;font-family:verdana,sans-serif">dereference null GDALProgressFunc, but still have error saying </span><span style="line-height:15.703125px;font-size:12px;white-space:pre-wrap;font-family:verdana,sans-serif">AccessViolationException was unhandled. Attempted to read or write protected memory. This is often an indication that other memory is corrupt.</span></div>
<div><span style="line-height:15.703125px;font-size:12px;white-space:pre-wrap;font-family:verdana,sans-serif"><br></span></div><div><span style="line-height:15.703125px;font-size:12px;white-space:pre-wrap;font-family:verdana,sans-serif">Can someone please help me figure this out and let me know how to make use of </span><span style="white-space:pre-wrap;font-family:verdana,sans-serif">OSGeo.OGR.Layer.Intersection() in the right way with c# bindings. Thank you.</span></div>
<div><span style="white-space:pre-wrap;font-family:verdana,sans-serif"><br></span></div><div><span style="white-space:pre-wrap;font-family:verdana,sans-serif">Thanks,</span></div><div>Dheeraj<br>
</div><div dir="ltr"><div><br></div><div><br></div></div>
</div></div>
<br></div></div><div>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">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></div></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div></div></div>-- <br><div dir="ltr"><br></div>
</div></div>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div dir="ltr">Dheeraj Reddy Mamidi<div><br></div></div>
</font></span></div></div>
</blockquote></div><br></div>