Select to view content in your preferred language

Raster Mobile Cache [10]

2465
10
04-29-2011 11:43 AM
AkhilParujanwala
Regular Contributor
Hi,

I am trying to add a MobileCache that is generated from the Mobile Cache tool in ArcMap.
Unfortunately when I added this Mobile Cache to the map I don't see anything.

I have tried a JPG in an MXD -> Mobile Cache.
TIFF in an MXD -> Mobile Cache.
Featureclass of both JPG and TIFF then put them into an MXD -> Mobile Cache.
Converted the TIFF to a GRID and put that GRID into an MXD -> Mobile Cache.
Took that GRID MXD and turned it into a service and tried to load the service with the cached rater layer for the background and it still didn't work in ArcGIS Mobile 10.

Kindly advise on how to make a mobile cache for ArcGIS Mobile 10.

Thanks,

Akhil P.
0 Kudos
10 Replies
AkhilParujanwala
Regular Contributor
Can anyone share the steps on which they successfully put a Mobile Cache that contains a raster into their mobile application.

I am also using map.AddRange(mobilecache) as my code to add the Mobile Cache generated from the GP tool. Should I be using something else?

Thanks in advance!
0 Kudos
MelindaFrost
Frequent Contributor
For raster caches I created a tiled map service and then copied that cahce locally and used TileCacheMapLayer to add to mobile map.

TileCacheMapLayer mpLayer = new TileCacheMapLayer(streetCache);
0 Kudos
AkhilParujanwala
Regular Contributor
Very interesting, thanks.

I have a small raster image of a building that I took from Google Earth, it is georeferenced vis ArcMap.

If you don't mind telling me how to create a Tile Map Service? Or Where to get information on how to create this please.

Thanks in advance.
0 Kudos
MelindaFrost
Frequent Contributor
Well first off you are going to have to use ArcGIS Server.
Create a mxd with your raster image.
Publish it to ArcGIS Server as a tile service. You will have to determine what scale levels you will need (1:500, 1:1000,1:500 and so on).

Here is a link to the tools for creating and manging tile caches:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/An_overview_of_the_Caching_toolset/005...

After you create it you will need to copy the cache locally. It will be saved on your server under arcgisserver\arcgiscache\<map service name>\
And the local path you will use in the for the TileCacheMapLayer will be the somethign like this: C:\Caches\BaseMapCache\Layers
where under Layers folder is a subfolder called _alllayers and two files- conf.cdi and conf.xml

Not sure if this the route you need to take for what you want to do- seems to me there should be something simpler. But at least you know how to do this.
0 Kudos
MelindaFrost
Frequent Contributor
Also- I have had lots of problems with map.MapLayers.AddRange(mobileCache). Pretty sure there is a major bug there.
Try using the long way to add the layers:

ReadOnlyLayerCollection clc = mobileCache.Layers;
                        int iCnt = mobileCache.Layers.Count;
                        for (int i = 0; i < iCnt; i++)
                        {
                            Layer layer = mobileCache.Layers;
                            MobileCacheMapLayer mobileCacheMapLayer = new MobileCacheMapLayer((MobileCacheLayer)layer);
                            map1.MapLayers.Insert(index, mobileCacheMapLayer);
                        }
0 Kudos
AkhilParujanwala
Regular Contributor
Ok wow, thanks for the detailed information Buddha.

I will let you know how things turn out when I get a chance to tackle this task.


Thanks,

Akhil P.
0 Kudos
AkhilParujanwala
Regular Contributor
I am still having difficulties bringing a Raster cache into ArcGIS Mobile.

Here are the exact steps I am using in full detail, kindly advise if I am doing anything wrong.

1) Georeferenced Raster image in ArcMap with appropriate projection to match all other layers used in the Mobile Application.

2) Publish the MXD as a ArcGIS Service, no additional services were checked, just simply a Map Service.
* It is Compact as well.

3) In ArcCatalog, I used Manage Map Server Cache Tiles, and the tiles were created. I only had 2 scales.
* I checked if the tiles were created and I can also see the TileCache in the Mobile Project Center, meaning the tiles were created correctly.

4) Now I can go two ways to showing the RasterTileCache in ArcGIS Mobile.

a) I created project in Project Center with the RasterTileCache and other operational layers. But I still can't see the RasterTileCache in ArcGIS Mobile. I have copied the Layers folder to the directory of the project file in attempt for ArcGIS Mobile to consume the Layers folder.

I have attempted to modify the AMP file so that it can go to the directory of where the tilecache is located, but it still does not show up on the Map.

b) I also want to use code to bring the RasterTileCache onto the Map. I have created a variable for the location.

string filePath = "C:\\Layers";   //this is where the conf file and tiles are located
TileCacheMapLayer mpLayer = new TileCacheMapLayer(filePath);
ESRI.ArcGIS.Mobile.WPF.Map mmap = MobileApplication.Current.Map;
mpLayer.Open();
mmap.MapLayers.Add(mpLayer);

Everything seems ok so far.

5) I open ArcGIS Mobile, and I am using an unmodified AMP file with just the simple code above and I get an error.
"Parameter is not valid" when the map is displayed.
at System.Drawing.Bitmap..ctor(Stream stream)
at ESRI.ArcGIS.Mobile.DataProducts.RasterData.TileMapLayer.CreateImage(Display display)
at ESRI.ArcGIS.Mobile.DataProducts.RasterData.TileMapLayer.Draw(Display display)
at ESRI.ArcGIS.Mobile.MapLayer.OnDraw(IntPtr canvasHandle)

* Reference to another person having the same problem:
http://forums.arcgis.com/threads/14635-TileCacheMapLayer-problems-in-10

6) In the Layer Visibility I see that a Layer has been added to the map, although it has no name, there is simply a checkbox that is checked and a blank name.

7) If I turn off the visbility of the small Raster Image and zoom to the location of where raster image is, I do see the raster image and it works ok, mind you ArcGIS Mobile becomes very sluggish when zooming and panning.

😎 How do I solve this problem? is there anything I missed? What other solutions are people using for Raster Imagery? How about a Live service connection to the ArcGIS Server (using Internet)?


Thanks in advance.
0 Kudos
AkhilParujanwala
Regular Contributor
Ok I found a decent solution.

I was using an older build of ArcGIS Mobile and Project Center, Buil2475.
I simply installed Build 2500 over the previous build as instructed and things are much smoother.

1) Adding TileCache to Project Center does not crash MPC, which is good.

2) When zooming in ArcGIS Mobile I don't see such a huge performance hit with a TileCache layer enabled.

3) When zooming I can for the most part zoom to full extent and then zoom back to the small Raster layer. Once again, no performance hits when zoom around at full extent. Once the Raster layer is suppose to be drawn there is a small delay.

4) [Problem] When at full extent, and I try to zoom to where the raster TileCache layer is located, ArcGIS Mobile can hang and crash, giving no error. I also checked the Logs and no error was logged.

Overall the Build 2500 did work, but it is still not perfect. ArcGIS Mobile can still crash when I manually attempt to zoom to the TileCache.

5) In addition, the TileCache layer that is added in ArcGIS Mobile WPF Out-of-the-Box solution does not show the name of the layer when using code to add the TileCache from a local directory.

Can anyone kindly provide an solution to get a name to appear for the Layer?

Thanks
0 Kudos
SethHays
Emerging Contributor
I think you just need to set the name when you are creating your new tile cache layer:

     
      TileCacheMapLayer mpLayer = new TileCacheMapLayer(filePath);
            ESRI.ArcGIS.Mobile.WPF.Map mmap = MobileApplication.Current.Map;
            mpLayer.Name = "This is my test layer name";
            mpLayer.Open();
            mmap.MapLayers.Add(mpLayer);


If you are trying to get the name of an existing basemap layer that was added in mobile project center, you could do the following (provided its the bottom layer in the project):

TileCacheMapLayer tileLayer = (TileCacheMapLayer)Convert.ChangeType(mmap.MapLayers.Last(), typeof(TileCacheMapLayer));

         string tileName = tileLayer.Name;
0 Kudos