Hello Everyone
I have an ArcGIS Engine application and I'm attempting to provide a command to my end users which will allow them to create a *.tpk file from their map document (*.mxd). My goal is to have our clients use our Engine product to create a tile package which will be consumed within our new CAD ArcGIS Runtime .Net product.
Not all our clients will have access to ArcMap to create these tpk files so I would like to give them the ability to create these files in lieu of.
Prior to making this post I did scour the api documentation ESRI.ArcGIS.DataManagementTools but couldn't come up with anything.
I appreciate any help on how to move forward.
Thanks
Jim
Solved! Go to Solution.
I tested it on my machine and everything appears to work fine. I used the managed approach.
string mxdPath = BrowseForFile("Map Document", "Map Document (*.mxd)|*.mxd"); Geoprocessor gp = new Geoprocessor {OverwriteOutput = true}; try { CreateMapTilePackage tool = new CreateMapTilePackage { in_map = mxdPath, service_type = "ONLINE", output_file = mxdPath.Replace(".mxd", ".tpk"), format_type = "PNG", level_of_detail = 3, summary = "test", tags = "test" }; IGeoProcessorResult2 result = gp.Execute(tool, null) as IGeoProcessorResult2; if (result.ReturnValue is string) { object sev = 0; Console.WriteLine(gp.GetMessages(ref sev)); } } catch (Exception ex) { Console.WriteLine(ex.Message); object sev = 2; Console.WriteLine(gp.GetMessages(ref sev)); }
Are you needing to run the Create Map Tile Package data management tool against the geoprocessor?
Create Map Tile Package
I tested it on my machine and everything appears to work fine. I used the managed approach.
string mxdPath = BrowseForFile("Map Document", "Map Document (*.mxd)|*.mxd"); Geoprocessor gp = new Geoprocessor {OverwriteOutput = true}; try { CreateMapTilePackage tool = new CreateMapTilePackage { in_map = mxdPath, service_type = "ONLINE", output_file = mxdPath.Replace(".mxd", ".tpk"), format_type = "PNG", level_of_detail = 3, summary = "test", tags = "test" }; IGeoProcessorResult2 result = gp.Execute(tool, null) as IGeoProcessorResult2; if (result.ReturnValue is string) { object sev = 0; Console.WriteLine(gp.GetMessages(ref sev)); } } catch (Exception ex) { Console.WriteLine(ex.Message); object sev = 2; Console.WriteLine(gp.GetMessages(ref sev)); }
I will create a small test project to test this but this is exactly what I was looking for. I don't know how I didn't see the CreateMapTilePackage withing the GeoProcessing namespace but I see it now.
Thanks,
Freddie
Hey Freddie
I've run this code is a small test project and I'm receiving an error in the Catch statement.
ERROR 001117: Map description property must be set
Failed to execute (CreateMapTilePackage).
When I look at the properties of CreateMapTilePackage, "Description" is not an option to assign. When I go into ArcMap and look at the wizard for create a tile package there, Description is an option. Thoughts?
Jim
Prior to calling the tool you could open the map document with IMapDocument and then check or set the description using IDocumentInfo. I believe that description is the Comments property.
IDocumentInfo Interface
That all worked perfectly and now I have an end control for my clients. Two issues become outstanding from this point.
If I create a TPK wihtin ArcMap that has 19 levels of details, it takes several hours (under estimated here) to complete and works out to be just under 1Gb in size. If I take the exact same project and run it through my code (as above), it takes 5 minutes (ish) and has a completion size of 12 mb. Something odd there.
The second issue is trying to setup events for a GeoProcess:
var gp = new Geoprocessor { OverwriteOutput = true }; | |||
//gp.MessagesCreated += GpOnMessagesCreated; | |||
gp.ProgressChanged +=GpOnProgressChanged; | |||
gp.ToolExecuted += GpOnToolExecuted; |
They don't appear to be firing.
If you want me to start a new thread, just let me know.
Thanks,
Jim
Yea...you may want to start a new thread for this. I think you'd need to use the executeAync method to fire those events.
New thread started for those with similar inquiries.