Experience in using the slice map of ArcGIS Server in ArcGIS Engine

Source: Internet
Author: User

 

Recently, I wrote a program based on ArcGIS Engine (AE). Because the displayed features are extremely complex and many data needs to be refreshed and flashed continuously, so I plan to use dynamic display and cache for writing, but I don't know why, every time the program restarts, it cannot connect to the original cache directory. the Code is as follows:

Private void setdynamicdisplay ()
{
Idynamicmap idmap = m_mapcontrol.map as idynamicmap;

If (m_bdynamicdisplay = true)
{
Idmap. dynamicmapenabled = false;
M_bdynamicdisplay = false;

Return;
}

Idmap. dynamicmapenabled = true;
Idmap. dynamicdrawrate = 15;
M_bdynamicdisplay = true;

String strstartuppath = application. startuppath;

String strcachepath = strstartuppath + @ "\ cache ";
Bool bfirstrun =! System. Io. Directory. exists (strcachepath );
If (bfirstrun)
{
System. Io. Directory. createdirectory (strcachepath );
}
Idynamiccachelayermanager pdynamiccachelayermanager = new dynamiccachelayermanagerclass ();
For (INT iindex = 0; iindex <m_mapcontrol.layercount; iindex ++)
{
Ilayer layer = m_mapcontrol.get_layer (iindex );
If (! (Layer is idynamiclayer ))
{
Layer. cached = true;
Pdynamiccachelayermanager. INIT (m_mapcontrol.map, layer );
Bool bcacheable = pdynamiccachelayermanager. cacheable;

If (bcacheable)
{
String scachefoldername = pdynamiccachelayermanager. Foldername;
If (bfirstrun)
{
Pdynamiccachelayermanager. folderpath = strcachepath;
Pdynamiccachelayermanager. detailsthreshold = 100;
Pdynamiccachelayermanager. format = "PNG ";
If (layer is icompositelayer) pdynamiccachelayermanager. Required lidatedgrouplayer = true;
Pdynamiccachelayermanager. strictondemanmode = false;
}
If (! Bfirstrun)
{
Pdynamiccachelayermanager. Connect (strcachepath, scachefoldername );
}
}
}
}
}

After several days of searching, I posted a post on the ESRI China Forum to ask why, but I still couldn't get the answer. If you can see it here, please advise.

The preceding problem cannot be solved, so the problem is solved to ArcGIS Server. Because ArcGIS Server comes with the slicing function, This is the prototype of dynamic display.

After publishing the map as a service on ArcGIS Server, set the slice. then, when the program is loaded, connect to the as map service and add it to the current map control. after a try, the display effect is quite good, but one problem is that when the ratio changes, it is impossible to control which slice layer (tiles) the map control loads ). this will often cause the current proportion to show a very small map, unable to see clearly. it is similar to displaying a large image at a ratio of 50%. even if the ratio of the map to be controlled in the afterextentchanged event of mapcontrol is the same as that of the slice to be displayed. after several attempts, we finally found that when AE downloads the as map, it is closer to the As ratio based on the current map. That is to say, when the current mapcontrol ratio is 200,000, the AS slice has two layers: 220,000 and 100,000. It gives priority to 100,000 slice. so I modified the code in the afterextentchanged event to control the proportion of mapcontrol slightly higher than the proportion of slice I want to display. That is to say, when I want to display a 220,000 slice, I set mapcontrol. mapscale is set to 230,000, so that even if the pulled slice is stretched a little, the display effect is far better than its own choice.

The Code is as follows:

Private void extentupdated ()
{
Double dactivemapscale = m_mapcontrol.mapscale;

If (dactivemapscale = m_dprivscale)
Return;

Double ddangqian = 0.0f;
Double dshangyiji = 0.0f;

Double dshangyijicha = 0.0f;
Double dxiayijicha = 0.0f;

For (INT I = 0; I <dlevels. length; I ++)
{
Ddangqian = dlevels [I];
If (dactivemapscale <= ddangqian)
{
Dxiayijicha = ddangqian-dactivemapscale;
If (dshangyijicha> 0 & dxiayijicha <= dshangyijicha) | dshangyijicha = 0)
{
M_dprivscale = ddangqian;
M_mapcontrol.mapscale = ddangqian;
}
Else if (dxiayijicha> dshangyijicha)
{
M_dprivscale = dshangyiji;
M_mapcontrol.mapscale = dshangyiji;
}
Cborate. Text = string. Format ("1: {0: n}", m_mapcontrol.mapscale );
Return;
}
Else
{
Dshangyijicha = dactivemapscale-ddangqian;
Dshangyiji = ddangqian;
}
}
}

This code selects the most appropriate ratio (closest to the current mapscale) When mapscale is changed. dlevels are an array that stores the proportions you want to display.

 

From: http://hi.baidu.com/hizsk/blog/item/60ee80b19d0a415c09230236.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.