Hi
I try to build a spatial index for a shapefile
My shapefile contains 128000 objects (pieces of roads) and it is in french projection (EPSG:2154)
I have put the file in an asset folder and I copy it in the tablet by code (as in the samples).
string targetDirectory = (@"/mnt/sdcard/Android.Sample/Osm");
CopySampleData(targetDirectory, "Osm");
string pl = System.IO.Path.Combine(targetDirectory, "PC_roads.shp");
string il = System.IO.Path.Combine(targetDirectory, "PC_roads.ids");
ShapeFileFeatureLayer.BuildIndexFile(pl,il,BuildIndexMode.DoNotRebuild);
I have an error on the BuildIndexFile
System.IO.IOException Win32 IO returned 25. Path: /mnt/sdcard/Android.Sample/Osm\TMPPC_roads.ids.
To prepare my shapefile, is it possible to make the index on my Computer ? and copy
Best Regards
Laurent M
Spatial Index with Shpfile
Hi Laurent,
I think your code have a little problem: “PC_roads.ids” should be “PC_roads.idx”.
And you can build index in computer and then copy it to android by your 1st and 2nd line code.
You can download any version of our product, then build the index file like this:
ShapeFileFeatureSource.BuildIndexFile("");
Wish that’s helpful.
Regards,
Don
Hi Don
I have tried with
string pl = System.IO.Path.Combine(targetDirectory, "PC_roads.shp");
string il = System.IO.Path.Combine(targetDirectory, "PC_roads.idx");
ShapeFileFeatureLayer.BuildIndexFile(pl,il,BuildIndexMode.DoNotRebuild);
Or directly
ShapeFileFeatureLayer.BuildIndexFile(pl,BuildIndexMode.DoNotRebuild);
Allways the same error about the path
System.IO.IOException Win32 IO returned 25. Path: /mnt/sdcard/Android.Sample/Osm\TMPPC_roads.ids.
Regards
Laurent
Hi Laurent,
I meant you should want to build index in computer then copy generated index files to android.
Regards,
Don
Hi don
I have made the index on my computer with MapSuite Gis editor (Trial). But if I need to create directly a ShapeFile with application, I have also need to create the index.
Thanks
Laurent
Hi Laurent,
Do you meant you have to build the index in Android application?
But in your first topic you said: To prepare my shapefile, is it possible to make the index on my Computer ? and copy
So I think you can build that then copy it.
Regards,
Don
Hi don
Both possibility
Build the index in Adroid application.
And to prepare shapefile.
And a have the message on .BuildIndexFile()
Regards
Laurent
Hi Laurent,
Our android development have reproduced that, it have been fixed.
But our daily build is suspend now because new release, please get the latest package after daily build back.
Regards,
Don
Hi
Version Full Developpement 9.0.16.0
I have the same error on a CreateShapeFile
About the directoty TMP
System.IO.IOException Win32 IO returned 25. Path: /mnt/sdcard/Android.Sample/Osm\TMPPC_roads.shp.
But if my application creates the directory TMP before the CreateShapeFile, none error.
I create the directoty TMP and I test with ShapeFileFeatureLayer.BuildIndexFile
No error about the TMP directory but another.
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
Best Regards
Laurent
Another information on the error
The application create a ShapeFile and I use BuildIndexFile, no problem.
The application copy the ShapeFile from Assets (with the index file) and I try a BuildIndexFile, the application crash.
Regards
Laurent
Hi Laurent,
Our developer is working for this, any update will let you know.
BTW, I have some confused about your 2nd reply "The application copy the ShapeFile from Assets (with the index file) and I try a BuildIndexFile, the application crash.", do you meant you copied the data with index file to Android mobile, then call API to build index and get crash? If so, have you set the BuildIndexMode.DoNotRebuild or BuildIndexMode.Rebuild?
Regards,
Don
Hi Laurent,
Thanks for your detail information, our developer had worked for it and fixed the issues.
1. The directoty TMP issue
We can call CreateShapeFile method directly now, don’t need to create TMP directory before that. So you won’t get the same error.
2. System.InvalidOperationException issue
We have fixed it. Tested by call ShapeFileFeatureLayer.BuildIndexFile and it works well now.
3. Application crashe issue
It should be caused by ShapeFileFeatureLayer.BuildIndexFile, so we have fixed it in issue2.
Please get the latest AndroidEdition(9.0.21.0) or any higher version to get this fix.
If any issue persists, please feel free to let me know.
Regards,
Don
Hi Don
I have checked, it is OK
Thanks
Regards
Laurent
Hi Laurent,
I am glad to hear that works for you.
Regards,
Don