<div dir="ltr">Dheeraj,<div><br></div><div>The issue is now fixed in trunk and branch-1-10 (check out the latest sources)</div><div>I've also added a sample application for these methods:</div><div><a href="http://trac.osgeo.org/gdal/browser/trunk/gdal/swig/csharp/apps/OGRLayerAlg.cs">http://trac.osgeo.org/gdal/browser/trunk/gdal/swig/csharp/apps/OGRLayerAlg.cs</a></div>
<div><br></div><div>Best regards,</div><div><br></div><div>Tamas</div><div><br><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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Tamas,<div><br></div><div>I appreciate you adding a ticket for this issue. Thanks. Is there any other option for me to use OGRLayer intersection with out C# bindings for now ? </div>
<div><br></div><div><br></div>
<div>Thanks,</div><div>Dheeraj</div><div><br></div></div><div class="gmail_extra"><div><div class="h5"><br><br><div class="gmail_quote">On Thu, Oct 10, 2013 at 2:21 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><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" target="_blank">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><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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style: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><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><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>
<div>DataSource dataSourceToIntersect = driver.Open(@"C:\Temp\gdal_32\Polyline.shp", 0);</div>
</div><div>Layer layerToIntersect = dataSourceToIntersect.GetLayerByIndex(0);</div></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>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><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><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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style: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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style: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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style: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><font color="#888888">-- <br><div dir="ltr">Dheeraj Reddy Mamidi<div><br></div></div>
</font></span></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div></div></div><span class=""><font color="#888888">-- <br><div dir="ltr">Dheeraj Reddy Mamidi<div><br></div><div><span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">Software Developer</span><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">The Rothwell Group, L.P.</span><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">Email: </span><a href="mailto:atvaughan@rothwellgroup.com" style="color:rgb(17,85,204);font-size:13px;font-family:arial,sans-serif" target="_blank">drmamidi@rothwellgroup.com</a><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">Phone: </span><a value="+17139525355" style="color:rgb(17,85,204);font-size:13px;font-family:arial,sans-serif">713-952-5355 ext.30</a><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">Web: </span><a href="http://www.rothwellgroup.com/" style="color:rgb(17,85,204);font-size:13px;font-family:arial,sans-serif" target="_blank">www.rothwellgroup.com</a>
</div></div>
</font></span></div>
</blockquote></div><br></div></div></div>