图号(图幅号):地图图号是指为便于使用和管理,按照一定方法将各分幅地图进行的编号。

经常用到图号,但是在网上一直没有找到一个完整的图号转换程序,因此自己写了一个图号处理的库,分享出来。如有错误请指正。

新图号标准:GB/T 13989-2012.国家基本比例尺地形图分幅和编号

旧图号标准:无。历史遗留问题。从最初的苏联坐标系开始,旧图号分别采用了俄文编号/中文编号/数字编号/英文编号等等各个版本,使用起来很不方便。此次将旧图号统一了一下,全部采用“-”分割,百万图号标准同步新图号标准,子比例尺分幅时,共有4幅的用大写ABCD表示,如50万比例尺:H-45-A。大于4幅时使用数字,不足位补零,如10万比例尺:H-45-001。特殊情况,2.5万比例尺,最后一位用1234,倒数第二位用大写ABCD,如:H45-090-C-2。

编程语言:C#。库类包含的方法:新/旧图号互转,新/旧图号检查,新/旧图号非标准格式转标准格式,新/旧图号转图幅东南西北坐标,坐标点所在图幅 等。鉴于篇幅,完整代码可以到我的GitHub上下载。地址:https://github.com/tanghaojie/Mapnumber

   1 using System;
2 using System. Linq;
3
4 namespace Mapnumber {
5
6 /// <summary>
7 /// Mapnumber = Sheet designation
8 /// 图幅号,图幅编号
9 ///
10 /// C#
11 ///
12 /// By JackieTang
13 /// 2016
14 ///
15 /// Reference & Standard: New mapnumber standard GB/T 13989-2012.国家基本比例尺地形图分幅和编号 -China
16 /// Old mapnumber standard Not found. Same as national geomatics center of China
17 ///
18 /// </summary>
19 public class Mapnumber {
20
21 #region Defins about mapnumber 图号定义
22
23 #region 1 million mapnumber defines,same in newmapnumber and oldmapnumber 百万图号定义,新旧图号相同
24
25 /// <summary>
26 /// 1 million standard row nums
27 /// 100万标准行号
28 /// </summary>
29 public static readonly string[] _100W_RowNum = { "A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" , "I" , "J" , "K" , "L" , "M" , "N" , "O" , "P" , "Q" , "R" , "S" , "T" , "U" , "V" };
30 /// <summary>
31 /// 1 million standard column nums
32 /// 100万标准列号
33 /// </summary>
34 public static readonly string[] _100W_ColumnNum = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"
35 , "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40"
36 , "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60"};
37
38 /// <summary>
39 /// Check 1 million mapnumber row num is valid
40 /// 检查100万图号行号是否有效
41 /// </summary>
42 /// <returns>true:valid;false:invalid</returns>
43 public bool Check100W_RowNum( string _100W_RowNum ) {
44 if ( _100W_RowNum. Contains( _100W_RowNum ) ) {
45 return true;
46 }
47 return false;
48 }
49
50 /// <summary>
51 /// Check 1 million mapnumber column num is valid
52 /// 检查100万图号列号是否有效
53 /// </summary>
54 /// <returns>true:valid;false:invalid</returns>
55 public bool Check100W_ColumnNum( string _100W_ColumnNum ) {
56 if ( _100W_ColumnNum. Contains( _100W_ColumnNum ) ) {
57 return true;
58 }
59 return false;
60 }
61
62 /// <summary>
63 /// Change 1 million mapnumber row digital to string
64 /// </summary>
65 /// <returns>1 million mapnumber row string number</returns>
66 public string Change100W_RowDigitalToString( int _100W_RowDigital ) {
67 switch ( _100W_RowDigital ) {
68 case 1:
69 return "A";
70 case 2:
71 return "B";
72 case 3:
73 return "C";
74 case 4:
75 return "D";
76 case 5:
77 return "E";
78 case 6:
79 return "F";
80 case 7:
81 return "G";
82 case 8:
83 return "H";
84 case 9:
85 return "I";
86 case 10:
87 return "J";
88 case 11:
89 return "K";
90 case 12:
91 return "L";
92 case 13:
93 return "M";
94 case 14:
95 return "N";
96 case 15:
97 return "O";
98 case 16:
99 return "P";
100 case 17:
101 return "Q";
102 case 18:
103 return "R";
104 case 19:
105 return "S";
106 case 20:
107 return "T";
108 case 21:
109 return "U";
110 case 22:
111 return "V";
112 default:
113 return "";
114 }
115 }
116
117 /// <summary>
118 /// Change 1 million mapnumber row string number to digital
119 /// </summary>
120 /// <returns>1 million mapnumber row digital number.This is not standard</returns>
121 public int Change100W_RowStringToDigital( string _100W_RowString ) {
122 switch ( _100W_RowString ) {
123 case "A":
124 return 1;
125 case "B":
126 return 2;
127 case "C":
128 return 3;
129 case "D":
130 return 4;
131 case "E":
132 return 5;
133 case "F":
134 return 6;
135 case "G":
136 return 7;
137 case "H":
138 return 8;
139 case "I":
140 return 9;
141 case "J":
142 return 10;
143 case "K":
144 return 11;
145 case "L":
146 return 12;
147 case "M":
148 return 13;
149 case "N":
150 return 14;
151 case "O":
152 return 15;
153 case "P":
154 return 16;
155 case "Q":
156 return 17;
157 case "R":
158 return 18;
159 case "S":
160 return 19;
161 case "T":
162 return 20;
163 case "U":
164 return 21;
165 case "V":
166 return 22;
167 default:
168 return -1;
169 }
170 }
171
172 #endregion
173
174 #region Longitude Difference/Latitude Difference 经差、纬差
175
176 /// <summary>
177 /// 1,000,000
178 /// 1 million longitude difference
179 /// </summary>
180 public const decimal _100W_LongitudeDifference = 6M;
181 /// <summary>
182 /// 1,000,000
183 /// 1 million latitude difference
184 /// </summary>
185 public const decimal _100W_LatitudeDifference = 4M;
186
187 /// <summary>
188 /// 500,000
189 /// 500 thousand longitude difference
190 /// </summary>
191 public const decimal _50W_LongitudeDifference = 3M;
192 /// <summary>
193 /// 500,000
194 /// 500 thousand latitude difference
195 /// </summary>
196 public const decimal _50W_LatitudeDifference = 2M;
197
198 /// <summary>
199 /// 250,000
200 /// 250 thousand longitude difference
201 /// </summary>
202 public const decimal _25W_LongitudeDifference = 3 / 2M;
203 /// <summary>
204 /// 250,000
205 /// 250 thousand latitude difference
206 /// </summary>
207 public const decimal _25W_LatitudeDifference = 1M;
208
209 /// <summary>
210 /// 200,000 only oldmapnumber
211 /// 200 thousand longitude difference
212 /// </summary>
213 public const decimal _20W_LongitudeDifference = 1M;
214 /// <summary>
215 /// 200,000 only oldmapnumber
216 /// 200 thousand latitude difference
217 /// </summary>
218 public const decimal _20W_LatitudeDifference = 2 / 3M;
219
220 /// <summary>
221 /// 100,000
222 /// 100 thousand longitude difference
223 /// </summary>
224 public const decimal _10W_LongitudeDifference = 1 / 2M;
225 /// <summary>
226 /// 100,000
227 /// 100 thousand latitude difference
228 /// </summary>
229 public const decimal _10W_LatitudeDifference = 1 / 3M;
230
231 /// <summary>
232 /// 50,000
233 /// 50 thousand longitude difference
234 /// </summary>
235 public const decimal _5W_LongitudeDifference = 1 / 4M;
236 /// <summary>
237 /// 50,000
238 /// 50 thousand latitude difference
239 /// </summary>
240 public const decimal _5W_LatitudeDifference = 1 / 6M;
241
242 /// <summary>
243 /// 25,000
244 /// 25 thousand longitude difference
245 /// </summary>
246 public const decimal _2_5W_LongitudeDifference = 1 / 8M;
247 /// <summary>
248 /// 25,000
249 /// 25 thousand latitude difference
250 /// </summary>
251 public const decimal _2_5W_LatitudeDifference = 1 / 12M;
252
253 /// <summary>
254 /// 10,000
255 /// 10 thousand longitude difference
256 /// </summary>
257 public const decimal _1W_LongitudeDifference = 1 / 16M;
258 /// <summary>
259 /// 10,000
260 /// 10 thousand latitude difference
261 /// </summary>
262 public const decimal _1W_LatitudeDifference = 1 / 24M;
263
264 /// <summary>
265 /// 5,000
266 /// 5 thousand longitude difference
267 /// </summary>
268 public const decimal _0_5W_LongitudeDifference = 1 / 32M;
269 /// <summary>
270 /// 5,000
271 /// 5 thousand latitude difference
272 /// </summary>
273 public const decimal _0_5W_LatitudeDifference = 1 / 48M;
274
275 /// <summary>
276 /// 2,000
277 /// 2 thousand longitude difference
278 /// </summary>
279 public const decimal _0_2W_LongitudeDifference = 1 / 96M;
280 /// <summary>
281 /// 2,000
282 /// 2 thousand latitude difference
283 /// </summary>
284 public const decimal _0_2W_LatitudeDifference = 1 / 144M;
285
286 /// <summary>
287 /// 1,000
288 /// 1 thousand longitude difference
289 /// </summary>
290 public const decimal _0_1W_LongitudeDifference = 1 / 192M;
291 /// <summary>
292 /// 1,000
293 /// 1 thousand latitude difference
294 /// </summary>
295 public const decimal _0_1W_LatitudeDifference = 1 / 288M;
296
297 /// <summary>
298 /// 500
299 /// 500 longitude difference
300 /// </summary>
301 public const decimal _500_LongitudeDifference = 1 / 384M;
302 /// <summary>
303 /// 500
304 /// 500 latitude difference
305 /// </summary>
306 public const decimal _500_LatitudeDifference = 1 / 576M;
307
308 #endregion
309
310 #region New mapnumber defines 新图幅号定义
311
312 /// <summary>
313 /// Newmapnumber all scale strings
314 /// 新图号比例尺字符
315 /// </summary>
316 public static readonly string[] newMapnumber_ScaleString = { "B" , "C" , "D" , "E" , "F" , "G" , "H" , "I" , "J" , "K" };
317
318 #region New mapnumber max row and column number
319
320 /// <summary>
321 /// 500,000
322 /// Newmapnumber max row and column number
323 /// 新图号最大行列号
324 /// </summary>
325 private const int newMapnumber_50W_MaxNum = 2;
326
327 /// <summary>
328 /// 250,000
329 /// Newmapnumber max row and column number
330 /// </summary>
331 private const int newMapnumber_25W_MaxNum = 4;
332
333 /// <summary>
334 /// 100,000
335 /// Newmapnumber max row and column number
336 /// </summary>
337 private const int newMapnumber_10W_MaxNum = 12;
338
339 /// <summary>
340 /// 50,000
341 /// Newmapnumber max row and column number
342 /// </summary>
343 private const int newMapnumber_5W_MaxNum = 24;
344
345 /// <summary>
346 /// 25,000
347 /// Newmapnumber max row and column number
348 /// </summary>
349 private const int newMapnumber_2_5W_MaxNum = 48;
350
351 /// <summary>
352 /// 10,000
353 /// Newmapnumber max row and column number
354 /// </summary>
355 private const int newMapnumber_1W_MaxNum = 96;
356
357 /// <summary>
358 /// 5,000
359 /// Newmapnumber max row and column number
360 /// </summary>
361 private const int newMapnumber_0_5W_MaxNum = 192;
362
363 /// <summary>
364 /// 2,000
365 /// Newmapnumber max row and column number
366 /// </summary>
367 private const int newMapnumber_0_2W_MaxNum = 576;
368
369 /// <summary>
370 /// 1,000
371 /// Newmapnumber max row and column number
372 /// </summary>
373 private const int newMapnumber_0_1W_MaxNum = 1152;
374
375 /// <summary>
376 /// 500
377 /// Newmapnumber max row and column number
378 /// </summary>
379 private const int newMapnumber_500_MaxNum = 2304;
380
381 #endregion
382
383 /// <summary>
384 /// Newmapnumber all row column num strings
385 /// </summary>
386 private string[] NewMapnumber_GetAllRCNumStrsByMaxNum( int maxNum ) {
387 string[] numStr = new string[maxNum];
388 if ( maxNum < 999 ) {
389 for ( int q = 1 ; q <= maxNum ; q++ ) {
390 numStr[q - 1] = q. ToString( "000" );
391 }
392 } else {
393 for ( int q = 1 ; q <= maxNum ; q++ ) {
394 numStr[q - 1] = q. ToString( "0000" );
395 }
396 }
397 return numStr;
398 }
399
400 /// <summary>
401 /// Newmapnumber all row column num strings
402 /// </summary>
403 private string[] NewMapnumber_GetAllRCNumStrsByScaleStr( string scaleStr ) {
404 switch ( scaleStr ) {
405 case "B":
406 return NewMapnumber_GetAllRCNumStrsByMaxNum( newMapnumber_50W_MaxNum );
407 case "C":
408 return NewMapnumber_GetAllRCNumStrsByMaxNum( newMapnumber_25W_MaxNum );
409 case "D":
410 return NewMapnumber_GetAllRCNumStrsByMaxNum( newMapnumber_10W_MaxNum );
411 case "E":
412 return NewMapnumber_GetAllRCNumStrsByMaxNum( newMapnumber_5W_MaxNum );
413 case "F":
414 return NewMapnumber_GetAllRCNumStrsByMaxNum( newMapnumber_2_5W_MaxNum );
415 case "G":
416 return NewMapnumber_GetAllRCNumStrsByMaxNum( newMapnumber_1W_MaxNum );
417 case "H":
418 return NewMapnumber_GetAllRCNumStrsByMaxNum( newMapnumber_0_5W_MaxNum );
419 case "I":
420 return NewMapnumber_GetAllRCNumStrsByMaxNum( newMapnumber_0_2W_MaxNum );
421 case "J":
422 return NewMapnumber_GetAllRCNumStrsByMaxNum( newMapnumber_0_1W_MaxNum );
423 case "K":
424 return NewMapnumber_GetAllRCNumStrsByMaxNum( newMapnumber_500_MaxNum );
425 default:
426 return null;
427 }
428 }
429
430 /// <summary>
431 /// Newmapnumber check scale str is valid
432 /// </summary>
433 /// <param name="scaleStr"></param>
434 /// <returns>true:valid;false:invalid</returns>
435 private bool NewMapnumber_CheckScaleStr( string scaleStr ) {
436 if ( newMapnumber_ScaleString. Contains( scaleStr ) ) {
437 return true;
438 }
439 return false;
440 }
441
442 /// <summary>
443 /// Newmapnumber check row column num is valid
444 /// </summary>
445 /// <returns>true:valid;false:invalid</returns>
446 private bool NewMapnumber_CheckRCNumIsValid( string scaleStr , string rowNum , string columnNum ) {
447 try {
448 string[] rcNumStr = NewMapnumber_GetAllRCNumStrsByScaleStr( scaleStr );
449 if ( rcNumStr != null ) {
450 if ( rcNumStr. Contains( rowNum ) && rcNumStr. Contains( columnNum ) ) {
451 return true;
452 }
453 }
454 return false;
455 } catch {
456 throw;
457 }
458 }
459
460 /// <summary>
461 /// Newmapnumber get scale denominator number by scale string
462 /// </summary>
463 /// <param name="scaleStr"></param>
464 /// <returns></returns>
465 private int NewMapnumber_GetScaleDenominatorNumberByScaleStr( string scaleStr ) {
466 switch ( scaleStr ) {
467 case "":
468 return 1000000;
469 case null:
470 return 1000000;
471 case "B":
472 return 500000;
473 case "C":
474 return 250000;
475 case "D":
476 return 100000;
477 case "E":
478 return 50000;
479 case "F":
480 return 25000;
481 case "G":
482 return 10000;
483 case "H":
484 return 5000;
485 case "I":
486 return 2000;
487 case "J":
488 return 1000;
489 case "K":
490 return 500;
491 default:
492 return -1;
493 }
494 }
495
496 #endregion
497
498 #region Old mapnumber defines 旧图幅号定义
499
500 #region Old mapnumber max row and column number
501
502 private const int oldMapnumber_50W_RCNum = 2;
503 private const int oldMapnumber_25W_RCNum = 4;
504 private const int oldMapnumber_20W_RCNum = 6;
505 private const int oldMapnumber_10W_RCNum = 12;
506 private const int oldMapnumber_5W_RCNum = 2;
507 private const int oldMapnumber_2_5W_RCNum = 2;
508 private const int oldMapnumber_1W_RCNum = 8;
509
510 #endregion
511
512 private readonly string[] oldMapnumber_ABCD = { "A" , "B" , "C" , "D" };
513 private readonly string[] oldMapnumber_abcd = { "a" , "b" , "c" , "d" };
514 private readonly string[] oldMapnumber_1234 = { "1" , "2" , "3" , "4" };
515
516 /// <summary>
517 /// Get all string by sum
518 /// </summary>
519 /// <param name="sumNum"></param>
520 /// <returns></returns>
521 private string[] OldMapnumber_GetAllRCNumStrsByMaxNum( int sumNum ) {
522 string[] numStr = new string[sumNum];
523 if ( sumNum < 99 ) {
524 for ( int q = 1 ; q <= sumNum ; q++ ) {
525 numStr[q - 1] = q. ToString( "00" );
526 }
527 } else {
528 for ( int q = 1 ; q <= sumNum ; q++ ) {
529 numStr[q - 1] = q. ToString( "000" );
530 }
531 }
532 return numStr;
533 }
534
535 private int OldMapnumber_GetSumRCNum( int rcNum ) {
536 return rcNum * rcNum;
537 }
538
539 /// <summary>
540 /// Oldmapnumber change 1234 to ABCD
541 /// </summary>
542 private string OldMapnumber_Change1234ToABCD( int num ) {
543 switch ( num ) {
544 case 1:
545 return "A";
546 case 2:
547 return "B";
548 case 3:
549 return "C";
550 case 4:
551 return "D";
552 default:
553 return null;
554 }
555 }
556
557 /// <summary>
558 /// Oldmapnumber change 1234 to abcd
559 /// </summary>
560 private string OldMapnumber_Change1234Toabcd( int num ) {
561 switch ( num ) {
562 case 1:
563 return "a";
564 case 2:
565 return "b";
566 case 3:
567 return "c";
568 case 4:
569 return "d";
570 default:
571 return null;
572 }
573 }
574
575 /// <summary>
576 /// Oldmapnumber change ABCD or abcd to 1234
577 /// </summary>
578 private int OldMapnumber_ChangeABCDTo1234( string ABCD_abcd ) {
579 switch ( ABCD_abcd ) {
580 case "A":
581 case "a":
582 return 1;
583 case "B":
584 case "b":
585 return 2;
586 case "C":
587 case "c":
588 return 3;
589 case "D":
590 case "d":
591 return 4;
592 default:
593 return -1;
594 }
595 }
596
597 #endregion
598
599 #endregion
600
601
602 #region Check 检查
603
604 #region Check new mapnumber 检查新图号
605
606 /// <summary>
607 /// Check new mapnumber
608 /// 检查新图幅号
609 /// </summary>
610 public bool NewMapnumber_Check( string newMapnumber ) {
611 try {
612 if ( string. IsNullOrEmpty( newMapnumber ) ) {
613 return false;
614 }
615 int length = newMapnumber. Length;
616
617 #region Check length 长度检查
618 if ( !NewMapnumber_CheckLength( length ) ) {
619 return false;
620 }
621 #endregion
622
623 #region Check 1 million 100万检查
624 string m100W = newMapnumber. Substring( 0 , 3 );
625 if ( !NewMapnumber_Check100W( m100W ) ) {
626 return false;
627 }
628 if ( length == 3 ) {
629 return true;
630 }
631 #endregion
632
633 #region Check scale string 检查比例尺代码
634 string scaleStr = newMapnumber. Substring( 3 , 1 );
635 if ( !NewMapnumber_CheckScaleStr( scaleStr ) ) {
636 return false;
637 }
638 #endregion
639
640 #region Check row and column number 检查行列号
641 if ( length == 10 && scaleStr != "J" && scaleStr != "K" ) {
642 string r = newMapnumber. Substring( 4 , 3 );
643 string c = newMapnumber. Substring( 7 , 3 );
644 if ( !NewMapnumber_CheckRCNumIsValid( scaleStr , r , c ) ) {
645 return false;
646 }
647 } else {
648 string r = newMapnumber. Substring( 4 , 4 );
649 string c = newMapnumber. Substring( 8 , 4 );
650 if ( !NewMapnumber_CheckRCNumIsValid( scaleStr , r , c ) ) {
651 return false;
652 }
653 }
654 #endregion
655
656 return true;
657 } catch {
658 throw;
659 }
660 }
661
662 /// <summary>
663 /// Check newmapnumber length
664 /// </summary>
665 private bool NewMapnumber_CheckLength( int newMapnumberLength ) {
666 if ( newMapnumberLength == 3 || newMapnumberLength == 10 || newMapnumberLength == 12 ) {
667 return true;
668 }
669 return false;
670 }
671
672 /// <summary>
673 /// Check newmapnumber 100W(1,000,000)
674 /// </summary>
675 /// <param name="newMapnumber100W"></param>
676 /// <returns></returns>
677 private bool NewMapnumber_Check100W( string newMapnumber100W ) {
678 if ( newMapnumber100W. Length == 3 ) {
679 string r = newMapnumber100W. Substring( 0 , 1 );
680 string c = newMapnumber100W. Substring( 1 , 2 );
681 if ( !Check100W_RowNum( r ) || !Check100W_ColumnNum( c ) ) {
682 return false;
683 }
684 return true;
685 } else {
686 return false;
687 }
688 }
689
690 #endregion
691
692 #region Chekc old mapnumber 检查旧图号
693
694 /// <summary>
695 /// Check old mapnumber
696 /// 检查旧图幅号
697 /// </summary>
698 /// <param name="oldMapnumber"></param>
699 /// <returns></returns>
700 public bool OldMapnumber_Check( string oldMapnumber ) {
701 try {
702 if ( string. IsNullOrEmpty( oldMapnumber ) ) {
703 return false;
704 }
705 if ( !oldMapnumber. Contains( '-' ) ) {
706 return false;
707 }
708 string[] split = oldMapnumber. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
709 int length = split. Length;
710 if ( !OldMapnumber_CheckAfterSplitLength( length ) ) {
711 return false;
712 }
713 if ( length == 2 )//100
714 {
715 return OldMapnumber_Check100W( oldMapnumber );
716 } else if ( length == 3 )// 50 25 20 10
717 {
718 if ( OldMapnumber_Check50W( oldMapnumber ) || OldMapnumber_Check25W( oldMapnumber )
719 || OldMapnumber_Check20W( oldMapnumber ) || OldMapnumber_Check10W( oldMapnumber ) ) {
720 return true;
721 } else {
722 return false;
723 }
724 } else if ( length == 4 )// 5 1
725 {
726 if ( OldMapnumber_Check5W( oldMapnumber ) || OldMapnumber_Check1W( oldMapnumber ) ) {
727 return true;
728 } else {
729 return false;
730 }
731 } else if ( length == 5 )//2.5 0.5
732 {
733 if ( OldMapnumber_Check2_5W( oldMapnumber ) || OldMapnumber_Check0_5W( oldMapnumber ) ) {
734 return true;
735 } else {
736 return false;
737 }
738 } else {
739 return false;
740 }
741 } catch {
742 throw;
743 }
744 }
745
746 /// <summary>
747 /// Check old mapnumber 100W(1,000,000)
748 /// 检查100万旧图幅号
749 /// </summary>
750 /// <param name="oldMapnumber100W"></param>
751 /// <returns></returns>
752 public bool OldMapnumber_Check100W( string oldMapnumber100W ) {
753 try {
754 if ( string. IsNullOrEmpty( oldMapnumber100W ) ) {
755 return false;
756 }
757
758 #region Check necessary - 检查必须的-
759 if ( !oldMapnumber100W. Contains( '-' ) ) {
760 return false;
761 }
762 #endregion
763
764 string[] split = oldMapnumber100W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
765
766 #region Check length 检查长度
767 int length = split. Length;
768 if ( length != 2 ) {
769 return false;
770 }
771 #endregion
772
773 #region Check 100W row column num 检查100万行列号
774 string r = split[0];
775 string c = split[1];
776 if ( !Check100W_RowNum( r ) || !Check100W_ColumnNum( c ) ) {
777 return false;
778 }
779 #endregion
780
781 return true;
782 } catch {
783 throw;
784 }
785 }
786
787 /// <summary>
788 /// Check old mapnumber 50W(500,000)
789 /// 检查50万旧图幅号
790 /// </summary>
791 /// <param name="oldMapnumber50W"></param>
792 /// <returns></returns>
793 public bool OldMapnumber_Check50W( string oldMapnumber50W ) {
794 try {
795 if ( string. IsNullOrEmpty( oldMapnumber50W ) ) {
796 return false;
797 }
798
799 #region Check necessary - 检查必须的-
800 if ( !oldMapnumber50W. Contains( '-' ) ) {
801 return false;
802 }
803 #endregion
804
805 string[] split = oldMapnumber50W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
806
807 #region Check length 检查长度
808 int length = split. Length;
809 if ( length != 3 ) {
810 return false;
811 }
812 #endregion
813
814 #region Check 100W row column num 检查100万行列号
815 string r = split[0];
816 string c = split[1];
817 if ( !Check100W_RowNum( r ) || !Check100W_ColumnNum( c ) ) {
818 return false;
819 }
820 #endregion
821
822 #region Check sub row column num 检查子行列号
823 string k = split[2];
824 if ( !oldMapnumber_ABCD. Contains( k ) ) {
825 return false;
826 }
827 #endregion
828
829 return true;
830 } catch {
831 throw;
832 }
833 }
834
835 /// <summary>
836 /// Check old mapnumber 25W(250,000)
837 /// 检查25万旧图幅号
838 /// </summary>
839 /// <param name="oldMapnumber25W"></param>
840 /// <returns></returns>
841 public bool OldMapnumber_Check25W( string oldMapnumber25W ) {
842 try {
843 if ( string. IsNullOrEmpty( oldMapnumber25W ) ) {
844 return false;
845 }
846
847 #region Check necessary -[] 检查必须的 - [ ]
848 if ( !oldMapnumber25W. Contains( '-' ) || !oldMapnumber25W. Contains( '[' ) || !oldMapnumber25W. Contains( ']' ) ) {
849 return false;
850 }
851
852 #endregion
853
854 string[] split = oldMapnumber25W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
855
856 #region Check length 检查长度
857 int length = split. Length;
858 if ( length != 3 ) {
859 return false;
860 }
861 #endregion
862
863 #region Check 100W row column num 检查100万行列号
864 string r = split[0];
865 string c = split[1];
866 if ( !Check100W_RowNum( r ) || !Check100W_ColumnNum( c ) ) {
867 return false;
868 }
869 #endregion
870
871 #region Check sub row column num 检查子行列号
872 string k = split[2];
873 string[] subSplit = k. Split( new char[] { '[' , ']' } , StringSplitOptions. RemoveEmptyEntries );
874 int len = subSplit. Length;
875 if ( len != 1 ) {
876 return false;
877 }
878 string sub = subSplit[0];
879 int sum = OldMapnumber_GetSumRCNum( oldMapnumber_25W_RCNum );
880 string[] strs = OldMapnumber_GetAllRCNumStrsByMaxNum( sum );
881 if ( strs. Contains( sub ) ) {
882 return true;
883 } else {
884 return false;
885 }
886 #endregion
887
888 } catch {
889 throw;
890 }
891 }
892
893 /// <summary>
894 /// Check old mapnumber 20W(200,000)
895 /// 检查20万旧图幅号
896 /// </summary>
897 /// <param name="oldMapnumber20W"></param>
898 /// <returns></returns>
899 public bool OldMapnumber_Check20W( string oldMapnumber20W ) {
900 try {
901 if ( string. IsNullOrEmpty( oldMapnumber20W ) ) {
902 return false;
903 }
904
905 #region Check necessary -() 检查必须的 - ( )
906 if ( !oldMapnumber20W. Contains( '-' ) || !oldMapnumber20W. Contains( '(' ) || !oldMapnumber20W. Contains( ')' ) ) {
907 return false;
908 }
909 #endregion
910
911 string[] split = oldMapnumber20W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
912
913 #region Check length 检查长度
914 int length = split. Length;
915 if ( length != 3 ) {
916 return false;
917 }
918 #endregion
919
920 #region Check 100W row column num 检查100万行列号
921 string r = split[0];
922 string c = split[1];
923 if ( !Check100W_RowNum( r ) || !Check100W_ColumnNum( c ) ) {
924 return false;
925 }
926 #endregion
927
928 #region Check sub row column num 检查子行列号
929 string k = split[2];
930 string[] subSplit = k. Split( new char[] { '(' , ')' } , StringSplitOptions. RemoveEmptyEntries );
931 int len = subSplit. Length;
932 if ( len != 1 ) {
933 return false;
934 }
935 string sub = subSplit[0];
936 int sum = OldMapnumber_GetSumRCNum( oldMapnumber_20W_RCNum );
937 string[] strs = OldMapnumber_GetAllRCNumStrsByMaxNum( sum );
938 if ( strs. Contains( sub ) ) {
939 return true;
940 } else {
941 return false;
942 }
943 #endregion
944
945 } catch {
946 throw;
947 }
948 }
949
950 /// <summary>
951 /// Check old mapnumber 10W(100,000)
952 /// 检查10万旧图幅号
953 /// </summary>
954 /// <param name="oldMapnumber10W"></param>
955 /// <returns></returns>
956 public bool OldMapnumber_Check10W( string oldMapnumber10W ) {
957 try {
958 if ( string. IsNullOrEmpty( oldMapnumber10W ) ) {
959 return false;
960 }
961
962 #region Check necessary - 检查必须的 -
963 if ( !oldMapnumber10W. Contains( '-' ) ) {
964 return false;
965 }
966 #endregion
967
968 string[] split = oldMapnumber10W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
969
970 #region Check length 检查长度
971 int length = split. Length;
972 if ( length != 3 ) {
973 return false;
974 }
975 #endregion
976
977 #region Check 100W row column num 检查100万行列号
978 string r = split[0];
979 string c = split[1];
980 if ( !Check100W_RowNum( r ) || !Check100W_ColumnNum( c ) ) {
981 return false;
982 }
983 #endregion
984
985 #region Check sub row column num 检查子行列号
986 string sub = split[2];
987 int sum = OldMapnumber_GetSumRCNum( oldMapnumber_10W_RCNum );
988 string[] strs = OldMapnumber_GetAllRCNumStrsByMaxNum( sum );
989 if ( strs. Contains( sub ) ) {
990 return true;
991 } else {
992 return false;
993 }
994 #endregion
995
996 } catch {
997 throw;
998 }
999 }
1000
1001 /// <summary>
1002 /// Check old mapnumber 5W(50,000)
1003 /// 检查5万旧图幅号
1004 /// </summary>
1005 /// <param name="oldMapnumber5W"></param>
1006 /// <returns></returns>
1007 public bool OldMapnumber_Check5W( string oldMapnumber5W ) {
1008 try {
1009 if ( string. IsNullOrEmpty( oldMapnumber5W ) ) {
1010 return false;
1011 }
1012
1013 #region 检查必须的 -
1014 if ( !oldMapnumber5W. Contains( '-' ) ) {
1015 return false;
1016 }
1017 #endregion
1018
1019 string[] split = oldMapnumber5W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
1020
1021 #region 检查长度
1022 int length = split. Length;
1023 if ( length != 4 ) {
1024 return false;
1025 }
1026 #endregion
1027
1028 #region 检查10万图号
1029 string o10W = split[0] + "-" + split[1] + "-" + split[2];
1030 if ( !OldMapnumber_Check10W( o10W ) ) {
1031 return false;
1032 }
1033 #endregion
1034
1035 #region 检查子行列号
1036 string k = split[3];
1037 if ( !oldMapnumber_ABCD. Contains( k ) ) {
1038 return false;
1039 }
1040 #endregion
1041
1042 return true;
1043 } catch {
1044 throw;
1045 }
1046 }
1047
1048 /// <summary>
1049 /// Check old mapnumber 2.5W(25,000)
1050 /// 检查2.5万旧图幅号
1051 /// </summary>
1052 /// <param name="oldMapnumber2_5W"></param>
1053 /// <returns></returns>
1054 public bool OldMapnumber_Check2_5W( string oldMapnumber2_5W ) {
1055 try {
1056 if ( string. IsNullOrEmpty( oldMapnumber2_5W ) ) {
1057 return false;
1058 }
1059
1060 #region 检查必须的 -
1061 if ( !oldMapnumber2_5W. Contains( '-' ) ) {
1062 return false;
1063 }
1064 #endregion
1065 string[] split = oldMapnumber2_5W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
1066
1067 #region 检查长度
1068 int length = split. Length;
1069 if ( length != 5 ) {
1070 return false;
1071 }
1072 #endregion
1073
1074 #region 检查5万图号
1075 string o5W = split[0] + "-" + split[1] + "-" + split[2] + "-" + split[3];
1076 if ( !OldMapnumber_Check5W( o5W ) ) {
1077 return false;
1078 }
1079 #endregion
1080
1081 #region 检查子行列号
1082 string k = split[4];
1083 if ( !oldMapnumber_1234. Contains( k ) ) {
1084 return false;
1085 }
1086 #endregion
1087
1088 return true;
1089 } catch {
1090 throw;
1091 }
1092 }
1093
1094 /// <summary>
1095 /// Check old mapnumber 1W(10,000)
1096 /// 检查1万旧图幅号
1097 /// </summary>
1098 /// <param name="oldMapnumber1W"></param>
1099 /// <returns></returns>
1100 public bool OldMapnumber_Check1W( string oldMapnumber1W ) {
1101 try {
1102 if ( string. IsNullOrEmpty( oldMapnumber1W ) ) {
1103 return false;
1104 }
1105
1106 #region 检查必须的 - ( )
1107 if ( !oldMapnumber1W. Contains( '-' ) || !oldMapnumber1W. Contains( '(' ) || !oldMapnumber1W. Contains( ')' ) ) {
1108 return false;
1109 }
1110 #endregion
1111
1112 string[] split = oldMapnumber1W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
1113
1114 #region 检查长度
1115 int length = split. Length;
1116 if ( length != 4 ) {
1117 return false;
1118 }
1119 #endregion
1120
1121 #region 检查10万图号
1122 string o10W = split[0] + "-" + split[1] + "-" + split[2];
1123 if ( !OldMapnumber_Check10W( o10W ) ) {
1124 return false;
1125 }
1126 #endregion
1127
1128 #region 检查子行列号
1129 string k = split[3];
1130 string[] subSplit = k. Split( new char[] { '(' , ')' } , StringSplitOptions. RemoveEmptyEntries );
1131 int len = subSplit. Length;
1132 if ( len != 1 ) {
1133 return false;
1134 }
1135 string sub = subSplit[0];
1136 int sum = OldMapnumber_GetSumRCNum( oldMapnumber_1W_RCNum );
1137 string[] strs = OldMapnumber_GetAllRCNumStrsByMaxNum( sum );
1138 if ( strs. Contains( sub ) ) {
1139 return true;
1140 } else {
1141 return false;
1142 }
1143 #endregion
1144
1145 } catch {
1146 throw;
1147 }
1148 }
1149
1150 /// <summary>
1151 /// Check old mapnumber 5,000
1152 /// 检查0.5万旧图幅号
1153 /// </summary>
1154 /// <param name="oldMapnumber0_5W"></param>
1155 /// <returns></returns>
1156 public bool OldMapnumber_Check0_5W( string oldMapnumber0_5W ) {
1157 try {
1158 if ( string. IsNullOrEmpty( oldMapnumber0_5W ) ) {
1159 return false;
1160 }
1161
1162 #region 检查必须的 - ( )
1163 if ( !oldMapnumber0_5W. Contains( '-' ) || !oldMapnumber0_5W. Contains( '(' ) || !oldMapnumber0_5W. Contains( ')' ) ) {
1164 return false;
1165 }
1166 #endregion
1167
1168 string[] split = oldMapnumber0_5W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
1169
1170 #region 检查长度
1171 int length = split. Length;
1172 if ( length != 5 ) {
1173 return false;
1174 }
1175 #endregion
1176
1177 #region 检查1万图号
1178 string o1W = split[0] + "-" + split[1] + "-" + split[2] + "-" + split[3];
1179 if ( !OldMapnumber_Check1W( o1W ) ) {
1180 return false;
1181 }
1182 #endregion
1183
1184 #region 检查子行列号
1185 string k = split[4];
1186 if ( !oldMapnumber_abcd. Contains( k ) ) {
1187 return false;
1188 }
1189 #endregion
1190
1191 return true;
1192 } catch {
1193 throw;
1194 }
1195 }
1196
1197 /// <summary>
1198 /// Check old mapnumber length after split
1199 /// </summary>
1200 /// <param name="oldMapnumberLength"></param>
1201 /// <returns></returns>
1202 private bool OldMapnumber_CheckAfterSplitLength( int oldMapnumberLength ) {
1203 if ( oldMapnumberLength < 2 || oldMapnumberLength > 5 ) {
1204 return false;
1205 }
1206 return true;
1207 }
1208
1209 #endregion
1210
1211 #endregion
1212
1213
1214 #region Exchange new/old mapnumber 新旧图幅号转换
1215
1216 #region Old mapnumber to new mapnumber 旧图号转新图号
1217
1218 /// <summary>
1219 /// Old mapnumber to new mapnumber
1220 /// 旧图幅号转新图幅号
1221 /// </summary>
1222 /// <param name="oldMapnumber"></param>
1223 /// <returns></returns>
1224 public string OldMapnumberToNewMapnumber( string oldMapnumber ) {
1225 if ( !OldMapnumber_Check( oldMapnumber ) ) {
1226 return "";
1227 }
1228 string result = "";
1229 result = OldMapnumberToNewMapnumber_100W( oldMapnumber );
1230 if ( !string. IsNullOrEmpty( result ) ) {
1231 return result;
1232 }
1233 result = OldMapnumberToNewMapnumber_50W( oldMapnumber );
1234 if ( !string. IsNullOrEmpty( result ) ) {
1235 return result;
1236 }
1237 result = OldMapnumberToNewMapnumber_25W( oldMapnumber );
1238 if ( !string. IsNullOrEmpty( result ) ) {
1239 return result;
1240 }
1241 result = OldMapnumberToNewMapnumber_10W( oldMapnumber );
1242 if ( !string. IsNullOrEmpty( result ) ) {
1243 return result;
1244 }
1245 result = OldMapnumberToNewMapnumber_5W( oldMapnumber );
1246 if ( !string. IsNullOrEmpty( result ) ) {
1247 return result;
1248 }
1249 result = OldMapnumberToNewMapnumber_2_5W( oldMapnumber );
1250 if ( !string. IsNullOrEmpty( result ) ) {
1251 return result;
1252 }
1253 result = OldMapnumberToNewMapnumber_1W( oldMapnumber );
1254 if ( !string. IsNullOrEmpty( result ) ) {
1255 return result;
1256 }
1257 result = OldMapnumberToNewMapnumber_0_5W( oldMapnumber );
1258 if ( !string. IsNullOrEmpty( result ) ) {
1259 return result;
1260 }
1261 return result;
1262 }
1263
1264 /// <summary>
1265 /// Old mapnumber to new mapnumber 100W
1266 /// 100万旧图幅号转新图幅号
1267 /// </summary>
1268 /// <param name="oldMapnumber100W"></param>
1269 /// <returns></returns>
1270 public string OldMapnumberToNewMapnumber_100W( string oldMapnumber100W ) {
1271 try {
1272 if ( !OldMapnumber_Check100W( oldMapnumber100W ) ) {
1273 return "";
1274 }
1275 string[] temp = oldMapnumber100W. Split( '-' );
1276 string new100 = temp[0] + temp[1]. PadLeft( 2 , '0' );
1277 return new100;
1278 } catch {
1279 throw;
1280 }
1281 }
1282
1283 /// <summary>
1284 /// Old mapnumber to new mapnumber 50W
1285 /// 50万旧图幅号转新图幅号
1286 /// </summary>
1287 /// <param name="oldMapnumber50W"></param>
1288 /// <returns></returns>
1289 public string OldMapnumberToNewMapnumber_50W( string oldMapnumber50W ) {
1290 try {
1291 if ( !OldMapnumber_Check50W( oldMapnumber50W ) ) {
1292 return "";
1293 }
1294 string[] temp = oldMapnumber50W. Split( '-' );
1295 string new100 = temp[0] + temp[1]. PadLeft( 2 , '0' );
1296 int x = OldMapnumber_ChangeABCDTo1234( temp[2] );
1297 if ( x <= 0 ) {
1298 return "";
1299 }
1300 int new50R = OldToNew50W_R( x );
1301 int new50C = OldToNew50W_C( x );
1302 return new100 + "B" + new50R. ToString(). PadLeft( 3 , '0' ) + new50C. ToString(). PadLeft( 3 , '0' );
1303 } catch {
1304 throw;
1305 }
1306 }
1307
1308 /// <summary>
1309 /// Old mapnumber to new mapnumber 25W
1310 /// 25万旧图幅号转新图幅号
1311 /// </summary>
1312 /// <param name="oldMapnumber25W"></param>
1313 /// <returns></returns>
1314 public string OldMapnumberToNewMapnumber_25W( string oldMapnumber25W ) {
1315 try {
1316 if ( !OldMapnumber_Check25W( oldMapnumber25W ) ) {
1317 return "";
1318 }
1319 string[] temp = oldMapnumber25W. Split( '-' );
1320 string new100 = temp[0] + temp[1]. PadLeft( 2 , '0' );
1321 string sub25W = temp[2];
1322 string[] subTemp = sub25W. Split( new char[] { '[' , ']' } , StringSplitOptions. RemoveEmptyEntries );
1323 int x = int. Parse( subTemp[0] );
1324 int new25R = OldToNew25W_R( x );
1325 int new25C = OldToNew25W_C( x );
1326 return new100 + "C" + new25R. ToString(). PadLeft( 3 , '0' ) + new25C. ToString(). PadLeft( 3 , '0' );
1327 } catch {
1328 throw;
1329 }
1330 }
1331
1332 /// <summary>
1333 /// Old mapnumber to new mapnumber 10W
1334 /// 10万旧图幅号转新图幅号
1335 /// </summary>
1336 /// <param name="oldMapnumber10W"></param>
1337 /// <returns></returns>
1338 public string OldMapnumberToNewMapnumber_10W( string oldMapnumber10W ) {
1339 try {
1340 if ( !OldMapnumber_Check10W( oldMapnumber10W ) ) {
1341 return "";
1342 }
1343 string[] temp = oldMapnumber10W. Split( '-' );
1344 string new100 = temp[0] + temp[1]. PadLeft( 2 , '0' );
1345 string sub10W = temp[2];
1346 int x = int. Parse( sub10W );
1347 int new10R = OldToNew10W_R( x );
1348 int new10C = OldToNew10W_C( x );
1349 return new100 + "D" + new10R. ToString(). PadLeft( 3 , '0' ) + new10C. ToString(). PadLeft( 3 , '0' );
1350 } catch {
1351 throw;
1352 }
1353 }
1354
1355 /// <summary>
1356 /// Old mapnumber to new mapnumber 5W
1357 /// 5万旧图幅号转新图幅号
1358 /// </summary>
1359 /// <param name="oldMapnumber5W"></param>
1360 /// <returns></returns>
1361 public string OldMapnumberToNewMapnumber_5W( string oldMapnumber5W ) {
1362 try {
1363 if ( !OldMapnumber_Check5W( oldMapnumber5W ) ) {
1364 return "";
1365 }
1366 string[] temp = oldMapnumber5W. Split( '-' );
1367 string new100 = temp[0] + temp[1]. PadLeft( 2 , '0' );
1368 string sub10W = temp[2];
1369 int x = int. Parse( sub10W );
1370 int new10R = OldToNew10W_R( x );
1371 int new10C = OldToNew10W_C( x );
1372 int sub5W = OldMapnumber_ChangeABCDTo1234( temp[3] );
1373 int new5R = OldToNew5W_R( sub5W , new10R );
1374 int new5C = OldToNew5W_C( sub5W , new10C );
1375 return new100 + "E" + new5R. ToString(). PadLeft( 3 , '0' ) + new5C. ToString(). PadLeft( 3 , '0' );
1376 } catch {
1377 throw;
1378 }
1379 }
1380
1381 /// <summary>
1382 /// Old mapnumber to new mapnumber 2.5W
1383 /// 2.5万旧图幅号转新图幅号
1384 /// </summary>
1385 /// <param name="oldMapnumber2_5W"></param>
1386 /// <returns></returns>
1387 public string OldMapnumberToNewMapnumber_2_5W( string oldMapnumber2_5W ) {
1388 try {
1389 if ( !OldMapnumber_Check2_5W( oldMapnumber2_5W ) ) {
1390 return "";
1391 }
1392 string[] temp = oldMapnumber2_5W. Split( '-' );
1393 string new100 = temp[0] + temp[1]. PadLeft( 2 , '0' );
1394 string sub10W = temp[2];
1395 int x = int. Parse( sub10W );
1396 int new10R = OldToNew10W_R( x );
1397 int new10C = OldToNew10W_C( x );
1398 int sub5W = OldMapnumber_ChangeABCDTo1234( temp[3] );
1399 int new5R = OldToNew5W_R( sub5W , new10R );
1400 int new5C = OldToNew5W_C( sub5W , new10C );
1401 int sub2_5W = int. Parse( temp[4] );
1402 int new2_5R = OldToNew2_5W_R( sub2_5W , new5R );
1403 int new2_5C = OldToNew2_5W_C( sub2_5W , new5C );
1404 string new2 = new100 + "F" + new2_5R. ToString(). PadLeft( 3 , '0' ) + new2_5C. ToString(). PadLeft( 3 , '0' );
1405 return new2;
1406 } catch {
1407 throw;
1408 }
1409 }
1410
1411 /// <summary>
1412 /// Old mapnumber to new mapnumber 1W
1413 /// 1万旧图幅号转新图幅号
1414 /// </summary>
1415 /// <param name="oldMapnumber1W"></param>
1416 /// <returns></returns>
1417 public string OldMapnumberToNewMapnumber_1W( string oldMapnumber1W ) {
1418 try {
1419 if ( !OldMapnumber_Check1W( oldMapnumber1W ) ) {
1420 return "";
1421 }
1422 string[] temp = oldMapnumber1W. Split( '-' );
1423 string new100 = temp[0] + temp[1]. PadLeft( 2 , '0' );
1424 string sub10W = temp[2];
1425 int x = int. Parse( sub10W );
1426 int new10R = OldToNew10W_R( x );
1427 int new10C = OldToNew10W_C( x );
1428 string sub1W = temp[3];
1429 string[] subTemp = sub1W. Split( new char[] { '(' , ')' } , StringSplitOptions. RemoveEmptyEntries );
1430 int k = int. Parse( subTemp[0] );
1431 int new1R = OldToNew1W_R( k , new10R );
1432 int new1C = OldToNew1W_C( k , new10C );
1433 return new100 + "G" + new1R. ToString(). PadLeft( 3 , '0' ) + new1C. ToString(). PadLeft( 3 , '0' );
1434 } catch {
1435 throw;
1436 }
1437 }
1438
1439 /// <summary>
1440 /// Old mapnumber to new mapnumber 0.5W
1441 /// 0.5万旧图幅号转新图幅号
1442 /// </summary>
1443 /// <param name="oldMapnumber0_5W"></param>
1444 /// <returns></returns>
1445 public string OldMapnumberToNewMapnumber_0_5W( string oldMapnumber0_5W ) {
1446 try {
1447 if ( !OldMapnumber_Check0_5W( oldMapnumber0_5W ) ) {
1448 return "";
1449 }
1450 string[] temp = oldMapnumber0_5W. Split( '-' );
1451 string new100 = temp[0] + temp[1]. PadLeft( 2 , '0' );
1452 string sub10W = temp[2];
1453 int x = int. Parse( sub10W );
1454 int new10R = OldToNew10W_R( x );
1455 int new10C = OldToNew10W_C( x );
1456 string sub1W = temp[3];
1457 string[] subTemp = sub1W. Split( new char[] { '(' , ')' } , StringSplitOptions. RemoveEmptyEntries );
1458 int k = int. Parse( subTemp[0] );
1459 int new1R = OldToNew1W_R( k , new10R );
1460 int new1C = OldToNew1W_C( k , new10C );
1461 string sub0_5W = temp[4];
1462 int l = OldMapnumber_ChangeABCDTo1234( sub0_5W );
1463 int new0_5R = OldToNew0_5W_R( l , new1R );
1464 int new0_5C = OldToNew0_5W_C( l , new1C );
1465 return new100 + "H" + new0_5R. ToString(). PadLeft( 3 , '0' ) + new0_5C. ToString(). PadLeft( 3 , '0' );
1466 } catch {
1467 throw;
1468 }
1469 }
1470
1471 #region Old mapnumber to new mapnumber calculate row column number 旧转新计算行列号
1472
1473 /// <summary>
1474 /// Old mapnumber to new mapnumber calculate 50W row number
1475 /// </summary>
1476 private int OldToNew50W_R( int oldMapnumberSub50W ) {
1477 return ( oldMapnumberSub50W - 1 ) / 2 + 1;
1478 }
1479 /// <summary>
1480 /// Old mapnumber to new mapnumber calculate 50W column number
1481 /// </summary>
1482 private int OldToNew50W_C( int oldMapnumberSub50W ) {
1483 return ( oldMapnumberSub50W + 1 ) % 2 + 1;
1484 }
1485
1486 /// <summary>
1487 /// Old mapnumber to new mapnumber calculate 25W row number
1488 /// </summary>
1489 private int OldToNew25W_R( int oldMapnumberSub25W ) {
1490 return ( ( oldMapnumberSub25W - 1 ) / 4 ) + 1;
1491 }
1492 /// <summary>
1493 /// Old mapnumber to new mapnumber calculate 25W column number
1494 /// </summary>
1495 private int OldToNew25W_C( int oldMapnumberSub25W ) {
1496 return ( ( oldMapnumberSub25W + 3 ) % 4 ) + 1;
1497 }
1498
1499 /// <summary>
1500 /// Old mapnumber to new mapnumber calculate 10W row number
1501 /// </summary>
1502 private int OldToNew10W_R( int oldMapnumberSub10W ) {
1503 return ( ( oldMapnumberSub10W - 1 ) / 12 ) + 1;
1504 }
1505 /// <summary>
1506 /// Old mapnumber to new mapnumber calculate 10W column number
1507 /// </summary>
1508 private int OldToNew10W_C( int oldMapnumberSub10W ) {
1509 return ( ( oldMapnumberSub10W + 11 ) % 12 ) + 1;
1510 }
1511
1512 /// <summary>
1513 /// Old mapnumber to new mapnumber calculate 5W row number
1514 /// </summary>
1515 private int OldToNew5W_R( int oldMapnumberSub5W , int new10R ) {
1516 return ( 2 * new10R ) + ( ( oldMapnumberSub5W - 1 ) / 2 - 1 );
1517 }
1518 /// <summary>
1519 /// Old mapnumber to new mapnumber calculate 5W column number
1520 /// </summary>
1521 private int OldToNew5W_C( int oldMapnumberSub5W , int new10C ) {
1522 return ( 2 * new10C ) + ( ( oldMapnumberSub5W + 1 ) % 2 - 1 );
1523 }
1524
1525 /// <summary>
1526 /// Old mapnumber to new mapnumber calculate 2_5W row number
1527 /// </summary>
1528 private int OldToNew2_5W_R( int oldMapnumberSub2_5W , int new5R ) {
1529 return 2 * new5R + ( oldMapnumberSub2_5W - 1 ) / 2 - 1;
1530 }
1531 /// <summary>
1532 /// Old mapnumber to new mapnumber calculate 2_5W column number
1533 /// </summary>
1534 private int OldToNew2_5W_C( int oldMapnumberSub2_5W , int new5C ) {
1535 return 2 * new5C + ( oldMapnumberSub2_5W + 1 ) % 2 - 1;
1536 }
1537
1538 /// <summary>
1539 /// Old mapnumber to new mapnumber calculate 1W row number
1540 /// </summary>
1541 private int OldToNew1W_R( int oldMapnumberSub1W , int new10R ) {
1542 return 8 * new10R + ( ( oldMapnumberSub1W - 1 ) / 8 ) - 7;
1543 }
1544 /// <summary>
1545 /// Old mapnumber to new mapnumber calculate 1W column number
1546 /// </summary>
1547 private int OldToNew1W_C( int oldMapnumberSub1W , int new10C ) {
1548 return 8 * new10C + ( ( oldMapnumberSub1W + 7 ) % 8 ) - 7;
1549 }
1550
1551 /// <summary>
1552 /// Old mapnumber to new mapnumber calculate 0_5W row number
1553 /// </summary>
1554 private int OldToNew0_5W_R( int oldMapnumberSub0_5W , int new1R ) {
1555 return 2 * new1R + ( oldMapnumberSub0_5W - 1 ) / 2 - 1;
1556 }
1557 /// <summary>
1558 /// Old mapnumber to new mapnumber calculate 0_5W column number
1559 /// </summary>
1560 private int OldToNew0_5W_C( int oldMapnumberSub0_5W , int new1C ) {
1561 return 2 * new1C + ( oldMapnumberSub0_5W + 1 ) % 2 - 1;
1562 }
1563
1564 #endregion
1565
1566 #endregion
1567
1568 #region New mapnumber to old mapnumber 新图号转旧图号
1569
1570 /// <summary>
1571 /// New mapnumber to old mapnumber
1572 /// 新图幅号转旧图幅号
1573 /// </summary>
1574 /// <param name="newMapnumber"></param>
1575 /// <returns></returns>
1576 public string NewMapnumberToOldMapnumber( string newMapnumber ) {
1577 try {
1578 if ( !NewMapnumber_Check( newMapnumber ) ) {
1579 return "";
1580 }
1581 string[] newMapnumberInfo = GetInfoFromNewMapnumber( newMapnumber );
1582 if ( newMapnumberInfo == null ) {
1583 return "";
1584 }
1585 string n100WR = newMapnumberInfo[0];
1586 string n100WC = newMapnumberInfo[1];
1587 string nScaleStr = newMapnumberInfo[2];
1588 string nR = newMapnumberInfo[3];
1589 string nC = newMapnumberInfo[4];
1590 int scaleNumber = NewMapnumber_GetScaleDenominatorNumberByScaleStr( nScaleStr );
1591 if ( scaleNumber == -1 ) {
1592 return null;
1593 }
1594 #region 100万
1595 else if ( scaleNumber == 1000000 ) {
1596 return NewMapnumberToOldMapnumber_100W( n100WR , n100WC );
1597 }
1598 #endregion
1599 #region 50万
1600 else if ( scaleNumber == 500000 ) {
1601 string o100W = NewMapnumberToOldMapnumber_100W( n100WR , n100WC );
1602 int o50W = NewToOld50WNum( nR , nC );
1603 string o50WStr = OldMapnumber_Change1234ToABCD( o50W );
1604 if ( string. IsNullOrEmpty( o50WStr ) ) {
1605 return "";
1606 }
1607 return o100W + "-" + o50WStr;
1608 }
1609 #endregion
1610 #region 25万
1611 else if ( scaleNumber == 250000 ) {
1612 string o100W = NewMapnumberToOldMapnumber_100W( n100WR , n100WC );
1613 int o25W = NewToOld25WNum( nR , nC );
1614 if ( o25W <= 0 || o25W > 16 ) {
1615 return "";
1616 }
1617 return o100W + "-[" + o25W. ToString( "00" ) + "]";
1618 }
1619 #endregion
1620 #region 10万
1621 else if ( scaleNumber == 100000 ) {
1622 string o100W = NewMapnumberToOldMapnumber_100W( n100WR , n100WC );
1623 int o10W = NewToOld10WNum( nR , nC );
1624 if ( o10W <= 0 || o10W > 144 ) {
1625 return "";
1626 }
1627 return o100W + "-" + o10W. ToString( "000" );
1628 }
1629 #endregion
1630 #region 5万
1631 else if ( scaleNumber == 50000 ) {
1632 string o100W = NewMapnumberToOldMapnumber_100W( n100WR , n100WC );
1633 int o5W = NewToOld5WNum( nR , nC );
1634 string o5WStr = OldMapnumber_Change1234ToABCD( o5W );
1635 if ( string. IsNullOrEmpty( o5WStr ) ) {
1636 return "";
1637 }
1638 int n10WR = New5WRCToNew10WRC( int. Parse( nR ) );
1639 int n10WC = New5WRCToNew10WRC( int. Parse( nC ) );
1640 int o10W = NewToOld10WNum( n10WR. ToString() , n10WC. ToString() );
1641 if ( o10W <= 0 || o10W > 144 ) {
1642 return "";
1643 }
1644 return o100W + "-" + o10W. ToString( "000" ) + "-" + o5WStr;
1645 }
1646 #endregion
1647 #region 2.5万
1648 else if ( scaleNumber == 25000 ) {
1649 string o100W = NewMapnumberToOldMapnumber_100W( n100WR , n100WC );
1650 int o2_5W = NewToOld2_5WNum( nR , nC );
1651 if ( o2_5W <= 0 || o2_5W > 4 ) {
1652 return "";
1653 }
1654 int n5WR = New2_5WRCToNew5WRC( int. Parse( nR ) );
1655 int n5WC = New2_5WRCToNew5WRC( int. Parse( nC ) );
1656 int o5W = NewToOld5WNum( n5WR. ToString() , n5WC. ToString() );
1657 string o5WStr = OldMapnumber_Change1234ToABCD( o5W );
1658 if ( string. IsNullOrEmpty( o5WStr ) ) {
1659 return "";
1660 }
1661 int n10WR = New5WRCToNew10WRC( n5WR );
1662 int n10WC = New5WRCToNew10WRC( n5WC );
1663 int o10W = NewToOld10WNum( n10WR. ToString() , n10WC. ToString() );
1664 if ( o10W <= 0 || o10W > 144 ) {
1665 return "";
1666 }
1667
1668 return o100W + "-" + o10W. ToString( "000" ) + "-" + o5WStr + "-" + o2_5W. ToString();
1669 }
1670 #endregion
1671 #region 1万
1672 else if ( scaleNumber == 10000 ) {
1673 string o100W = NewMapnumberToOldMapnumber_100W( n100WR , n100WC );
1674 int o1W = NewToOld1WNum( nR , nC );
1675 if ( o1W <= 0 || o1W > 64 ) {
1676 return "";
1677 }
1678 int n10WR = New1WRCToNew10WRC( int. Parse( nR ) );
1679 int n10WC = New1WRCToNew10WRC( int. Parse( nC ) );
1680 int o10W = NewToOld10WNum( n10WR. ToString() , n10WC. ToString() );
1681 if ( o10W <= 0 || o10W > 144 ) {
1682 return "";
1683 }
1684 return o100W + "-" + o10W. ToString( "000" ) + "-(" + o1W. ToString( "00" ) + ")";
1685 }
1686 #endregion
1687 #region 5000
1688 else if ( scaleNumber == 5000 ) {
1689 string o100W = NewMapnumberToOldMapnumber_100W( n100WR , n100WC );
1690 int o0_5W = NewToOld0_5WNum( nR , nC );
1691 string o0_5WStr = OldMapnumber_Change1234Toabcd( o0_5W );
1692 if ( string. IsNullOrEmpty( o0_5WStr ) ) {
1693 return "";
1694 }
1695 int n1WR = New0_5WRCToNew1WRC( int. Parse( nR ) );
1696 int n1WC = New0_5WRCToNew1WRC( int. Parse( nC ) );
1697 int o1W = NewToOld1WNum( n1WR. ToString() , n1WC. ToString() );
1698 if ( o1W <= 0 || o1W > 64 ) {
1699 return "";
1700 }
1701 int n10WR = New1WRCToNew10WRC( n1WR );
1702 int n10WC = New1WRCToNew10WRC( n1WC );
1703 int o10W = NewToOld10WNum( n10WR. ToString() , n10WC. ToString() );
1704 if ( o10W <= 0 || o10W > 144 ) {
1705 return "";
1706 }
1707 return o100W + "-" + o10W. ToString( "000" ) + "-(" + o1W. ToString( "00" ) + ")-" + o0_5WStr;
1708 }
1709 #endregion
1710 else {
1711 return null;
1712 }
1713 } catch {
1714 throw;
1715 }
1716 }
1717
1718 /// <summary>
1719 /// New mapnumber to old mapnumber 100W
1720 /// </summary>
1721 /// <param name="newMapnumber100WR"></param>
1722 /// <param name="newMapnumber100WC"></param>
1723 /// <returns></returns>
1724 private string NewMapnumberToOldMapnumber_100W( string newMapnumber100WR , string newMapnumber100WC ) {
1725 return newMapnumber100WR + "-" + newMapnumber100WC;
1726 }
1727
1728 #region New mapnumber to old mapnumber calculate row column num 新转旧计算行列号
1729
1730 /// <summary>
1731 /// New mapnumber to old mapnumber calculate num 50W
1732 /// </summary>
1733 private int NewToOld50WNum( string newMapnumber50WR , string newMapnumber50WC ) {
1734 int n50WR = int. Parse( newMapnumber50WR );
1735 int n50WC = int. Parse( newMapnumber50WC );
1736 return 2 * ( n50WR - 1 ) + n50WC;
1737 }
1738
1739 /// <summary>
1740 /// New mapnumber to old mapnumber calculate num 25W
1741 /// </summary>
1742 private int NewToOld25WNum( string newMapnumber25WR , string newMapnumber25WC ) {
1743 int n25WR = int. Parse( newMapnumber25WR );
1744 int n25WC = int. Parse( newMapnumber25WC );
1745 return 4 * ( n25WR - 1 ) + n25WC;
1746 }
1747
1748 /// <summary>
1749 /// New mapnumber to old mapnumber calculate num 10W
1750 /// </summary>
1751 private int NewToOld10WNum( string newMapnumber10WR , string newMapnumber10WC ) {
1752 int n10WR = int. Parse( newMapnumber10WR );
1753 int n10WC = int. Parse( newMapnumber10WC );
1754 return 12 * ( n10WR - 1 ) + n10WC;
1755 }
1756
1757 /// <summary>
1758 /// New mapnumber to old mapnumber calculate num 5W
1759 /// </summary>
1760 private int NewToOld5WNum( string newMapnumber5WR , string newMapnumber5WC ) {
1761 int n5WR = int. Parse( newMapnumber5WR );
1762 int n5WC = int. Parse( newMapnumber5WC );
1763 return 2 * n5WR + n5WC - ( 4 * ( (int) ( n5WR - 1 ) / 2 ) ) - ( 2 * ( (int) ( n5WC - 1 ) / 2 ) ) - 2;
1764 }
1765
1766 /// <summary>
1767 /// New mapnumber to old mapnumber calculate num 2.5W
1768 /// </summary>
1769 private int NewToOld2_5WNum( string newMapnumber2_5WR , string newMapnumber2_5WC ) {
1770 int n2_5WR = int. Parse( newMapnumber2_5WR );
1771 int n2_5WC = int. Parse( newMapnumber2_5WC );
1772 return 2 * n2_5WR + n2_5WC - ( 4 * ( (int) ( n2_5WR - 1 ) / 2 ) ) - ( 2 * ( (int) ( n2_5WC - 1 ) / 2 ) ) - 2;
1773 }
1774
1775 /// <summary>
1776 /// New mapnumber to old mapnumber calculate num 1W
1777 /// </summary>
1778 private int NewToOld1WNum( string newMapnumber1WR , string newMapnumber1WC ) {
1779 int n1WR = int. Parse( newMapnumber1WR );
1780 int n1WC = int. Parse( newMapnumber1WC );
1781 return 8 * n1WR + n1WC - ( 64 * ( (int) ( n1WR - 1 ) / 8 ) ) - ( 8 * ( (int) ( n1WC - 1 ) / 8 ) ) - 8;
1782 }
1783
1784 /// <summary>
1785 /// New mapnumber to old mapnumber calculate num 0.5W
1786 /// </summary>
1787 private int NewToOld0_5WNum( string newMapnumber0_5WR , string newMapnumber0_5WC ) {
1788 int n0_5WR = int. Parse( newMapnumber0_5WR );
1789 int n0_5WC = int. Parse( newMapnumber0_5WC );
1790 return 2 * n0_5WR + n0_5WC - ( 4 * ( (int) ( n0_5WR - 1 ) / 2 ) ) - ( 2 * ( (int) ( n0_5WC - 1 ) / 2 ) ) - 2;
1791 }
1792
1793 /// <summary>
1794 /// 5W New mapnumber row column number to 10W new mapnumber row column
1795 /// </summary>
1796 /// <param name="newMapnumber5WRC"></param>
1797 /// <returns></returns>
1798 private int New5WRCToNew10WRC( int newMapnumber5WRC ) {
1799 return (int) ( ( newMapnumber5WRC - 1 ) / 2 ) + 1;
1800 }
1801
1802 private int New2_5WRCToNew5WRC( int newMapnumber2_5WRC ) {
1803 return (int) ( ( newMapnumber2_5WRC - 1 ) / 2 ) + 1;
1804 }
1805
1806 private int New1WRCToNew10WRC( int newMapnumber1WRC ) {
1807 return (int) ( ( newMapnumber1WRC - 1 ) / 8 ) + 1;
1808 }
1809
1810 private int New0_5WRCToNew1WRC( int newMapnumber0_5WRC ) {
1811 return (int) ( ( newMapnumber0_5WRC - 1 ) / 2 ) + 1;
1812 }
1813
1814 #endregion
1815
1816 #endregion
1817
1818 #region New mapnumber to new mapnumber 新图号转新图号
1819
1820 /// <summary>
1821 /// Newmapnumber to newmapnumber
1822 /// 新图号转新图号
1823 /// </summary>
1824 /// <param name="newMapnumber"></param>
1825 /// <returns></returns>
1826 public string NewMapnumberToNewMapnumber( string newMapnumber ) {
1827 if ( NewMapnumber_Check( newMapnumber ) ) {
1828 return newMapnumber;
1829 }
1830
1831 newMapnumber = newMapnumber. ToUpper();
1832 if ( NewMapnumber_Check( newMapnumber ) ) {
1833 return newMapnumber;
1834 }
1835
1836 return "";
1837 }
1838
1839 #endregion
1840
1841 #region Old mapnumber to old mapnumber 旧图号转旧图号
1842
1843 /// <summary>
1844 /// Old mapnumber to old mapnumber
1845 /// 旧图号转旧图号
1846 /// </summary>
1847 /// <param name="oldMapnumber"></param>
1848 /// <param name="scaleDenominator"></param>
1849 /// <returns></returns>
1850 public string OldMapnumberToOldMapnumber( string oldMapnumber , int scaleDenominator ) {
1851 if ( scaleDenominator == 1000000 ) {
1852 return OldMapnumberToOldMapnumber100W( oldMapnumber );
1853 } else if ( scaleDenominator == 500000 ) {
1854 return OldMapnumberToOldMapnumber50W( oldMapnumber );
1855 } else if ( scaleDenominator == 250000 ) {
1856 return OldMapnumberToOldMapnumber25W( oldMapnumber );
1857 } else if ( scaleDenominator == 100000 ) {
1858 return OldMapnumberToOldMapnumber10W( oldMapnumber );
1859 } else if ( scaleDenominator == 50000 ) {
1860 return OldMapnumberToOldMapnumber5W( oldMapnumber );
1861 } else if ( scaleDenominator == 25000 ) {
1862 return OldMapnumberToOldMapnumber2_5W( oldMapnumber );
1863 } else if ( scaleDenominator == 10000 ) {
1864 return OldMapnumberToOldMapnumber1W( oldMapnumber );
1865 } else if ( scaleDenominator == 5000 ) {
1866 return OldMapnumberToOldMapnumber0_5W( oldMapnumber );
1867 } else {
1868 return "";
1869 }
1870 }
1871
1872 /// <summary>
1873 /// Change old mapnumber char
1874 /// </summary>
1875 /// <param name="oldMapnumber"></param>
1876 /// <returns></returns>
1877 private string ChangeOldMapnumberChar( string oldMapnumber ) {
1878 oldMapnumber = oldMapnumber. Replace( "(" , "" );
1879 oldMapnumber = oldMapnumber. Replace( ")" , "" );
1880 oldMapnumber = oldMapnumber. Replace( "(" , "" );
1881 oldMapnumber = oldMapnumber. Replace( ")" , "" );
1882 oldMapnumber = oldMapnumber. Replace( "【" , "" );
1883 oldMapnumber = oldMapnumber. Replace( "】" , "" );
1884 oldMapnumber = oldMapnumber. Replace( "甲" , "1" );
1885 oldMapnumber = oldMapnumber. Replace( "乙" , "2" );
1886 oldMapnumber = oldMapnumber. Replace( "丙" , "3" );
1887 oldMapnumber = oldMapnumber. Replace( "丁" , "4" );
1888 oldMapnumber = oldMapnumber. Replace( "A" , "1" );
1889 oldMapnumber = oldMapnumber. Replace( "B" , "2" );
1890 oldMapnumber = oldMapnumber. Replace( "C" , "3" );
1891 oldMapnumber = oldMapnumber. Replace( "D" , "4" );
1892 oldMapnumber = oldMapnumber. Replace( "a" , "1" );
1893 oldMapnumber = oldMapnumber. Replace( "b" , "2" );
1894 oldMapnumber = oldMapnumber. Replace( "c" , "3" );
1895 oldMapnumber = oldMapnumber. Replace( "d" , "4" );
1896
1897 oldMapnumber = oldMapnumber. ToUpper();
1898 foreach ( string m100WR in _100W_RowNum ) {
1899 oldMapnumber = oldMapnumber. Replace( m100WR , Change100W_RowStringToDigital( m100WR ). ToString() );
1900 }
1901 return oldMapnumber;
1902 }
1903
1904 /// <summary>
1905 /// Old mapnumber to old mapnumber 100W
1906 /// </summary>
1907 private string OldMapnumberToOldMapnumber100W( string oldMapnumber100W ) {
1908 if ( string. IsNullOrEmpty( oldMapnumber100W ) ) {
1909 return "";
1910 }
1911 if ( OldMapnumber_Check100W( oldMapnumber100W ) ) {
1912 return oldMapnumber100W;
1913 }
1914
1915 oldMapnumber100W = ChangeOldMapnumberChar( oldMapnumber100W );
1916 if ( !oldMapnumber100W. Contains( '-' ) ) {
1917 return "";
1918 }
1919 string[] split = oldMapnumber100W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
1920 int length = split. Length;
1921 if ( length != 2 ) {
1922 return "";
1923 }
1924
1925 int x100R = -1;
1926 if ( !int. TryParse( split[0] , out x100R ) ) {
1927 return "";
1928 }
1929 int x100C = -1;
1930 if ( !int. TryParse( split[1] , out x100C ) ) {
1931 return "";
1932 }
1933
1934 string s100R = Change100W_RowDigitalToString( x100R );
1935 string s100C = x100C. ToString( "00" );
1936 oldMapnumber100W = s100R + "-" + s100C;
1937 if ( OldMapnumber_Check100W( oldMapnumber100W ) ) {
1938 return oldMapnumber100W;
1939 }
1940 return "";
1941 }
1942
1943 /// <summary>
1944 /// Old mapnumber to old mapnumber 50W
1945 /// </summary>
1946 private string OldMapnumberToOldMapnumber50W( string oldMapnumber50W ) {
1947 if ( string. IsNullOrEmpty( oldMapnumber50W ) ) {
1948 return "";
1949 }
1950 if ( OldMapnumber_Check50W( oldMapnumber50W ) ) {
1951 return oldMapnumber50W;
1952 }
1953
1954 oldMapnumber50W = ChangeOldMapnumberChar( oldMapnumber50W );
1955 if ( !oldMapnumber50W. Contains( '-' ) ) {
1956 return "";
1957 }
1958 string[] split = oldMapnumber50W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
1959 int length = split. Length;
1960 if ( length != 3 ) {
1961 return "";
1962 }
1963 string x100 = split[0] + "-" + split[1];
1964 string s100 = OldMapnumberToOldMapnumber100W( x100 );
1965 if ( string. IsNullOrEmpty( s100 ) ) {
1966 return "";
1967 }
1968
1969 int x50 = -1;
1970 if ( !int. TryParse( split[2] , out x50 ) ) {
1971 return "";
1972 }
1973 string s50 = OldMapnumber_Change1234ToABCD( x50 );
1974 oldMapnumber50W = s100 + "-" + s50;
1975 if ( OldMapnumber_Check50W( oldMapnumber50W ) ) {
1976 return oldMapnumber50W;
1977 }
1978 return "";
1979 }
1980
1981 /// <summary>
1982 /// Old mapnumber to old mapnumber 25W
1983 /// </summary>
1984 private string OldMapnumberToOldMapnumber25W( string oldMapnumber25W ) {
1985 if ( string. IsNullOrEmpty( oldMapnumber25W ) ) {
1986 return "";
1987 }
1988 if ( OldMapnumber_Check25W( oldMapnumber25W ) ) {
1989 return oldMapnumber25W;
1990 }
1991
1992 oldMapnumber25W = ChangeOldMapnumberChar( oldMapnumber25W );
1993 if ( !oldMapnumber25W. Contains( '-' ) ) {
1994 return "";
1995 }
1996 string[] split = oldMapnumber25W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
1997 int length = split. Length;
1998 if ( length != 3 ) {
1999 return "";
2000 }
2001 string x100 = split[0] + "-" + split[1];
2002 string s100 = OldMapnumberToOldMapnumber100W( x100 );
2003 if ( string. IsNullOrEmpty( s100 ) ) {
2004 return "";
2005 }
2006
2007 int x25 = -1;
2008 if ( !int. TryParse( split[2] , out x25 ) ) {
2009 return "";
2010 }
2011 string s25 = x25. ToString( "00" );
2012 oldMapnumber25W = s100 + "-[" + s25 + "]";
2013 if ( OldMapnumber_Check25W( oldMapnumber25W ) ) {
2014 return oldMapnumber25W;
2015 }
2016 return "";
2017 }
2018
2019 /// <summary>
2020 /// Old mapnumber to old mapnumber 10W
2021 /// </summary>
2022 private string OldMapnumberToOldMapnumber10W( string oldMapnumber10W ) {
2023 if ( string. IsNullOrEmpty( oldMapnumber10W ) ) {
2024 return "";
2025 }
2026 if ( OldMapnumber_Check10W( oldMapnumber10W ) ) {
2027 return oldMapnumber10W;
2028 }
2029
2030 oldMapnumber10W = ChangeOldMapnumberChar( oldMapnumber10W );
2031 if ( !oldMapnumber10W. Contains( '-' ) ) {
2032 return "";
2033 }
2034 string[] split = oldMapnumber10W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
2035 int length = split. Length;
2036 if ( length != 3 ) {
2037 return "";
2038 }
2039 string x100 = split[0] + "-" + split[1];
2040 string s100 = OldMapnumberToOldMapnumber100W( x100 );
2041 if ( string. IsNullOrEmpty( s100 ) ) {
2042 return "";
2043 }
2044
2045 int x10 = -1;
2046 if ( !int. TryParse( split[2] , out x10 ) ) {
2047 return "";
2048 }
2049 string s10 = x10. ToString( "000" );
2050 oldMapnumber10W = s100 + "-" + s10;
2051 if ( OldMapnumber_Check10W( oldMapnumber10W ) ) {
2052 return oldMapnumber10W;
2053 }
2054 return "";
2055 }
2056
2057 /// <summary>
2058 /// Old mapnumber to old mapnumber 5W
2059 /// </summary>
2060 private string OldMapnumberToOldMapnumber5W( string oldMapnumber5W ) {
2061 if ( string. IsNullOrEmpty( oldMapnumber5W ) ) {
2062 return "";
2063 }
2064 if ( OldMapnumber_Check5W( oldMapnumber5W ) ) {
2065 return oldMapnumber5W;
2066 }
2067
2068 oldMapnumber5W = ChangeOldMapnumberChar( oldMapnumber5W );
2069 if ( !oldMapnumber5W. Contains( '-' ) ) {
2070 return "";
2071 }
2072 string[] split = oldMapnumber5W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
2073 int length = split. Length;
2074 if ( length != 4 ) {
2075 return "";
2076 }
2077 string x10 = split[0] + "-" + split[1] + "-" + split[2];
2078 string s10 = OldMapnumberToOldMapnumber10W( x10 );
2079 if ( string. IsNullOrEmpty( s10 ) ) {
2080 return "";
2081 }
2082
2083 int x5 = -1;
2084 if ( !int. TryParse( split[3] , out x5 ) ) {
2085 return "";
2086 }
2087 string s5 = OldMapnumber_Change1234ToABCD( x5 );
2088 oldMapnumber5W = s10 + "-" + s5;
2089 if ( OldMapnumber_Check5W( oldMapnumber5W ) ) {
2090 return oldMapnumber5W;
2091 }
2092 return "";
2093 }
2094
2095 /// <summary>
2096 /// Old mapnumber to old mapnumber 2.5W
2097 /// </summary>
2098 private string OldMapnumberToOldMapnumber2_5W( string oldMapnumber2_5W ) {
2099 if ( string. IsNullOrEmpty( oldMapnumber2_5W ) ) {
2100 return "";
2101 }
2102 if ( OldMapnumber_Check2_5W( oldMapnumber2_5W ) ) {
2103 return oldMapnumber2_5W;
2104 }
2105
2106 oldMapnumber2_5W = ChangeOldMapnumberChar( oldMapnumber2_5W );
2107 if ( !oldMapnumber2_5W. Contains( '-' ) ) {
2108 return "";
2109 }
2110 string[] split = oldMapnumber2_5W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
2111 int length = split. Length;
2112 if ( length != 5 ) {
2113 return "";
2114 }
2115 string x5 = split[0] + "-" + split[1] + "-" + split[2] + "-" + split[3];
2116 string s5 = OldMapnumberToOldMapnumber5W( x5 );
2117 if ( string. IsNullOrEmpty( s5 ) ) {
2118 return "";
2119 }
2120
2121 int x2_5 = -1;
2122 if ( !int. TryParse( split[4] , out x2_5 ) ) {
2123 return "";
2124 }
2125 string s2_5 = x2_5. ToString();
2126 oldMapnumber2_5W = s5 + "-" + s2_5;
2127 if ( OldMapnumber_Check2_5W( oldMapnumber2_5W ) ) {
2128 return oldMapnumber2_5W;
2129 }
2130 return "";
2131 }
2132
2133 /// <summary>
2134 /// Old mapnumber to old mapnumber 1W
2135 /// </summary>
2136 private string OldMapnumberToOldMapnumber1W( string oldMapnumber1W ) {
2137 if ( string. IsNullOrEmpty( oldMapnumber1W ) ) {
2138 return "";
2139 }
2140 if ( OldMapnumber_Check1W( oldMapnumber1W ) ) {
2141 return oldMapnumber1W;
2142 }
2143
2144 oldMapnumber1W = ChangeOldMapnumberChar( oldMapnumber1W );
2145 if ( !oldMapnumber1W. Contains( '-' ) ) {
2146 return "";
2147 }
2148 string[] split = oldMapnumber1W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
2149 int length = split. Length;
2150 if ( length != 4 ) {
2151 return "";
2152 }
2153 string x10 = split[0] + "-" + split[1] + "-" + split[2];
2154 string s10 = OldMapnumberToOldMapnumber10W( x10 );
2155 if ( string. IsNullOrEmpty( s10 ) ) {
2156 return "";
2157 }
2158
2159 int x1 = -1;
2160 if ( !int. TryParse( split[3] , out x1 ) ) {
2161 return "";
2162 }
2163 string s1 = x1. ToString( "00" );
2164 oldMapnumber1W = s10 + "-(" + s1 + ")";
2165 if ( OldMapnumber_Check1W( oldMapnumber1W ) ) {
2166 return oldMapnumber1W;
2167 }
2168 return "";
2169 }
2170
2171 /// <summary>
2172 /// Old mapnumber to old mapnumber 0.5W
2173 /// </summary>
2174 private string OldMapnumberToOldMapnumber0_5W( string oldMapnumber0_5W ) {
2175 if ( string. IsNullOrEmpty( oldMapnumber0_5W ) ) {
2176 return "";
2177 }
2178 if ( OldMapnumber_Check0_5W( oldMapnumber0_5W ) ) {
2179 return oldMapnumber0_5W;
2180 }
2181
2182 oldMapnumber0_5W = ChangeOldMapnumberChar( oldMapnumber0_5W );
2183 if ( !oldMapnumber0_5W. Contains( '-' ) ) {
2184 return "";
2185 }
2186 string[] split = oldMapnumber0_5W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
2187 int length = split. Length;
2188 if ( length != 5 ) {
2189 return "";
2190 }
2191 string x1 = split[0] + "-" + split[1] + "-" + split[2] + "-(" + split[3] + ")";
2192 string s1 = OldMapnumberToOldMapnumber1W( x1 );
2193 if ( string. IsNullOrEmpty( s1 ) ) {
2194 return "";
2195 }
2196
2197 int x0_5 = -1;
2198 if ( !int. TryParse( split[4] , out x0_5 ) ) {
2199 return "";
2200 }
2201 string s0_5 = OldMapnumber_Change1234Toabcd( x0_5 );
2202 oldMapnumber0_5W = s1 + "-" + s0_5;
2203 if ( OldMapnumber_Check0_5W( oldMapnumber0_5W ) ) {
2204 return oldMapnumber0_5W;
2205 }
2206 return "";
2207 }
2208
2209 #endregion
2210
2211
2212 #endregion
2213
2214
2215 #region Exchange between mapnumber and coordinate 图幅号和坐标的转换
2216
2217 #region Mapnumber to coordinate 图号转坐标
2218
2219 #region New mapnumber to coordinate 新图号转坐标
2220
2221 /// <summary>
2222 /// Calculate West North East South coordinate from new mapnumber
2223 /// 从新图幅号计算图廓“西北东南”坐标([0]W [1]N [2]E [3]S)
2224 /// </summary>
2225 /// <param name="newMapnumber"></param>
2226 /// <returns></returns>
2227 public decimal[] CalculateLongitudeLatitudeFromNewMapnumber( string newMapnumber ) {
2228 try {
2229 decimal[] WNES = new decimal[4];
2230 string[] newMapnumberInfo = GetInfoFromNewMapnumber( newMapnumber );
2231 if ( newMapnumberInfo == null ) {
2232 return null;
2233 }
2234 string n100WR = newMapnumberInfo[0];
2235 string n100WC = newMapnumberInfo[1];
2236 string nScaleStr = newMapnumberInfo[2];
2237 string nR = newMapnumberInfo[3];
2238 string nC = newMapnumberInfo[4];
2239 int scaleNumber = NewMapnumber_GetScaleDenominatorNumberByScaleStr( nScaleStr );
2240 if ( scaleNumber == -1 ) {
2241 return null;
2242 }
2243 #region 100万
2244 else if ( scaleNumber == 1000000 ) {
2245 decimal W = CalculateLongitudeLatitudeFromNewMapnumberWest( n100WC , _100W_LatitudeDifference , "0" , 0 );
2246 decimal S = CalculateLongitudeLatitudeFromNewMapnumberSouth( n100WR , _100W_LongitudeDifference , "0" , 0 );
2247 decimal N = S + _100W_LongitudeDifference;
2248 decimal E = W + _100W_LatitudeDifference;
2249 WNES[0] = W;
2250 WNES[1] = N;
2251 WNES[2] = E;
2252 WNES[3] = S;
2253 return WNES;
2254 }
2255 #endregion
2256 #region 50万
2257 else if ( scaleNumber == 500000 ) {
2258 decimal W = CalculateLongitudeLatitudeFromNewMapnumberWest( n100WC , _100W_LatitudeDifference , nC , _50W_LongitudeDifference );
2259 decimal S = CalculateLongitudeLatitudeFromNewMapnumberSouth( n100WR , _100W_LongitudeDifference , nR , _50W_LatitudeDifference );
2260 decimal N = S + _50W_LatitudeDifference;
2261 decimal E = W + _50W_LongitudeDifference;
2262 WNES[0] = W;
2263 WNES[1] = N;
2264 WNES[2] = E;
2265 WNES[3] = S;
2266 return WNES;
2267 }
2268 #endregion
2269 #region 25万
2270 else if ( scaleNumber == 250000 ) {
2271 decimal W = CalculateLongitudeLatitudeFromNewMapnumberWest( n100WC , _100W_LatitudeDifference , nC , _25W_LongitudeDifference );
2272 decimal S = CalculateLongitudeLatitudeFromNewMapnumberSouth( n100WR , _100W_LongitudeDifference , nR , _25W_LatitudeDifference );
2273 decimal N = S + _25W_LatitudeDifference;
2274 decimal E = W + _25W_LongitudeDifference;
2275 WNES[0] = W;
2276 WNES[1] = N;
2277 WNES[2] = E;
2278 WNES[3] = S;
2279 return WNES;
2280 }
2281 #endregion
2282 #region 10万
2283 else if ( scaleNumber == 100000 ) {
2284 decimal W = CalculateLongitudeLatitudeFromNewMapnumberWest( n100WC , _100W_LatitudeDifference , nC , _10W_LongitudeDifference );
2285 decimal S = CalculateLongitudeLatitudeFromNewMapnumberSouth( n100WR , _100W_LongitudeDifference , nR , _10W_LatitudeDifference );
2286 decimal N = S + _10W_LatitudeDifference;
2287 decimal E = W + _10W_LongitudeDifference;
2288 WNES[0] = W;
2289 WNES[1] = N;
2290 WNES[2] = E;
2291 WNES[3] = S;
2292 return WNES;
2293 }
2294 #endregion
2295 #region 5万
2296 else if ( scaleNumber == 50000 ) {
2297 decimal W = CalculateLongitudeLatitudeFromNewMapnumberWest( n100WC , _100W_LatitudeDifference , nC , _5W_LongitudeDifference );
2298 decimal S = CalculateLongitudeLatitudeFromNewMapnumberSouth( n100WR , _100W_LongitudeDifference , nR , _5W_LatitudeDifference );
2299 decimal N = S + _5W_LatitudeDifference;
2300 decimal E = W + _5W_LongitudeDifference;
2301 WNES[0] = W;
2302 WNES[1] = N;
2303 WNES[2] = E;
2304 WNES[3] = S;
2305 return WNES;
2306 }
2307 #endregion
2308 #region 2.5万
2309 else if ( scaleNumber == 25000 ) {
2310 decimal W = CalculateLongitudeLatitudeFromNewMapnumberWest( n100WC , _100W_LatitudeDifference , nC , _2_5W_LongitudeDifference );
2311 decimal S = CalculateLongitudeLatitudeFromNewMapnumberSouth( n100WR , _100W_LongitudeDifference , nR , _2_5W_LatitudeDifference );
2312 decimal N = S + _2_5W_LatitudeDifference;
2313 decimal E = W + _2_5W_LongitudeDifference;
2314 WNES[0] = W;
2315 WNES[1] = N;
2316 WNES[2] = E;
2317 WNES[3] = S;
2318 return WNES;
2319 }
2320 #endregion
2321 #region 1万
2322 else if ( scaleNumber == 10000 ) {
2323 decimal W = CalculateLongitudeLatitudeFromNewMapnumberWest( n100WC , _100W_LatitudeDifference , nC , _1W_LongitudeDifference );
2324 decimal S = CalculateLongitudeLatitudeFromNewMapnumberSouth( n100WR , _100W_LongitudeDifference , nR , _1W_LatitudeDifference );
2325 decimal N = S + _1W_LatitudeDifference;
2326 decimal E = W + _1W_LongitudeDifference;
2327 WNES[0] = W;
2328 WNES[1] = N;
2329 WNES[2] = E;
2330 WNES[3] = S;
2331 return WNES;
2332 }
2333 #endregion
2334 #region 5000
2335 else if ( scaleNumber == 5000 ) {
2336 decimal W = CalculateLongitudeLatitudeFromNewMapnumberWest( n100WC , _100W_LatitudeDifference , nC , _0_5W_LongitudeDifference );
2337 decimal S = CalculateLongitudeLatitudeFromNewMapnumberSouth( n100WR , _100W_LongitudeDifference , nR , _0_5W_LatitudeDifference );
2338 decimal N = S + _0_5W_LatitudeDifference;
2339 decimal E = W + _0_5W_LongitudeDifference;
2340 WNES[0] = W;
2341 WNES[1] = N;
2342 WNES[2] = E;
2343 WNES[3] = S;
2344 return WNES;
2345 }
2346 #endregion
2347 #region 2000
2348 else if ( scaleNumber == 2000 ) {
2349 decimal W = CalculateLongitudeLatitudeFromNewMapnumberWest( n100WC , _100W_LatitudeDifference , nC , _0_2W_LongitudeDifference );
2350 decimal S = CalculateLongitudeLatitudeFromNewMapnumberSouth( n100WR , _100W_LongitudeDifference , nR , _0_2W_LatitudeDifference );
2351 decimal N = S + _0_2W_LatitudeDifference;
2352 decimal E = W + _0_2W_LongitudeDifference;
2353 WNES[0] = W;
2354 WNES[1] = N;
2355 WNES[2] = E;
2356 WNES[3] = S;
2357 return WNES;
2358 }
2359 #endregion
2360 #region 1000
2361 else if ( scaleNumber == 1000 ) {
2362 decimal W = CalculateLongitudeLatitudeFromNewMapnumberWest( n100WC , _100W_LatitudeDifference , nC , _0_1W_LongitudeDifference );
2363 decimal S = CalculateLongitudeLatitudeFromNewMapnumberSouth( n100WR , _100W_LongitudeDifference , nR , _0_1W_LatitudeDifference );
2364 decimal N = S + _0_1W_LatitudeDifference;
2365 decimal E = W + _0_1W_LongitudeDifference;
2366 WNES[0] = W;
2367 WNES[1] = N;
2368 WNES[2] = E;
2369 WNES[3] = S;
2370 return WNES;
2371 }
2372 #endregion
2373 #region 500
2374 else if ( scaleNumber == 500 ) {
2375 decimal W = CalculateLongitudeLatitudeFromNewMapnumberWest( n100WC , _100W_LatitudeDifference , nC , _500_LongitudeDifference );
2376 decimal S = CalculateLongitudeLatitudeFromNewMapnumberSouth( n100WR , _100W_LongitudeDifference , nR , _500_LatitudeDifference );
2377 decimal N = S + _500_LatitudeDifference;
2378 decimal E = W + _500_LongitudeDifference;
2379 WNES[0] = W;
2380 WNES[1] = N;
2381 WNES[2] = E;
2382 WNES[3] = S;
2383 return WNES;
2384 }
2385 #endregion
2386 else {
2387 return null;
2388 }
2389 } catch {
2390 throw;
2391 }
2392 }
2393
2394 /// <summary>
2395 /// Calculate West coordinate from new mapnumber
2396 /// </summary>
2397 private decimal CalculateLongitudeLatitudeFromNewMapnumberWest( string newMapnumber_100W_Column , decimal newMapnumber_100W_LongitudeDifference ,
2398 string subColumn , decimal subLongitudeDifference ) {
2399 try {
2400 if ( string. IsNullOrEmpty( newMapnumber_100W_Column ) ) {
2401 return 0;
2402 }
2403 if ( string. IsNullOrEmpty( subColumn ) ) {
2404 subColumn = "0";
2405 }
2406 decimal n100WC_d = decimal. Parse( newMapnumber_100W_Column );
2407 decimal subC_d = decimal. Parse( subColumn );
2408 decimal x = ( n100WC_d - 31 ) * newMapnumber_100W_LongitudeDifference + ( subC_d - 1 ) * subLongitudeDifference;
2409 return x;
2410 } catch {
2411 throw;
2412 }
2413 }
2414
2415 /// <summary>
2416 /// Calculate South coordinate from new mapnumber
2417 /// </summary>
2418 private decimal CalculateLongitudeLatitudeFromNewMapnumberSouth( string newMapnumber_100W_Row , decimal newMapnumber_100W_LatitudeDifference ,
2419 string subRow , decimal subLatitudeDifference ) {
2420 try {
2421 if ( string. IsNullOrEmpty( newMapnumber_100W_Row ) ) {
2422 return 0;
2423 }
2424 if ( string. IsNullOrEmpty( subRow ) ) {
2425 subRow = "0";
2426 }
2427 int n100WRInt = Change100W_RowStringToDigital( newMapnumber_100W_Row );
2428 if ( n100WRInt == -1 ) {
2429 return 0;
2430 }
2431 decimal n100WR_d = decimal. Parse( n100WRInt. ToString() );
2432 decimal subR_d = decimal. Parse( subRow );
2433 if ( subLatitudeDifference == 0M ) {
2434 decimal x = ( n100WR_d - 1 ) * newMapnumber_100W_LatitudeDifference;
2435 return x;
2436 } else {
2437 decimal x = ( n100WR_d - 1 ) * newMapnumber_100W_LatitudeDifference + ( newMapnumber_100W_LatitudeDifference / subLatitudeDifference - subR_d ) * subLatitudeDifference;
2438 return x;
2439 }
2440 } catch {
2441 throw;
2442 }
2443 }
2444
2445 #endregion
2446
2447 #region Old mapnumber to coordinate 旧图号转坐标
2448
2449 /// <summary>
2450 /// Calculate West North East South coordinate from old mapnumber
2451 /// 从旧图幅号计算图廓“西北东南”坐标([0]W [1]N [2]E [3]S)
2452 /// </summary>
2453 /// <param name="oldMapnumber"></param>
2454 /// <returns></returns>
2455 public decimal[] CalculateLongitudeLatitudeFromOldMapnumber( string oldMapnumber ) {
2456 try {
2457 string newMapnumber = OldMapnumberToNewMapnumber( oldMapnumber );
2458 if ( string. IsNullOrEmpty( newMapnumber ) ) {
2459 return CalculateLongitudeLatitudeFromNewMapnumber( newMapnumber );
2460 } else {
2461 return CalculateLongitudeLatitudeFromOldMapnumber20W( oldMapnumber );
2462 }
2463 } catch {
2464 throw;
2465 }
2466 }
2467
2468 /// <summary>
2469 /// Calculate West North East South coordinate from 20W old mapnumber
2470 /// 从20万旧图幅号计算图廓“西北东南”坐标([0]W [1]N [2]E [3]S)
2471 /// </summary>
2472 /// <param name="oldMapnumber20W"></param>
2473 /// <returns></returns>
2474 public decimal[] CalculateLongitudeLatitudeFromOldMapnumber20W( string oldMapnumber20W ) {
2475 try {
2476 if ( !OldMapnumber_Check20W( oldMapnumber20W ) ) {
2477 return null;
2478 }
2479 decimal[] WNES = new decimal[4];
2480 string[] split = oldMapnumber20W. Split( new char[] { '-' } , StringSplitOptions. RemoveEmptyEntries );
2481 string o100WR = split[0];
2482 string o100WC = split[1];
2483 string o20W = split[2];
2484 string[] subSplit = o20W. Split( new char[] { '(' , ')' } , StringSplitOptions. RemoveEmptyEntries );
2485 string o20WNum = subSplit[0];
2486 decimal o100WW = CalculateLongitudeLatitudeFromNewMapnumberWest( o100WC , _100W_LatitudeDifference , "0" , 0 );
2487 decimal o100WS = CalculateLongitudeLatitudeFromNewMapnumberSouth( o100WR , _100W_LongitudeDifference , "0" , 0 );
2488 int i20WNum = int. Parse( o20WNum );
2489 int o20WR = Old20WR( i20WNum );
2490 int o20WC = Old20WC( i20WNum );
2491 decimal W = o100WW + ( o20WC - 1 ) * _20W_LongitudeDifference;
2492 decimal S = o100WS + ( oldMapnumber_20W_RCNum - o20WR ) * _20W_LatitudeDifference;
2493 decimal N = S + _20W_LatitudeDifference;
2494 decimal E = W + _20W_LongitudeDifference;
2495 WNES[0] = W;
2496 WNES[1] = N;
2497 WNES[2] = E;
2498 WNES[3] = S;
2499 return WNES;
2500 } catch {
2501 throw;
2502 }
2503 }
2504
2505 private int Old20WR( int o20WNum ) {
2506 return ( ( o20WNum - 1 ) / oldMapnumber_20W_RCNum ) + 1;
2507 }
2508 private int Old20WC( int o20WNum ) {
2509 return ( ( o20WNum - 1 ) % oldMapnumber_20W_RCNum ) + 1;
2510 }
2511
2512 #endregion
2513
2514 #endregion
2515
2516 #region Coordinate to mapnumber 坐标转图号
2517
2518 #region Coordinate to new mapnumber 坐标转新图号
2519
2520 /// <summary>
2521 /// Coordinate to new mapnumber
2522 /// 从经纬度计算所在新图幅号
2523 /// </summary>
2524 /// <param name="longitude">longitude/经度</param>
2525 /// <param name="latitude">latitude/纬度</param>
2526 /// <param name="scaleDenominator">scaleDenominator/比例尺分母</param>
2527 /// <returns></returns>
2528 public string CalculateNewMapnumberFromLongitudeLatitude( decimal longitude , decimal latitude , int scaleDenominator ) {
2529 try {
2530 string newMapnumber_100W = CalculateNewMapnumberFromLongitudeLatitude100W( longitude , latitude );
2531 if ( string. IsNullOrEmpty( newMapnumber_100W ) ) {
2532 return "";
2533 }
2534 decimal[] longitudeLatitudeDifference = GetLongitudeLatitudeDifference( scaleDenominator );
2535 decimal longitudeDifference = longitudeLatitudeDifference[0];
2536 decimal latitudeDifference = longitudeLatitudeDifference[1];
2537
2538 int[] subRC = CalculateNewMapnumberRowColumnIn100WFromLongitudeLatitude( longitude , latitude , longitudeDifference , latitudeDifference );
2539 string scaleStr = GetNewMapnumberScaleString( scaleDenominator );
2540 string r = "";
2541 string c = "";
2542 if ( scaleStr == "J" || scaleStr == "K" ) {
2543 r = subRC[0]. ToString( "0000" );
2544 c = subRC[1]. ToString( "0000" );
2545 } else {
2546 r = subRC[0]. ToString( "000" );
2547 c = subRC[1]. ToString( "000" );
2548 }
2549 if ( string. IsNullOrEmpty( scaleStr ) ) {
2550 scaleStr = "";
2551 r = "";
2552 c = "";
2553 }
2554 string newMapnumber = newMapnumber_100W + scaleStr + r + c;
2555 if ( NewMapnumber_Check( newMapnumber ) ) {
2556 return newMapnumber;
2557 } else {
2558 return "";
2559 }
2560 } catch {
2561 throw;
2562 }
2563 }
2564
2565 /// <summary>
2566 /// Coordinate to 100W new mapnumber
2567 /// 从经纬度计算所在100万新图幅号
2568 /// </summary>
2569 /// <param name="longitude"></param>
2570 /// <param name="latitude"></param>
2571 /// <returns></returns>
2572 public string CalculateNewMapnumberFromLongitudeLatitude100W( decimal longitude , decimal latitude ) {
2573 try {
2574 int rNum = (int) ( latitude / _100W_LongitudeDifference ) + 1;
2575 int cNum = (int) ( longitude / _100W_LatitudeDifference ) + 31;
2576 string rStr = Change100W_RowDigitalToString( rNum );
2577 string n100W = rStr + cNum. ToString( "00" );
2578 if ( NewMapnumber_Check( n100W ) ) {
2579 return n100W;
2580 } else {
2581 return "";
2582 }
2583 } catch {
2584 throw;
2585 }
2586 }
2587
2588 /// <summary>
2589 /// Coordinate to 50W new mapnumber
2590 /// 从经纬度计算所在50万新图幅号
2591 /// </summary>
2592 /// <param name="longitude"></param>
2593 /// <param name="latitude"></param>
2594 /// <returns></returns>
2595 public string CalculateNewMapnumberFromLongitudeLatitude50W( decimal longitude , decimal latitude ) {
2596 try {
2597 string n100W = CalculateNewMapnumberFromLongitudeLatitude100W( longitude , latitude );
2598 if ( string. IsNullOrEmpty( n100W ) ) {
2599 return "";
2600 }
2601 int[] subRC = CalculateNewMapnumberRowColumnIn100WFromLongitudeLatitude( longitude , latitude , _50W_LongitudeDifference , _50W_LatitudeDifference );
2602 string r = subRC[0]. ToString( "000" );
2603 string c = subRC[1]. ToString( "000" );
2604 string n50W = n100W + "B" + r + c;
2605 if ( NewMapnumber_Check( n50W ) ) {
2606 return n50W;
2607 } else {
2608 return "";
2609 }
2610 } catch {
2611 throw;
2612 }
2613 }
2614
2615 /// <summary>
2616 /// Coordinate to 25W new mapnumber
2617 /// 从经纬度计算所在25万新图幅号
2618 /// </summary>
2619 /// <param name="longitude"></param>
2620 /// <param name="latitude"></param>
2621 /// <returns></returns>
2622 public string CalculateNewMapnumberFromLongitudeLatitude25W( decimal longitude , decimal latitude ) {
2623 try {
2624 string n100W = CalculateNewMapnumberFromLongitudeLatitude100W( longitude , latitude );
2625 if ( string. IsNullOrEmpty( n100W ) ) {
2626 return "";
2627 }
2628 int[] subRC = CalculateNewMapnumberRowColumnIn100WFromLongitudeLatitude( longitude , latitude , _25W_LongitudeDifference , _25W_LatitudeDifference );
2629 string r = subRC[0]. ToString( "000" );
2630 string c = subRC[1]. ToString( "000" );
2631 string n25W = n100W + "C" + r + c;
2632 if ( NewMapnumber_Check( n25W ) ) {
2633 return n25W;
2634 } else {
2635 return "";
2636 }
2637 } catch {
2638 throw;
2639 }
2640 }
2641
2642 /// <summary>
2643 /// Coordinate to 10W new mapnumber
2644 /// 从经纬度计算所在10万新图幅号
2645 /// </summary>
2646 /// <param name="longitude"></param>
2647 /// <param name="latitude"></param>
2648 /// <returns></returns>
2649 public string CalculateNewMapnumberFromLongitudeLatitude10W( decimal longitude , decimal latitude ) {
2650 try {
2651 string n100W = CalculateNewMapnumberFromLongitudeLatitude100W( longitude , latitude );
2652 if ( string. IsNullOrEmpty( n100W ) ) {
2653 return "";
2654 }
2655 int[] subRC = CalculateNewMapnumberRowColumnIn100WFromLongitudeLatitude( longitude , latitude , _10W_LongitudeDifference , _10W_LatitudeDifference );
2656 string r = subRC[0]. ToString( "000" );
2657 string c = subRC[1]. ToString( "000" );
2658 string n10W = n100W + "D" + r + c;
2659 if ( NewMapnumber_Check( n10W ) ) {
2660 return n10W;
2661 } else {
2662 return "";
2663 }
2664 } catch {
2665 throw;
2666 }
2667 }
2668
2669 /// <summary>
2670 /// Coordinate to 5W new mapnumber
2671 /// 从经纬度计算所在5万新图幅号
2672 /// </summary>
2673 /// <param name="longitude"></param>
2674 /// <param name="latitude"></param>
2675 /// <returns></returns>
2676 public string CalculateNewMapnumberFromLongitudeLatitude5W( decimal longitude , decimal latitude ) {
2677 try {
2678 string n100W = CalculateNewMapnumberFromLongitudeLatitude100W( longitude , latitude );
2679 if ( string. IsNullOrEmpty( n100W ) ) {
2680 return "";
2681 }
2682 int[] subRC = CalculateNewMapnumberRowColumnIn100WFromLongitudeLatitude( longitude , latitude , _5W_LongitudeDifference , _5W_LatitudeDifference );
2683 string r = subRC[0]. ToString( "000" );
2684 string c = subRC[1]. ToString( "000" );
2685 string n5W = n100W + "E" + r + c;
2686 if ( NewMapnumber_Check( n5W ) ) {
2687 return n5W;
2688 } else {
2689 return "";
2690 }
2691 } catch {
2692 throw;
2693 }
2694 }
2695
2696 /// <summary>
2697 /// Coordinate to 2.5W new mapnumber
2698 /// 从经纬度计算所在2.5万新图幅号
2699 /// </summary>
2700 /// <param name="longitude"></param>
2701 /// <param name="latitude"></param>
2702 /// <returns></returns>
2703 public string CalculateNewMapnumberFromLongitudeLatitude2_5W( decimal longitude , decimal latitude ) {
2704 try {
2705 string n100W = CalculateNewMapnumberFromLongitudeLatitude100W( longitude , latitude );
2706 if ( string. IsNullOrEmpty( n100W ) ) {
2707 return "";
2708 }
2709 int[] subRC = CalculateNewMapnumberRowColumnIn100WFromLongitudeLatitude( longitude , latitude , _2_5W_LongitudeDifference , _2_5W_LatitudeDifference );
2710 string r = subRC[0]. ToString( "000" );
2711 string c = subRC[1]. ToString( "000" );
2712 string n2_5W = n100W + "F" + r + c;
2713 if ( NewMapnumber_Check( n2_5W ) ) {
2714 return n2_5W;
2715 } else {
2716 return "";
2717 }
2718 } catch {
2719 throw;
2720 }
2721 }
2722
2723 /// <summary>
2724 /// Coordinate to 1W new mapnumber
2725 /// 从经纬度计算所在1万新图幅号
2726 /// </summary>
2727 /// <param name="longitude"></param>
2728 /// <param name="latitude"></param>
2729 /// <returns></returns>
2730 public string CalculateNewMapnumberFromLongitudeLatitude1W( decimal longitude , decimal latitude ) {
2731 try {
2732 string n100W = CalculateNewMapnumberFromLongitudeLatitude100W( longitude , latitude );
2733 if ( string. IsNullOrEmpty( n100W ) ) {
2734 return "";
2735 }
2736 int[] subRC = CalculateNewMapnumberRowColumnIn100WFromLongitudeLatitude( longitude , latitude , _1W_LongitudeDifference , _1W_LatitudeDifference );
2737 string r = subRC[0]. ToString( "000" );
2738 string c = subRC[1]. ToString( "000" );
2739 string n1W = n100W + "G" + r + c;
2740 if ( NewMapnumber_Check( n1W ) ) {
2741 return n1W;
2742 } else {
2743 return "";
2744 }
2745 } catch {
2746 throw;
2747 }
2748 }
2749
2750 /// <summary>
2751 /// Coordinate to 0.5W new mapnumber
2752 /// 从经纬度计算所在0.5万新图幅号
2753 /// </summary>
2754 /// <param name="longitude"></param>
2755 /// <param name="latitude"></param>
2756 /// <returns></returns>
2757 public string CalculateNewMapnumberFromLongitudeLatitude0_5W( decimal longitude , decimal latitude ) {
2758 try {
2759 string n100W = CalculateNewMapnumberFromLongitudeLatitude100W( longitude , latitude );
2760 if ( string. IsNullOrEmpty( n100W ) ) {
2761 return "";
2762 }
2763 int[] subRC = CalculateNewMapnumberRowColumnIn100WFromLongitudeLatitude( longitude , latitude , _0_5W_LongitudeDifference , _0_5W_LatitudeDifference );
2764 string r = subRC[0]. ToString( "000" );
2765 string c = subRC[1]. ToString( "000" );
2766 string n0_5W = n100W + "H" + r + c;
2767 if ( NewMapnumber_Check( n0_5W ) ) {
2768 return n0_5W;
2769 } else {
2770 return "";
2771 }
2772 } catch {
2773 throw;
2774 }
2775 }
2776
2777 /// <summary>
2778 /// Coordinate to 0.2W new mapnumber
2779 /// 从经纬度计算所在0.2万新图幅号
2780 /// </summary>
2781 /// <param name="longitude"></param>
2782 /// <param name="latitude"></param>
2783 /// <returns></returns>
2784 public string CalculateNewMapnumberFromLongitudeLatitude0_2W( decimal longitude , decimal latitude ) {
2785 try {
2786 string n100W = CalculateNewMapnumberFromLongitudeLatitude100W( longitude , latitude );
2787 if ( string. IsNullOrEmpty( n100W ) ) {
2788 return "";
2789 }
2790 int[] subRC = CalculateNewMapnumberRowColumnIn100WFromLongitudeLatitude( longitude , latitude , _0_2W_LongitudeDifference , _0_2W_LatitudeDifference );
2791 string r = subRC[0]. ToString( "000" );
2792 string c = subRC[1]. ToString( "000" );
2793 string n0_2W = n100W + "I" + r + c;
2794 if ( NewMapnumber_Check( n0_2W ) ) {
2795 return n0_2W;
2796 } else {
2797 return "";
2798 }
2799 } catch {
2800 throw;
2801 }
2802 }
2803
2804 /// <summary>
2805 /// Coordinate to 0.1W new mapnumber
2806 /// 从经纬度计算所在0.1万新图幅号
2807 /// </summary>
2808 /// <param name="longitude"></param>
2809 /// <param name="latitude"></param>
2810 /// <returns></returns>
2811 public string CalculateNewMapnumberFromLongitudeLatitude0_1W( decimal longitude , decimal latitude ) {
2812 try {
2813 string n100W = CalculateNewMapnumberFromLongitudeLatitude100W( longitude , latitude );
2814 if ( string. IsNullOrEmpty( n100W ) ) {
2815 return "";
2816 }
2817 int[] subRC = CalculateNewMapnumberRowColumnIn100WFromLongitudeLatitude( longitude , latitude , _0_1W_LongitudeDifference , _0_1W_LatitudeDifference );
2818 string r = subRC[0]. ToString( "0000" );
2819 string c = subRC[1]. ToString( "0000" );
2820 string n0_1W = n100W + "J" + r + c;
2821 if ( NewMapnumber_Check( n0_1W ) ) {
2822 return n0_1W;
2823 } else {
2824 return "";
2825 }
2826 } catch {
2827 throw;
2828 }
2829 }
2830
2831 /// <summary>
2832 /// Coordinate to 500 new mapnumber
2833 /// 从经纬度计算所在500新图幅号
2834 /// </summary>
2835 /// <param name="longitude"></param>
2836 /// <param name="latitude"></param>
2837 /// <returns></returns>
2838 public string CalculateNewMapnumberFromLongitudeLatitude500( decimal longitude , decimal latitude ) {
2839 try {
2840 string n100W = CalculateNewMapnumberFromLongitudeLatitude100W( longitude , latitude );
2841 if ( string. IsNullOrEmpty( n100W ) ) {
2842 return "";
2843 }
2844 int[] subRC = CalculateNewMapnumberRowColumnIn100WFromLongitudeLatitude( longitude , latitude , _500_LongitudeDifference , _500_LatitudeDifference );
2845 string r = subRC[0]. ToString( "0000" );
2846 string c = subRC[1]. ToString( "0000" );
2847 string n500 = n100W + "K" + r + c;
2848 if ( NewMapnumber_Check( n500 ) ) {
2849 return n500;
2850 } else {
2851 return "";
2852 }
2853 } catch {
2854 throw;
2855 }
2856 }
2857
2858 private int[] CalculateNewMapnumberRowColumnIn100WFromLongitudeLatitude( decimal longitude , decimal latitude , decimal JC , decimal WC ) {
2859 int rNum = (int) ( Math. Round( ( _100W_LongitudeDifference / WC ) , MidpointRounding. AwayFromZero ) ) - (int) ( ( latitude % _100W_LongitudeDifference ) / WC );
2860 int cNum = (int) ( (int) ( ( longitude % _100W_LatitudeDifference ) / JC ) ) + 1;
2861
2862 return new int[] { rNum , cNum };
2863 }
2864
2865 #endregion
2866
2867 #region Coordinate to old mapnumber 坐标转旧图号
2868
2869 /// <summary>
2870 /// Coordinate to old mapnumber
2871 /// 从经纬度计算所在旧图幅号
2872 /// </summary>
2873 /// <param name="longitude">经度</param>
2874 /// <param name="latitude">纬度</param>
2875 /// <param name="scaleDenominator">比例尺分母</param>
2876 /// <returns></returns>
2877 public string CalculateOldMapnumberFromLongitudeLatitude( decimal longitude , decimal latitude , int scaleDenominator ) {
2878 try {
2879 string n100W = CalculateNewMapnumberFromLongitudeLatitude100W( longitude , latitude );
2880 if ( string. IsNullOrEmpty( n100W ) ) {
2881 return "";
2882 }
2883 decimal[] jwc = GetLongitudeLatitudeDifference( scaleDenominator );
2884 decimal JC = jwc[0];
2885 decimal WC = jwc[1];
2886 int[] subRC = CalculateNewMapnumberRowColumnIn100WFromLongitudeLatitude( longitude , latitude , JC , WC );
2887 string scaleStr = GetNewMapnumberScaleString( scaleDenominator );
2888 #region 20万
2889 if ( scaleDenominator == 200000 ) {
2890 return CalculateOldMapnumberFromLongitudeLatitude20W( longitude , latitude );
2891 }
2892 #endregion
2893 #region
2894 else {
2895 string r = "";
2896 string c = "";
2897 if ( scaleStr == "J" || scaleStr == "K" ) {
2898 r = subRC[0]. ToString( "0000" );
2899 c = subRC[1]. ToString( "0000" );
2900 } else {
2901 r = subRC[0]. ToString( "000" );
2902 c = subRC[1]. ToString( "000" );
2903 }
2904 if ( string. IsNullOrEmpty( scaleStr ) ) {
2905 scaleStr = "";
2906 r = "";
2907 c = "";
2908 }
2909 string newMapnumber = n100W + scaleStr + r + c;
2910 if ( NewMapnumber_Check( newMapnumber ) ) {
2911 string oldMapnumber = NewMapnumberToOldMapnumber( newMapnumber );
2912 if ( OldMapnumber_Check( oldMapnumber ) ) {
2913 return oldMapnumber;
2914 } else {
2915 return "";
2916 }
2917 } else {
2918 return "";
2919 }
2920 }
2921 #endregion
2922 } catch {
2923 throw;
2924 }
2925 }
2926
2927 /// <summary>
2928 /// Coordinate to 100W old mapnumber
2929 /// 从经纬度计算所在100万旧图幅号
2930 /// </summary>
2931 /// <param name="longitude"></param>
2932 /// <param name="latitude"></param>
2933 /// <returns></returns>
2934 public string CalculateOldMapnumberFromLongitudeLatitude100W( decimal longitude , decimal latitude ) {
2935 try {
2936 int rNum = (int) ( latitude / _100W_LongitudeDifference ) + 1;
2937 int cNum = (int) ( longitude / _100W_LatitudeDifference ) + 31;
2938 string rStr = Change100W_RowDigitalToString( rNum );
2939 string o100W = rStr + "-" + cNum. ToString( "00" );
2940 if ( OldMapnumber_Check100W( o100W ) ) {
2941 return o100W;
2942 } else {
2943 return "";
2944 }
2945 } catch {
2946 throw;
2947 }
2948 }
2949
2950 /// <summary>
2951 /// Coordinate to 20W old mapnumber
2952 /// 从经纬度计算所在20万旧图幅号
2953 /// </summary>
2954 /// <param name="longitude"></param>
2955 /// <param name="latitude"></param>
2956 /// <returns></returns>
2957 public string CalculateOldMapnumberFromLongitudeLatitude20W( decimal longitude , decimal latitude ) {
2958 try {
2959 string o100W = CalculateOldMapnumberFromLongitudeLatitude100W( longitude , latitude );
2960 if ( string. IsNullOrEmpty( o100W ) ) {
2961 return "";
2962 }
2963 int[] subRC = CalculateNewMapnumberRowColumnIn100WFromLongitudeLatitude( longitude , latitude , _20W_LongitudeDifference , _20W_LatitudeDifference );
2964 int o20WNum = O20WNum( subRC[0] , subRC[1] );
2965 string o20W = o100W + "-(" + o20WNum. ToString( "00" ) + ")";
2966 if ( OldMapnumber_Check20W( o20W ) ) {
2967 return o20W;
2968 } else {
2969 return "";
2970 }
2971 } catch {
2972 throw;
2973 }
2974 }
2975
2976 private int O20WNum( int n20WR , int n20WC ) {
2977 return oldMapnumber_20W_RCNum * ( n20WR - 1 ) + n20WC;
2978 }
2979
2980 #endregion
2981
2982 #endregion
2983
2984 #endregion
2985
2986
2987 #region Other 其他
2988
2989 /// <summary>
2990 /// Get 100W Row/100W Column/ScaleStr/Rownum/Columnnum from new mapnumber
2991 /// 从新图号获得比例尺、行列号信息([0]:百万行;[1]:百万咧;[2]:比例尺代码;[3]:行号;[4]:列号)
2992 /// </summary>
2993 /// <param name="newMapnumber"></param>
2994 /// <returns></returns>
2995 public string[] GetInfoFromNewMapnumber( string newMapnumber ) {
2996 try {
2997 string[] strs = new string[5];
2998 if ( !NewMapnumber_Check( newMapnumber ) ) {
2999 return null;
3000 }
3001 int length = newMapnumber. Length;
3002 string n100WR = "";
3003 string n100WC = "";
3004 string nScaleStr = "";
3005 string nR = "";
3006 string nC = "";
3007 if ( length == 3 ) {
3008 n100WR = newMapnumber. Substring( 0 , 1 );
3009 n100WC = newMapnumber. Substring( 1 , 2 );
3010 } else {
3011 n100WR = newMapnumber. Substring( 0 , 1 );
3012 n100WC = newMapnumber. Substring( 1 , 2 );
3013 nScaleStr = newMapnumber. Substring( 3 , 1 );
3014 if ( length == 10 ) {
3015 nR = newMapnumber. Substring( 4 , 3 );
3016 nC = newMapnumber. Substring( 7 , 3 );
3017 } else {
3018 nR = newMapnumber. Substring( 4 , 4 );
3019 nC = newMapnumber. Substring( 8 , 4 );
3020 }
3021 }
3022 if ( !string. IsNullOrEmpty( n100WR ) && !string. IsNullOrEmpty( n100WC ) ) {
3023 strs[0] = n100WR;
3024 strs[1] = n100WC;
3025 strs[2] = nScaleStr;
3026 strs[3] = nR;
3027 strs[4] = nC;
3028 return strs;
3029 }
3030 return null;
3031 } catch {
3032 throw;
3033 }
3034 }
3035
3036 /// <summary>
3037 /// Get longitude and latitude difference from scale denominator
3038 /// 从比例尺分母获得经差、纬差 [0]:经差;[1]:纬差
3039 /// </summary>
3040 /// <param name="scaleDenominator"></param>
3041 /// <returns></returns>
3042 public decimal[] GetLongitudeLatitudeDifference( int scaleDenominator ) {
3043 switch ( scaleDenominator ) {
3044 case 1000000:
3045 return new decimal[] { _100W_LatitudeDifference , _100W_LongitudeDifference };
3046 case 500000:
3047 return new decimal[] { _50W_LongitudeDifference , _50W_LatitudeDifference };
3048 case 250000:
3049 return new decimal[] { _25W_LongitudeDifference , _25W_LatitudeDifference };
3050 case 200000:
3051 return new decimal[] { _20W_LongitudeDifference , _20W_LatitudeDifference };
3052 case 100000:
3053 return new decimal[] { _10W_LongitudeDifference , _10W_LatitudeDifference };
3054 case 50000:
3055 return new decimal[] { _5W_LongitudeDifference , _5W_LatitudeDifference };
3056 case 25000:
3057 return new decimal[] { _2_5W_LongitudeDifference , _2_5W_LatitudeDifference };
3058 case 10000:
3059 return new decimal[] { _1W_LongitudeDifference , _1W_LatitudeDifference };
3060 case 5000:
3061 return new decimal[] { _0_5W_LongitudeDifference , _0_5W_LatitudeDifference };
3062 case 2000:
3063 return new decimal[] { _0_2W_LongitudeDifference , _0_2W_LatitudeDifference };
3064 case 1000:
3065 return new decimal[] { _0_1W_LongitudeDifference , _0_1W_LatitudeDifference };
3066 case 500:
3067 return new decimal[] { _500_LongitudeDifference , _500_LatitudeDifference };
3068 default:
3069 return null;
3070 }
3071 }
3072
3073 /// <summary>
3074 /// Get scale str from scale denominator
3075 /// 从比例尺分母获得新图号中的比例尺代码
3076 /// </summary>
3077 /// <param name="scaleDenominator"></param>
3078 /// <returns></returns>
3079 public string GetNewMapnumberScaleString( int scaleDenominator ) {
3080 switch ( scaleDenominator ) {
3081 case 1000000:
3082 return "";
3083 case 500000:
3084 return "B";
3085 case 250000:
3086 return "C";
3087 case 100000:
3088 return "D";
3089 case 50000:
3090 return "E";
3091 case 25000:
3092 return "F";
3093 case 10000:
3094 return "G";
3095 case 5000:
3096 return "H";
3097 case 2000:
3098 return "I";
3099 case 1000:
3100 return "J";
3101 case 500:
3102 return "K";
3103 default:
3104 return null;
3105 }
3106 }
3107
3108 /// <summary>
3109 /// Get polygon from new mapnumber
3110 /// 根据图号,生成面图形
3111 /// </summary>
3112 /// <param name="newMapnumber"></param>
3113 /// <returns></returns>
3114 //public ESRI.ArcGIS.Geometry.IGeometry GetPolygonGeometryFromNewMapnumber( string newMapnumber ) {
3115 // if ( NewMapnumber_Check( newMapnumber ) ) {
3116 // decimal[] coor = CalculateLongitudeLatitudeFromNewMapnumber( newMapnumber );
3117 // if ( coor != null ) {
3118 // ESRI.ArcGIS.Geometry.Ring ring = new ESRI.ArcGIS.Geometry.RingClass();
3119
3120 // ESRI.ArcGIS.Geometry.Point p1 = new ESRI.ArcGIS.Geometry.PointClass();
3121 // p1. PutCoords( decimal. ToDouble( coor[0] ) , decimal. ToDouble( coor[1] ) );
3122 // ring. AddPoint( p1 );
3123
3124 // ESRI. ArcGIS. Geometry. Point p2 = new ESRI. ArcGIS. Geometry. PointClass();
3125 // p2. PutCoords( decimal. ToDouble( coor[0] ) , decimal. ToDouble( coor[3] ) );
3126 // ring. AddPoint( p2 );
3127
3128 // ESRI. ArcGIS. Geometry. Point p3 = new ESRI. ArcGIS. Geometry. PointClass();
3129 // p3. PutCoords( decimal. ToDouble( coor[2] ) , decimal. ToDouble( coor[3] ) );
3130 // ring. AddPoint( p3 );
3131
3132 // ESRI. ArcGIS. Geometry. Point p4 = new ESRI. ArcGIS. Geometry. PointClass();
3133 // p4. PutCoords( decimal. ToDouble( coor[2] ) , decimal. ToDouble( coor[1] ) );
3134 // ring. AddPoint( p4 );
3135
3136 // ring. AddPoint( p1 );
3137
3138 // ESRI.ArcGIS.Geometry.IGeometryCollection pointPolygon = new ESRI.ArcGIS.Geometry.PolygonClass();
3139 // pointPolygon. AddGeometry( ring as ESRI.ArcGIS.Geometry.IGeometry );
3140 // ESRI.ArcGIS.Geometry.IPolygon pPolygon = pointPolygon as ESRI.ArcGIS.Geometry.IPolygon;
3141 // ESRI.ArcGIS.Geometry.IGeometry pGeometry = pPolygon as ESRI.ArcGIS.Geometry.IGeometry;
3142 // return pGeometry;
3143 // }
3144 // }
3145 // return null;
3146 //}
3147
3148
3149 #endregion
3150
3151 }
3152 }

Mapnumber

新旧图号(图幅号)转换/计算/检查,经纬度转换计算,C#代码的更多相关文章

  1. sql server编写通用脚本自动检查两个不同服务器的新旧数据库的表结构差异

    问题:工作过程中,不管是什么项目,伴随着项目不断升级版本,对应的项目数据库业务版本也不断升级,数据库出现新增表.修改表.删除表.新增字段.修改字段.删除字段等变化,如果人工检查,数据库表和字段比较多的 ...

  2. MapReduce简述、工作流程及新旧API对照

    什么是MapReduce? 你想数出一摞牌中有多少张黑桃.直观方式是一张一张检查而且数出有多少张是黑桃. MapReduce方法则是: 1. 给在座的全部玩家中分配这摞牌. 2. 让每一个玩家数自己手 ...

  3. A/B_test改变新旧网页 观察用户的引流效果

    代码处:https://github.com/xubin97/Data-analysis_exp2 分析A/B测试结果 目录 简介 I - 概率 II - A/B 测试 简介 首先这个项目数据来自某公 ...

  4. 渲染路径-Unity5 的新旧推迟渲染Deferred Lighting Rendering Path

    Unity5 的新旧延迟渲染Deferred Lighting Rendering Path unity5 的render path ,比4的区别就是使用的新的deferred rendering,之 ...

  5. 通过经纬度坐标计算距离的方法(经纬度距离计算)ZZ

    通过经纬度坐标计算距离的方法(经纬度距离计算) 最近在网上搜索“通过经纬度坐标计算距离的方法”,发现网上大部分都是如下的代码: #define PI 3.14159265 static double ...

  6. 根据经纬度坐标计算距离-python

    一.两个坐标之间距离计算 参考链接: python实现 1.Python 根据地址获取经纬度及求距离 2.python利用地图两个点的经纬度计算两点间距离 LBS 球面距离公式 美团app筛选“离我最 ...

  7. mysql 下 计算 两点 经纬度 之间的距离 计算结果排序

    根据经纬度计算距离公式 公式 对上面的公式解释如下: Lung1 Lat1表示A点经纬度, Lung2 Lat2表示B点经纬度: a=Lat1 – Lat2 为两点纬度之差 b=Lung1 -Lung ...

  8. sql server新旧数据库的表结构差异

    sql server编写通用脚本自动检查两个不同服务器的新旧数据库的表结构差异 问题:工作过程中,不管是什么项目,伴随着项目不断升级版本,对应的项目数据库业务版本也不断升级,数据库出现新增表.修改表. ...

  9. Android新旧版本Notification

    Android新旧版本Notification 在notification.setLatestEventInfo() 过时了 以前: NotificationManager mn = (Notific ...

随机推荐

  1. Redis SWAPDB 命令背后做了什么

    Redis SWAPDB 命令背后做了什么 目录 Redis SWAPDB 命令背后做了什么 0x00 摘要 0x01 SWAPDB 基础 1.1 命令说明 1.2 演示 0x02 预先校验 0x03 ...

  2. Git 上传基本命令

    注意:操作要保证在对应文件夹中打开Git bash here (例如:clone项目后要cd到文件中,否则报"git提示没有git存储库") 1.创建一个git裸服务器 (git ...

  3. MongoDB(7)- 文档插入操作

    插入方法 db.collection.insertOne() 插入单条文档到集合中 db.collection.insertMany() 插入多条文档到集合中 db.collection.insert ...

  4. 记一次zabbix-server故障恢复导致的事故 zabbix-server.log -- One child process died

    前言 zabbix-server昨天出了个问题,不停的重启.昨天摆弄到晚上也不搞清楚原因,按照网上说的各种操作,各种CacheSize.TimeOut.StartPollers都改了,还有什么Incl ...

  5. CVPR2018论文看点:基于度量学习分类与少镜头目标检测

    CVPR2018论文看点:基于度量学习分类与少镜头目标检测 简介 本文链接地址:https://arxiv.org/pdf/1806.04728.pdf 距离度量学习(DML)已成功地应用于目标分类, ...

  6. CVPR2020行人重识别算法论文解读

    CVPR2020行人重识别算法论文解读 Cross-modalityPersonre-identificationwithShared-SpecificFeatureTransfer 具有特定共享特征变换 ...

  7. NVIDIA DGX SUPERPOD 企业解决方案

    NVIDIA DGX SUPERPOD 企业解决方案 实现大规模 AI 创新的捷径 NVIDIA DGX SuperPOD 企业解决方案是业界首个支持任何组织大规模实施 AI 的基础架构解决方案.这一 ...

  8. 智能驾驶L2发展策略

    智能驾驶L2发展策略 智能驾驶L2,以们通俗的定义是,以高级辅助驾驶的产品为主的各种巡航产品,包括定速巡航,自适应巡航ACC,预见性巡航,智能巡航等等. 车辆驾驶是集注意力高度集中,手把控方向盘和换挡 ...

  9. 多尺度目标检测 Multiscale Object Detection

    多尺度目标检测 Multiscale Object Detection 我们在输入图像的每个像素上生成多个锚框.这些定位框用于对输入图像的不同区域进行采样.但是,如果锚定框是以图像的每个像素为中心生成 ...

  10. Yolov3&Yolov4网络结构与源码分析

    Yolov3&Yolov4网络结构与源码分析 从2018年Yolov3年提出的两年后,在原作者声名放弃更新Yolo算法后,俄罗斯的Alexey大神扛起了Yolov4的大旗. 文章目录 1. 论 ...