根据图幅左下角经纬度计算其所在图幅号
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
//char *MapNo:图幅号
//int lon_deg:经度-度
//lon_min:经度-分
//lon_sec:经度-秒
//lat_deg:纬度-度
//lat_min:纬度-分
//lat_sec:纬度-秒
//long lscale:比例尺
bool Trans(char *MapNo,int lon_deg,lon_min,lon_sec,lat_deg,lat_min,lat_sec,long lscale)
{
int ScaleID;
char buf[10];
char S[] = "ABCDEFGHIJKLMNOPQRSTUV"; // 1:1000000地形图图幅所在纬度带字符码
long Scale[] = {1000000,500000,250000,100000,50000,25000,10000,5000}; // 图幅比例尺
double df[] = {14400,7200,3600,1200,600,300,150,75}; // 图幅纬差,单位秒
double dr[] = {21600,10800,5400,1800,900,450,225,112.5}; // 图幅经差单位秒
long r=lon_deg*3600+lon_min*60+lon_sec; // 经度, 单位秒
long f=lat_deg*3600+lat_min*60+lat_sec; // 纬度单位秒
for(ScaleID=0;ScaleID<8;ScaleID++){
if(Scale[ScaleID]==lscale){
break;
}
}
if(ScaleID==8){
return false;
}
int a = f/(4*3600);
int b = r/(6*3600)+31;
int c = (int)(4*3600/df[ScaleID])-(int)((f%(4*3600))/df[ScaleID]);
int d = (int)((r%(6*3600))/dr[ScaleID])+1;
MapNo[0] = S[a];
strcpy(MapNo+1,itoa(b,buf,10));
if(ScaleID==0){
return true;
}
MapNo[3] = S[ScaleID];
itoa(c,buf,10);
if(c<10){
MapNo[4]=MapNo[5]='0';
strcpy(MapNo+6,buf);
}else if(c<100) {
MapNo[4]='0';
strcpy(MapNo+5,buf);}
else if(c<1000){
strcpy(MapNo+4,buf);
}else{
return false;
}
itoa(d,buf,10);
if(d<10){
MapNo[7]=MapNo[8]='0';
strcpy(MapNo+9,buf);
}else if(d<100) {
MapNo[7]='0';
strcpy(MapNo+8,buf);
}else if(d<1000){
strcpy(MapNo+7,buf);
}else{
return false;
}
MapNo[10] = '"0';
return true;
}
本篇文章来源于GIS动力站| 原文链接:/article/dev/2009/720/0972093211BBBBG0BB3063IEDH8F8I.html
问:
想把一些数字格式化为字符串,并在不足的位置补0
______________________________________________________________________________________________
答1:
int i = 1;
string j = string.Format("{0:D4}",i);
Response.Write(j);
______________________________________________________________________________________________
答2:
int k=99;
string s = k.ToString("d4"); s-->0099
______________________________________________________________________________________________
答3:
or
int i,e;//i=1--99
string e=i.Tostring().PadLeft(4, '0');
______________________________________________________________________________________________
答4:
/Expert/topic/1781/1781640.xml?temp=.246731
______________________________________________________________________________________________
答5:
int k=99;
string s = k.ToString();
s = Right("0000" + s , 4);
_________________________________________________________
_____________________________________
答6:
谢谢
本文来自: 站长() 详细出处参考:/web/719/248721.htm
#region 好像没用的分幅
/*class MapFenfu
{
public enum ScaleMark { A, B, C, D, E, F, G, H };//不同比例尺的号码
private int m_1s1000000_row;//1:100万图幅行
private int m_1s1000000_list;//1:100万图幅列
private int m_assign_row;//指定比例尺图幅行
private int m_assign_list;//指定比例尺图幅列
private int m_scale;//指定比例尺;
private esriUnits m_CurMapUnits;
private IMap curMap = new MapClass();
/// <summary>
/// 构造函数,初始化类中的私有变量
/// </summary>
public MapFenfu(int rowIn100,int columIn100, int rowAssigned,int columAssigned,int scale,IMap m_map)
{
m_1s1000000_row = rowIn100;
m_1s1000000_list = columIn100;
m_assign_row = rowAssigned;
m_assign_list = columAssigned;
m_scale = scale;
if (m_map != null)
{
m_CurMapUnits = m_map.MapUnits;
}
else
{
MessageBox.Show("a oh!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
}
}
#region 图幅号计算函数
private IEnvelope FromGeocodingDawn()
{
//计算要素的值
int h = this.m_1s1000000_row;//1:100万行号
int l = this.m_1s1000000_list;//1:100万列号
ScaleMark ScaleMark_1s1000000 = new ScaleMark();
IPoint scaleDelta_1s1000000 = new PointClass();
ScaleMark_1s1000000 = 0;
this.initialScaleMark(ScaleMark_1s1000000, scaleDelta_1s1000000);
double delta_x = scaleDelta_1s1000000.X;//1:100万经差(度)
double delta_y = scaleDelta_1s1000000.Y;//1:100万纬差(度)
ScaleMark pScaleMark = new ScaleMark();
IPoint scaleDelta = new PointClass();
pScaleMark = (ScaleMark)this.m_scale;
this.initialScaleMark(pScaleMark, scaleDelta);//获取不同比例尺及对应的经纬差
double delta_xp = scaleDelta.X;//其余比例尺的经差(度)
double delta_yp = scaleDelta.Y;//其余比例尺的纬差(度)
int hp = this.m_assign_row;
int lp = this.m_assign_list;
IEnvelope pEnvelope = new EnvelopeClass();
if (m_assign_list != 0 && m_assign_row != 0)
{
//进行指定图幅号左上角点经纬度计算:
double ymax = h * delta_y - (hp - 1) * delta_yp; //纬度
double xmin = (l - 31) * delta_x + (lp - 1) * delta_xp;//经度
//推算指定图幅
号右下角点坐标
double ymin = ymax - delta_yp;
double xmax = xmin + delta_xp;
//将点转换成地图存储单位Map(Metres) convertUnits
//esriUnits CurMapUnits = this.axMapControl1.Map.MapUnits;
IUnitConverter UC_map = new UnitConverterClass();
double yMax = UC_map.ConvertUnits(ymax, esriUnits.esriDecimalDegrees, m_CurMapUnits);
double yMin = UC_map.ConvertUnits(ymin, esriUnits.esriDecimalDegrees, m_CurMapUnits);
double xMax = UC_map.ConvertUnits(xmax, esriUnits.esriDecimalDegrees, m_CurMapUnits);
double xMin = UC_map.ConvertUnits(xmin, esriUnits.esriDecimalDegree
s, m_CurMapUnits);
pEnvelope.PutCoords(xMin, yMin, xMax, yMax);
return pEnvelope;
}
else
{
return null;
}
}
#endregion
#region 各比例尺经纬度差
private void initialScaleMark(ScaleMark pScaleMark, IPoint scaleDelta)
{
//IPoint[] scaleArr = new IPoint[8];
//IPoint scaleDelta = new PointClass();
switch (pScaleMark)
{
case ScaleMark.A:
scaleDelta.X = 6;//1:100万经差(度)
scaleDelta.Y = 4;//1:100万纬差(度)
break;
case ScaleMark.B:
scaleDelta.X = 3;//1:50万经差(度)
scaleDelta.Y = 2;//1:50万纬差(度)
break;
case ScaleMark.C:
scaleDelta.X = 1.5;//1:25万经差(度)
scaleDelta.Y = 1;//1:25万纬差(度)
break;
case ScaleMark.D:
scaleDelta.X = 0.5;//1:10万经差(度)
scaleDelta.Y = 0.33333;//1:10万纬差(度)
break;
case ScaleMark.E:
scaleDelta.X = 0.25;//1:5万经差(度)
scaleDelta.Y = 0.16667;//1:5万纬差(度)
break;
case ScaleMark.F:
scaleDelta.X = 0.125;//1:2.5万经差(度)
scaleDelta.Y = 0.08333;//1:2.5万纬差(度)
break;
case ScaleMark.G:
scaleDelta.X = 0.0625;//1:1万经差(度)
scaleDelta.Y = 0.04167;//1:1万纬差(度)
break;
case ScaleMark.H:
scaleDelta.X = 0.03125;//1:5000经差(度)
scaleDelta.Y = 0.02083;//1:5000纬差(度)
break;
}
}
#endregion
}
*/
#endregion