NetTopologySuite / NetTopologySuite.IO.ShapeFile

The ShapeFile IO module for NTS.
33 stars 25 forks source link

Read a shapefile in Xamarin.Forms #49

Closed benabdelkrim closed 3 years ago

benabdelkrim commented 3 years ago

i want to read a shapefile but file not existing ? ShapeDataReader reader = new ShapeDataReader("mapsuiSample.MURS.shp"); var mbr = reader.ShapefileBounds; var result = reader.ReadByMBRFilter(mbr); var coll = result.GetEnumerator(); while (coll.MoveNext()) var item = coll.Current;

DGuidi commented 3 years ago

I personally don't know Xamarin.Forms in detail, but I assume that you can be sure if there's a bug related to NTS simply adding this BEFORE the code you posted

Debug.WriteLine(Environment.CurrentDirectory)
Debug.Assert(File.Exists("mapsuiSample.MURS.shp"))

ShapeDataReader reader = new ShapeDataReader("mapsuiSample.MURS.shp");

Environment.CurrentDirectory shows the actual folder path used as a start when you specify a relative path, like the filename "mapsuiSample.MURS.shp" or something like "..\myfolder\myfile"

DGuidi commented 3 years ago

I personally don't know Xamarin.Forms in detail, but I assume that you can be sure if there's a bug related to NTS simply adding this BEFORE the code you posted

Debug.WriteLine(Environment.CurrentDirectory)
Debug.Assert(File.Exists("mapsuiSample.MURS.shp"))

ShapeDataReader reader = new ShapeDataReader("mapsuiSample.MURS.shp");

Environment.CurrentDirectory shows the actual folder path used as a start when you specify a relative path, like a filename, so you shall be sure that the file you try to read actually exists where Xamarin expects to be

benabdelkrim commented 3 years ago

Debug.WriteLine(Environment.CurrentDirectory) Debug.Assert(File.Exists("mapsuiSample.MURS.shp")) this was helpful for me thank you for your response