[工程师阿伟]正在和[机器小伟]一起研究[疆域的制定]。
厄尔斯星球是一个球体,所以阿伟和小伟就去找了一下关于经纬度的一些计算。
<span style="font-size:18px;"> if (1) { var mathText = new MathText(); //希腊字母表(存此用于Ctrl C/V //ΑΒΓΔΕΖΗ ΘΙΚΛΜΝΞ ΟΠΡ ΣΤΥ ΦΧΨ Ω //αβγδεζη θικλμνξ οπρ στυ φχψ ω //希腊大小写字母 var GreekCaps = 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ'; var GreakSmall = 'αβγδεζηθικλμνξοπρστυφχψω'; c = 'θ'; var s = [ /* 'Half-Versine', ' ', 'AOB = θ => AOC = θ/2', 'AC = sin(θ/2), AB = 2*sin(θ/2)'*/ /* 'AC = BD = 2*sin(d_[lat]/2)', 'EF = 2*sin(d_[lon]/2)', 'AO\' = r_[AD] = cos(lat1)', 'AD = 2*sin(d_[lon]/2)*cos(lat1)', 'CB = 2*sin(d_[lon]/2)*cos(lat2)',*/ 'AH^[2] = AC^[2]-CH^[2] = AC^[2] - (CB-AD)^[2]/4', 'BH = (BC+AD)/2', ' ', 'AB^[2] = AH^[2]+HB^[2] = AC^[2]+CB*AD', ' ', '=> AB^[2] = 4*(sin^[2](d_[lat]/2) + ', ' 4*cos(lat1)*cos(lat2)*sin^[2](d_[lon]/2))', ]; var x =40, y=40; var r1 = 40; var len = s.length; for (var i = 0; i < len; i++) { if (s[i] == '') { if (x < 100) { x += 300; y-=r1*3; } else { x = 20; y += r1; } } else { if (i > 0) { mathText.print(s[i], x, y, 'red', '|'); } else { mathText.print(s[i], x, y, 'red', '|'); } y+=r1; } } }</span>
这样就可以计算出任意两个经纬度坐标之间的距离:
<span style="font-size:18px;">#计算两个经续度之间的距离 def haversine(lon1, lat1, lon2, lat2): # 经度1,纬度1,经度2,纬度2 (十进制度数) """ Calculate the great circle distance between two points on the earth (specified in decimal degrees) """ # 将十进制度数转化为弧度 lon1, lat1, lon2, lat2 = map(math.radians, [lon1, lat1, lon2, lat2]) # haversine公式 dlon = lon2 - lon1 dlat = lat2 - lat1 a = math.sin(dlat/2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon/2)**2 c = 2 * math.asin(math.sqrt(a)) r = 6371 # 地球平均半径,单位为公里 return c * r * 1000 def tmp(): lon1, lat1, lon2, lat2 = 30, 0, 31, 0; d = haversine(lon1, lat1, lon2, lat2); print(d); >>> 111194.92664455889 >>> 111194.92664455889*360 40030173.5920412 def tmp(): lon1, lat1, lon2, lat2 = 30, 30, 31, 30; d = haversine(lon1, lat1, lon2, lat2); print(d); >>> 96297.32567761201</span>
<span style="font-size:18px;"># 计算x千米范围内的的最大最小经纬度 def calcu_location(location_x, location_y, r=1): lat_range = 180 / math.pi * r / 6372.797 # 里面的 1 就代表搜索 1km 之内,单位km long_r = lat_range / math.cos(location_x * math.pi / 180) max_lat = location_x + lat_range # 最大纬度 min_lat = location_x - lat_range # 最小纬度 max_long = location_y + long_r # 最大经度 min_long = location_y - long_r # 最小经度 range_xy = {} range_xy['location_x'] = {'min':min_lat, 'max':max_lat} range_xy['location_y'] = {'min':min_long, 'max':max_long} return range_xy def tmp(): ''' lon1, lat1, lon2, lat2 = 30, 30, 31, 30; d = haversine(lon1, lat1, lon2, lat2); print(d); ''' a = calcu_location(30, 30); print(a); >>> {'location_x': {'min': 29.991009319846047, 'max': 30.008990680153953}, 'location_y': {'min': 29.989618456785834, 'max': 30.010381543214166}}</span>
下面是中华帝国的二级以上城市经纬度坐标:
<span style="font-size:18px;">$Citys = [ //中国二级以上城市地名及经纬度坐标 //格式:[地名,经度E为正,纬度N为正] ['香港市', 115.12, 21.23], ['澳门市', 115.07, 21.33], ['台北市', 121.3, 25.03], ['北京市', 116.24, 39.55], ['上海市', 121.29, 31.14], ['广州', 113.14, 23.08], ['潮阳', 116.36, 23.16], ['潮州', 116.38, 23.4], ['澄海', 116.46, 23.28], ['从化', 113.33, 23.33], ['东莞', 113.45, 23.02], ['恩平', 112.19, 22.12], ['佛山', 113.06, 23.02], ['高明', 112.5, 22.53], ['高要', 112.26, 23.02], ['高州', 110.5, 21.54], ['鹤山', 112.57, 22.46], ['河源', 114.41, 23.43], ['花都', 113.12, 23.23], ['化州', 110.37, 21.39], ['惠阳', 114.28, 22.48], ['惠州', 114.22, 23.05], ['江门', 113.04, 22.35], ['揭阳', 116.21, 22.32], ['开平', 112.4, 22.22], ['乐昌', 113.21, 25.09], ['雷州', 110.04, 20.54], ['廉江', 110.17, 21.37], ['连州', 112.23, 24.48], ['罗定', 111.33, 22.46], ['茂名', 110.53, 21.4], ['梅州', 116.07, 24.19], ['南海', 113.09, 23.01], ['番禺', 113.22, 22.57], ['普宁', 116.1, 23.18], ['清远', 113.01, 23.42], ['三水', 112.52, 23.1], ['汕头', 116.41, 23.22], ['汕尾', 115.21, 22.47], ['韶关', 113.37, 24.48], ['深圳', 114.07, 22.33], ['顺德', 113.15, 22.5], ['四会', 112.41, 23.21], ['台山', 112.48, 22.15], ['吴川', 110.47, 21.26], ['新会', 113.01, 22.32], ['兴宁', 115.43, 24.09], ['阳春', 111.48, 22.1], ['阳江', 111.58, 21.5], ['英德', 113.22, 24.1], ['云浮', 112.02, 22.57], ['增城', 113.49, 23.18], ['湛江', 110.24, 21.11], ['肇庆', 112.27, 23.03], ['中山', 113.22, 22.31], ['珠海', 113.34, 22.17], ['南宁', 108.19, 22.48], ['北海', 109.07, 21.28], ['北流', 110.21, 22.42], ['百色', 106.36, 23.54], ['防城港', 108.2, 21.37], ['贵港', 109.36, 23.06], ['桂林', 110.17, 25.17], ['桂平', 110.04, 23.22], ['河池', 108.03, 24.42], ['合山', 108.52, 23.47], ['柳州', 109.24, 23.19], ['赁祥', 106.44, 22.07], ['钦州', 108.37, 21.57], ['梧州', 111.2, 23.29], ['玉林', 110.09, 22.38], ['宜州', 108.4, 24.28], ['合肥', 117.17, 31.52], ['安庆', 117.02, 30.31], ['蚌埠', 117.21, 32.56], ['亳州', 115.47, 33.52], ['巢湖', 117.52, 31.36], ['滁州', 118.18, 32.18], ['阜阳', 115.48, 32.54], ['贵池', 117.28, 30.39], ['淮北', 116.47, 33.57], ['淮南', 116.58, 32.37], ['黄山', 118.18, 29.43], ['界首', 115.21, 33.15], ['六安', 116.28, 31.44], ['马鞍山', 118.28, 31.43], ['明光', 117.58, 32.47], ['宿州', 116.58, 33.38], ['天长', 118.59, 32.41], ['铜陵', 117.48, 30.56], ['芜湖', 118.22, 31.19], ['宣州', 118.44, 30.57], ['福州', 119.18, 26.05], ['长乐', 119.31, 25.58], ['福安', 119.39, 27.06], ['福清', 119.23, 25.42], ['建瓯', 118.2, 27.03], ['建阳', 118.07, 27.21], ['晋江', 118.35, 24.49], ['龙海', 117.48, 24.26], ['龙岩', 117.01, 25.06], ['南安', 118.23, 24.57], ['南平', 118.1, 26.38], ['宁德', 119.31, 26.39], ['莆田', 119.01, 24.26], ['泉州', 118.36, 24.56], ['三明', 117.36, 26.13], ['邵武', 117.29, 27.2], ['石狮', 118.38, 24.44], ['武夷山', 118.02, 27.46], ['厦门', 118.06, 24.27], ['永安', 117.23, 25.58], ['漳平', 117.24, 25.17], ['漳州', 117.39, 24.31], ['兰州', 103.51, 36.04], ['白银', 104.12, 36.33], ['敦煌', 94.41, 40.08], ['嘉峪关', 98.14, 39.48], ['金昌', 102.1, 38.28], ['酒泉', 98.31, 39.44], ['临夏', 103.12, 35.37], ['平凉', 106.4, 35.32], ['天水', 105.42, 34.37], ['武威', 102.39, 37.56], ['西峰', 107.4, 35.45], ['玉门', 97.35, 39.49], ['张掖', 100.26, 38.56], ['贵阳', 106.42, 26.35], ['安顺', 105.55, 26.14], ['毕节', 105.18, 27.18], ['赤水', 105.42, 28.34], ['都匀', 107.31, 26.15], ['凯里', 107.58, 26.35], ['六盘水', 104.5, 26.35], ['清镇', 106.27, 26.33], ['铜仁', 109.12, 27.43], ['兴义', 104.53, 25.05], ['遵义', 106.55, 27.42], ['海口', 110.2, 20.02], ['儋州', 109.34, 19.31], ['琼海', 110.28, 19.14], ['琼山', 110.21, 19.59], ['三亚', 109.31, 18.14], ['通什', 109.31, 18.46], ['石家庄', 114.3, 38.02], ['安国', 115.2, 38.24], ['保定', 115.3, 38.51], ['霸州', 116.24, 39.06], ['泊头', 116.34, 38.04], ['沧州', 116.52, 38.18], ['承德', 117.57, 40.59], ['定州', 115.0, 38.3], ['丰南', 118.06, 39.34], ['高碑店', 115.51, 39.2], ['蒿城', 114.5, 38.02], ['邯郸', 114.28, 36.36], ['河间', 116.05, 38.26], ['衡水', 115.42, 37.44], ['黄骅', 117.21, 38.21], ['晋州', 115.02, 38.02], ['冀州', 115.33, 37.34], ['廓坊', 116.42, 39.31], ['鹿泉', 114.19, 38.04], ['南宫', 115.23, 37.22], ['秦皇岛', 119.35, 39.55], ['任丘', 116.07, 38.42], ['三河', 117.04, 39.58], ['沙河', 114.3, 36.51], ['深州', 115.32, 38.01], ['唐山', 118.11, 39.36], ['武安', 114.11, 36.42], ['邢台', 114.3, 37.04], ['辛集', 115.12, 37.54], ['新乐', 114.41, 38.2], ['张家口', 114.53, 40.48], ['涿州', 115.59, 39.29], ['遵化', 117.58, 40.11], ['郑州', 113.4, 34.46], ['安阳', 114.21, 36.06], ['长葛', 113.47, 34.12], ['登封', 113.02, 34.27], ['邓州', 112.05, 32.42], ['巩义', 112.58, 34.46], ['鹤壁', 114.11, 35.54], ['辉县', 113.47, 35.27], ['焦作', 113.12, 35.14], ['济源', 112.35, 35.04], ['开封', 114.21, 34.47], ['灵宝', 110.52, 34.31], ['林州', 113.49, 36.03], ['漯河', 114.02, 33.33], ['洛阳', 112.27, 34.41], ['南阳', 112.32, 33.0], ['平顶山', 113.17, 33.44], ['濮阳', 115.01, 35.44], ['沁阳', 112.57, 35.05], ['汝州', 112.5, 34.09], ['三门峡', 111.12, 34.47], ['商丘', 115.38, 34.26], ['卫辉', 114.03, 35.24], ['舞钢', 113.3, 33.17], ['项城', 114.54, 33.26], ['荥阳', 113.21, 34.46], ['新密', 113.22, 34.31], ['新乡', 113.52, 35.18], ['信阳', 114.04, 32.07], ['新郑', 113.43, 34.24], ['许昌', 113.49, 34.01], ['偃师', 112.47, 34.43], ['义马', 111.55, 34.43], ['禹州', 113.28, 34.09], ['周口', 114.38, 33.37], ['驻马店', 114.01, 32.58], ['哈尔滨', 126.36, 45.44], ['阿城', 126.58, 45.32], ['安达', 125.18, 46.24], ['北安', 126.31, 48.15], ['大庆', 125.01, 46.36], ['富锦', 132.02, 47.15], ['海林', 129.21, 44.35], ['海伦', 126.57, 47.28], ['鹤岗', 130.16, 47.2], ['黑河', 127.29, 50.14], ['佳木斯', 130.22, 46.47], ['鸡西', 130.57, 45.17], ['密山', 131.5, 45.32], ['牡丹江', 129.36, 44.35], ['讷河', 124.51, 48.29], ['宁安', 129.28, 44.21], ['齐齐哈尔', 123.57, 47.2], ['七台河', 130.49, 45.48], ['双城', 126.15, 45.22], ['尚志', 127.55, 45.14], ['双鸭山', 131.11, 46.38], ['绥芬河', 131.11, 44.25], ['绥化', 126.59, 46.38], ['铁力', 128.01, 46.59], ['同江', 132.3, 47.39], ['五常', 127.11, 44.55], ['五大连池', 126.07, 48.38], ['伊春', 128.56, 47.42], ['肇东', 125.58, 46.04], ['武汉', 114.17, 30.35], ['安陆', 113.41, 31.15], ['当阳', 111.47, 30.5], ['丹江口', 108.3, 32.33], ['大冶', 114.58, 30.06], ['恩施', 109.29, 30.16], ['鄂州', 114.52, 30.23], ['广水', 113.48, 31.37], ['洪湖', 113.27, 29.48], ['黄石', 115.06, 30.12], ['黄州', 114.52, 30.27], ['荆门', 112.12, 31.02], ['荆沙', 112.16, 30.18], ['老河口', 111.4, 32.23], ['利川', 108.56, 30.18], ['麻城', 115.01, 31.1], ['浦圻', 113.51, 29.42], ['潜江', 112.53, 30.26], ['石首', 112.24, 29.43], ['十堰', 110.47, 32.4], ['随州', 113.22, 31.42], ['天门', 113.1, 30.39], ['武穴', 115.33, 29.51], ['襄樊', 112.08, 32.02], ['咸宁', 114.17, 29.53], ['仙桃', 113.27, 30.22], ['孝感', 113.54, 30.56], ['宜昌', 111.17, 30.42], ['宜城', 112.15, 31.42], ['应城', 113.33, 30.57], ['枣阳', 112.44, 32.07], ['枝城', 111.27, 30.23], ['钟祥', 112.34, 31.1], ['长沙', 112.59, 28.12], ['常德', 111.51, 29.02], ['郴州', 113.02, 25.46], ['衡阳', 112.37, 26.53], ['洪江', 109.59, 27.07], ['怀化', 109.58, 27.33], ['津市', 111.52, 29.38], ['吉首', 109.43, 28.18], ['耒阳', 112.51, 26.24], ['冷水江', 111.26, 27.42], ['冷水滩', 111.35, 26.26], ['涟源', 111.41, 27.41], ['醴陵', 113.3, 27.4], ['临湘', 113.27, 29.29], ['浏阳', 113.37, 28.09], ['娄底', 111.59, 27.44], ['汨罗', 113.03, 28.49], ['韶山', 112.29, 27.54], ['邵阳', 111.28, 27.14], ['武冈', 110.37, 26.43], ['湘潭', 112.53, 27.52], ['湘乡', 112.31, 27.44], ['益阳', 112.2, 28.36], ['永州', 111.37, 26.13], ['沅江', 112.22, 28.5], ['岳阳', 113.06, 29.22], ['张家界', 110.29, 29.08], ['株洲', 113.09, 27.51], ['资兴', 113.13, 25.58], ['长春', 125.19, 43.54], ['白城', 122.5, 45.38], ['白山', 126.26, 41.56], ['大安', 124.18, 45.3], ['德惠', 125.42, 44.32], ['敦化', 128.13, 43.22], ['公主岭', 124.49, 43.31], ['和龙', 129.0, 42.32], ['桦甸', 126.44, 42.58], ['珲春', 130.22, 42.52], ['集安', 126.11, 41.08], ['蛟河', 127.21, 43.42], ['吉林', 126.33, 43.52], ['九台', 125.51, 44.09], ['辽源', 125.09, 42.54], ['临江', 126.53, 41.49], ['龙井', 129.26, 42.46], ['梅河口', 125.4, 42.32], ['舒兰', 126.57, 44.24], ['四平', 124.22, 43.1], ['松原', 124.49, 45.11], ['洮南', 122.47, 45.2], ['通化', 125.56, 41.43], ['图们', 129.51, 42.57], ['延吉', 129.3, 42.54], ['愉树', 126.32, 44.49], ['南京', 118.46, 32.03], ['常熟', 120.43, 31.39], ['常州', 119.58, 31.47], ['丹阳', 119.32, 32.0], ['东台', 120.19, 32.51], ['高邮', 119.27, 32.47], ['海门', 121.09, 31.53], ['淮安', 119.09, 33.3], ['淮阴', 119.02, 33.36], ['江都', 119.32, 32.26], ['姜堰', 120.08, 32.34], ['江阴', 120.17, 31.54], ['靖江', 120.17, 32.02], ['金坛', 119.33, 31.46], ['昆山', 120.57, 31.23], ['连去港', 119.1, 34.36], ['溧阳', 119.29, 31.26], ['南通', 120.51, 32.01], ['邳州', 117.59, 34.19], ['启乐', 121.39, 31.48], ['如皋', 120.33, 32.23], ['宿迁', 118.18, 33.58], ['苏州', 120.37, 31.19], ['太仓', 121.06, 31.27], ['泰兴', 120.01, 32.1], ['泰州', 119.54, 32.3], ['通州', 121.03, 32.05], ['吴江', 120.39, 31.1], ['无锡', 120.18, 31.34], ['兴化', 119.5, 32.56], ['新沂', 118.2, 34.22], ['徐州', 117.11, 34.15], ['盐在', 120.08, 33.22], ['扬中', 119.49, 32.14], ['扬州', 119.26, 32.23], ['宜兴', 119.49, 31.21], ['仪征', 119.1, 32.16], ['张家港', 120.32, 31.52], ['镇江', 119.27, 32.11], ['南昌', 115.55, 28.4], ['德兴', 117.35, 28.57], ['丰城', 115.48, 28.12], ['赣州', 114.56, 28.52], ['高安', 115.22, 28.25], ['吉安', 114.58, 27.07], ['景德镇', 117.13, 29.17], ['井冈山', 114.1, 26.34], ['九江', 115.58, 29.43], ['乐平', 117.08, 28.58], ['临川', 116.21, 27.59], ['萍乡', 113.5, 27.37], ['瑞昌', 115.38, 29.4], ['瑞金', 116.01, 25.53], ['上饶', 117.58, 25.27], ['新余', 114.56, 27.48], ['宜春', 114.23, 27.47], ['鹰潭', 117.03, 28.14], ['樟树', 115.32, 28.03], ['沈阳', 123.25, 41.48], ['鞍山', 123.0, 41.07], ['北票', 120.47, 41.48], ['本溪', 123.46, 41.18], ['朝阳', 120.27, 41.34], ['大连', 121.36, 38.55], ['丹东', 124.22, 40.08], ['大石桥', 122.31, 40.37], ['东港', 124.08, 39.53], ['凤城', 124.02, 40.28], ['抚顺', 123.54, 41.51], ['阜新', 121.39, 42.01], ['盖州', 122.21, 40.24], ['海城', 122.43, 40.51], ['葫芦岛', 120.51, 40.45], ['锦州', 121.09, 41.07], ['开原', 124.02, 42.32], ['辽阳', 123.12, 41.16], ['凌海', 121.21, 41.1], ['凌源', 119.22, 41.14], ['盘锦', 122.03, 41.07], ['普兰店', 121.58, 39.23], ['铁法', 123.32, 42.28], ['铁岭', 123.51, 42.18], ['瓦房店', 122.0, 39.37], ['兴城', 120.41, 40.37], ['新民', 122.49, 41.59], ['营口', 122.13, 40.39], ['庄河', 122.58, 39.41], ['呼和浩特', 111.41, 40.48], ['包头', 109.49, 40.39], ['赤峰', 118.58, 42.17], ['东胜', 109.59, 39.48], ['二连浩特', 111.58, 43.38], ['额尔古纳', 120.11, 50.13], ['丰镇', 113.09, 40.27], ['根河', 121.29, 50.48], ['海拉尔', 119.39, 49.12], ['霍林郭勒', 119.38, 45.32], ['集宁', 113.06, 41.02], ['临河', 107.22, 40.46], ['满洲里', 117.23, 49.35], ['通辽', 122.16, 43.37], ['乌兰浩特', 122.03, 46.03], ['乌海', 106.48, 39.4], ['锡林浩特', 116.03, 43.57], ['牙克石', 120.4, 49.17], ['扎兰屯', 122.47, 48.0], ['银川', 106.16, 38.27], ['青铜峡', 105.59, 37.56], ['石嘴山', 106.22, 39.02], ['吴忠', 106.11, 37.59], ['西宁', 101.48, 36.38], ['德令哈', 97.23, 37.22], ['格尔木', 94.55, 36.26], ['济南', 117.0, 36.4], ['安丘', 119.12, 36.25], ['滨州', 118.02, 37.22], ['昌邑', 119.24, 39.52], ['德州', 116.17, 37.26], ['东营', 118.3, 37.27], ['肥城', 116.46, 36.14], ['高密', 119.44, 36.22], ['菏泽', 115.26, 35.14], ['胶南', 119.58, 35.53], ['胶州', 120.0, 36.17], ['即墨', 120.28, 36.22], ['济宁', 116.33, 35.23], ['莱芜', 117.4, 36.12], ['莱西', 120.31, 36.52], ['莱阳', 120.42, 36.58], ['莱州', 119.57, 37.1], ['乐陵', 117.12, 37.44], ['聊城', 115.57, 36.26], ['临清', 115.42, 36.51], ['临沂', 118.2, 35.03], ['龙口', 120.21, 37.39], ['蓬莱', 120.45, 37.48], ['平度', 119.58, 36.47], ['青岛', 120.18, 36.03], ['青州', 118.28, 36.42], ['曲阜', 116.58, 35.36], ['日照', 119.32, 35.23], ['荣成', 122.25, 37.1], ['乳山', 121.31, 36.54], ['寿光', 118.44, 36.53], ['泰安', 117.08, 36.11], ['滕州', 117.09, 35.06], ['潍坊', 119.06, 36.43], ['威海', 122.07, 37.31], ['文登', 122.03, 37.12], ['新泰', 117.45, 35.54], ['烟台', 121.24, 37.32], ['兖州', 116.49, 35.32], ['禹城', 116.39, 36.56], ['枣庄', 117.33, 34.52], ['章丘', 117.32, 36.43], ['招远', 120.23, 37.21], ['诸城', 119.24, 35.59], ['淄博', 118.03, 36.48], ['邹城', 116.58, 35.24], ['太原', 112.33, 37.54], ['长治', 113.06, 36.11], ['大同', 113.17, 40.06], ['高平', 112.55, 35.48], ['古交', 112.09, 37.54], ['河津', 110.41, 35.35], ['侯马', 111.21, 35.37], ['霍州', 111.42, 36.34], ['介休', 111.55, 37.02], ['晋城', 112.51, 35.3], ['临汾', 111.31, 36.05], ['潞城', 113.14, 36.21], ['朔州', 112.26, 39.19], ['孝义', 111.48, 37.08], ['忻州', 112.43, 38.24], ['阳泉', 113.34, 37.51], ['永济', 110.27, 34.52], ['原平', 112.42, 38.43], ['榆次', 112.43, 37.41], ['运城', 110.59, 35.02], ['西安', 108.57, 34.17], ['安康', 109.01, 32.41], ['宝鸡', 107.09, 34.22], ['韩城', 110.27, 35.28], ['汉中', 107.01, 33.04], ['华阴', 110.05, 34.34], ['商州', 109.57, 33.52], ['铜川', 109.07, 35.06], ['渭南', 109.3, 34.3], ['咸阳', 108.43, 34.2], ['兴平', 108.29, 34.18], ['延安', 109.28, 36.35], ['榆林', 109.47, 38.18], ['成都', 104.04, 30.4], ['巴中', 106.43, 31.51], ['崇州', 103.4, 30.39], ['达川', 107.29, 31.14], ['德阳', 104.22, 31.09], ['都江堰', 103.37, 31.01], ['峨眉山', 103.29, 29.36], ['涪陵', 107.22, 29.42], ['广汉', 104.15, 30.58], ['广元', 105.51, 32.28], ['华蓥', 106.44, 30.26], ['简阳', 104.32, 30.24], ['江油', 104.42, 31.48], ['阆中', 105.58, 31.36], ['乐山', 103.44, 29.36], ['泸州', 105.24, 28.54], ['绵阳', 104.42, 31.3], ['南充', 106.04, 30.49], ['内江', 105.02, 29.36], ['攀枝花', 101.43, 26.34], ['彭州', 103.57, 30.59], ['邛崃', 103.28, 30.26], ['遂宁', 105.33, 30.31], ['万县', 108.21, 30.5], ['万源', 108.03, 32.03], ['西昌', 102.16, 27.54], ['雅安', 102.59, 29.59], ['宜宾', 104.34, 28.47], ['自贡', 104.46, 29.23], ['资阳', 104.38, 30.09], ['天津市', 117.12, 39.02], ['拉萨', 91.08, 29.39], ['日喀则', 88.51, 29.16], ['乌鲁木齐', 87.36, 43.45], ['阿克苏', 80.19, 41.09], ['阿勒泰', 88.12, 47.5], ['阿图什', 76.08, 39.42], ['博乐', 82.08, 44.57], ['昌吉', 87.18, 44.02], ['阜康', 87.58, 44.09], ['哈密', 93.28, 42.5], ['和田', 79.55, 37.09], ['克拉玛依', 84.51, 45.36], ['喀什', 75.59, 39.3], ['库尔勒', 86.07, 41.46], ['奎屯', 84.56, 44.27], ['石河子', 86.0, 44.18], ['塔城', 82.59, 46.46], ['吐鲁番', 89.11, 42.54], ['伊宁', 81.2, 43.55], ['昆明', 102.42, 25.04], ['保山', 99.1, 25.08], ['楚雄', 101.32, 25.01], ['大理', 100.13, 25.34], ['东川', 103.12, 26.06], ['个旧', 103.09, 23.21], ['景洪', 100.48, 22.01], ['开远', 103.13, 23.43], ['曲靖', 103.48, 25.3], ['瑞丽', 97.5, 24.0], ['思茅', 100.58, 22.48], ['畹町', 98.04, 24.06], ['宣威', 104.06, 26.13], ['玉溪', 102.32, 24.22], ['昭通', 103.42, 27.2], ['杭州', 120.1, 30.16], ['慈溪', 121.15, 30.11], ['东阳', 120.14, 29.16], ['奉化', 121.24, 29.39], ['富阳', 119.57, 30.03], ['海宁', 120.42, 30.32], ['湖州', 120.06, 30.52], ['建德', 119.16, 29.29], ['江山', 118.37, 28.45], ['嘉兴', 120.45, 30.46], ['金华', 119.39, 29.07], ['兰溪', 119.28, 29.12], ['临海', 121.08, 28.51], ['丽水', 119.54, 28.27], ['龙泉', 119.08, 28.04], ['宁波', 121.33, 29.52], ['平湖', 121.01, 30.42], ['衢州', 118.52, 28.58], ['瑞安', 120.38, 27.48], ['上虞', 120.52, 30.01], ['绍兴', 120.34, 30.0], ['台州', 121.27, 28.41], ['桐乡', 120.32, 30.38], ['温岭', 121.21, 28.22], ['温州', 120.39, 28.01], ['萧山', 120.16, 30.09], ['义乌', 120.04, 29.18], ['乐清', 120.58, 28.08], ['余杭', 120.18, 30.26], ['余姚', 121.1, 30.02], ['永康', 120.01, 29.54], ['舟山', 122.06, 30.01], ['诸暨', 120.14, 29.43], ['重庆市', 106.33, 29.35], ['合川市', 106.15, 30.02], ['江津市', 106.16, 29.18], ['南川市', 107.05, 29.1], ['永川市', 105.53, 29.23], /* 朝、日一些城市 ['平壤', 125.45, 39.01] , ['首爾', 126.58, 37.33] , ['大田', 127.24, 36.22] , ['濟州', 126.29, 33.31] , ['仁川', 126.38, 37.28] , ['釜山', 129.03, 35.06] , ['東京', 139.46, 35.42] , ['千葉', 140.07, 35.36] , ['廣島', 132.27, 34.24] , ['神戶', 135.1, 34.41] , ['京都', 135.45, 35.0] , ['名古屋', 136.55, 35.1] , ['奈良', 135.5, 34.41] , ['大阪', 135.3, 34.4] , ['橫濱', 139.39, 35.27] , ['北海道登別市', 141.1, 42.28] ,*/ ]; </span>
这是绘制显示它们的代码:
<span style="font-size:18px;">function myDraw(xGlobal, yGlobal) { var config = new PlotConfiguration(); config.init(); config.setPreference(); var r = 10; config.setSector(1,1,1,1); //config.graphPaper2D(0, 0, r); config.axis2D(0, 0,180); var len = $Citys.length; var array = []; var x0, y0; var c1, c2; var s, sx, sy; for (var i = 0; i < len; i++) { /* //城市数据样式:['香港市', 'E115.12N21.23'] s = $Citys[i][1]; c1 = s.indexOf('E'); if (c1 == -1) { c1 = s.indexOf('W'); } c2 = s.indexOf('N'); if (c2 == -1) { c2 = s.indexOf('S'); } if (c1 != -1 && c2 != -1) { if (s[c1]=='W') { sx = '-'+s.substring(c1+1, c2); } else { sx = s.substring(c1+1, c2); } if (s[c2]=='S') { sy = '-'+s.substring(c2+1); } else { sy = s.substring(c2+1); } } array.push([$Citys[i][0], parseFloat(sx), parseFloat(sy)]); */ //对于经纬度标识已去除,是直接的浮点量,压入数据 array.push([$Citys[i][0], $Citys[i][1], $Citys[i][2]]); } //document.write(array); array.sort(function(a, b) { if (Math.abs(a[1]-b[1])<0.001) { return a[2]-b[2]; } else { return a[1]-b[1]; } }); shape.strokeRect(0, 0, 20*r, 20*r); var colorArray = ['red', 'orange', '#0088FF', 'green', 'cyan', 'blue', '#FF00FF', 'purple']; var colors = colorArray.length; var tmp; var dx, dy, xpos, ypos; for (var i = 0; i < len; i++) { if (i > 0) { //对于两个地区过于接近,无法在图上分开的情况,就直接不标了。 if (Math.abs(array[i][1]-array[i-1][1]) < 0.05 && Math.abs(array[i][2]-array[i-1][2]) < 0.05) { continue; } } tmp = array[i]; dx = tmp[1]-xGlobal; dy = tmp[2]-yGlobal; //每屏可显示1.5个经度单位或1个纬度单位的区域 if (Math.abs(dx)<15/r && Math.abs(dy)<10/r) { //此处放大20倍是为了使度数相差大于0.05度的城市都可以显示 xpos = Math.round(dx*20)*r; ypos = -Math.round(dy*20)*r; shape.sphere([xpos, ypos], r/3, colorArray[i%colors]); plot.fillText(tmp[0], xpos+5, ypos, 50); } } }</span>
放大一倍后的效果:
以下的内容纯属娱乐,小伙伴们可以会心一笑,当作啥都没发生过:
话说在银河系厄尔斯星球上,有八大帝国,以及一些小一点的王国,公国。
八大帝国中,首屈一指的当然是中华[混沌]帝国啦。
想当年盘古大神开天辟地之时,一斧劈开了天,二斧辟开了地,天和地的混沌状态
就被解除掉了,当盘古大神想用第三斧把人心的混沌也给劈开时,突然一阵倦意袭来,
就去找地方打瞌睡去了,这一睡啊几亿年就这么过去了,盘古还没回来,
所以中华帝国的人心就一直处于[混沌]的状态之中。
其实[混沌]状态呢也没啥不好,就是每天忙的跟猪狗似的,好像干活少于十个小时
第二天就吃不起饭了似的。那为啥要这么拼死拼活的干呢。据阿伟的观察与统计分析,
发现其实这十个小时的劳动里面啊,只有两个小时是在推动社会的进步和发展的,
接下来的四个小时呢,就是在大马路上挖坑,砌墙,往死里给别人设置障碍。那还有四
个小时呢,当然是填别人挖的坑,拆别人砌的墙啦,不然没路可走啊。
好了,不说了,中华帝国的人哪还有一个特点就是比较傲骄,说不得,摸不得,碰不得。
所以阿伟自从深入分析研究了此中奥妙以后啊,就不用肉身在外行走了,因为到处是坑啊,
雷区啊,禁制啊神马的,一个不小心,轻则骨断筋折,重则香消玉殒。阿伟可是个胆小
怕事的唯利是图者,一旦有损自身利益那就是各种天山遁法,所以长久以后终于修得了
法身神通,从此移形换位,虚无空痕,行走于云端。
说这些的意思呢,是先在这里给未来阿伟的小伙伴们提个醒,千万要珍爱自己的肉身,
不到万不得已,在外行走多用法身吧。
关于这中华帝国这至高无上的[混沌]二字,其他帝国的子民那是拍马不及的。看看他们的特征吧,
那种生存状态和[混沌]比起来,那真是小儿科啊。
好像其它的词小伙伴们应该能一目了然,可能只有玛雅帝国的这[摇摆]二字难解其意,阿伟就在
这里解释一下,那里的子民呢,既没有成熟的自由型生态图纸,又没有有效的计划型生态图纸,
于是一会想,咱是不是要自由呢,一会又在想,咱是不是要计划呢,就这么摇摆不定,所以
称为[摇摆]帝国。
本节到此结束,欲知后事如何,请看下回分解。