pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <legend id='l1cz6'><style id='l1cz6'><dir id='l1cz6'><q id='l1cz6'></q></dir></style></legend>
    <i id='l1cz6'><tr id='l1cz6'><dt id='l1cz6'><q id='l1cz6'><span id='l1cz6'><b id='l1cz6'><form id='l1cz6'><ins id='l1cz6'></ins><ul id='l1cz6'></ul><sub id='l1cz6'></sub></form><legend id='l1cz6'></legend><bdo id='l1cz6'><pre id='l1cz6'><center id='l1cz6'></center></pre></bdo></b><th id='l1cz6'></th></span></q></dt></tr></i><div class="5hd77rr" id='l1cz6'><tfoot id='l1cz6'></tfoot><dl id='l1cz6'><fieldset id='l1cz6'></fieldset></dl></div>
      <bdo id='l1cz6'></bdo><ul id='l1cz6'></ul>
      <tfoot id='l1cz6'></tfoot>

      <small id='l1cz6'></small><noframes id='l1cz6'>

      1. 將經緯度坐標排序為順時針四邊形

        Sort latitude and longitude coordinates into clockwise ordered quadrilateral(將經緯度坐標排序為順時針四邊形)
          <tbody id='Dr0m1'></tbody>
        <tfoot id='Dr0m1'></tfoot>

        <small id='Dr0m1'></small><noframes id='Dr0m1'>

            <bdo id='Dr0m1'></bdo><ul id='Dr0m1'></ul>
          • <i id='Dr0m1'><tr id='Dr0m1'><dt id='Dr0m1'><q id='Dr0m1'><span id='Dr0m1'><b id='Dr0m1'><form id='Dr0m1'><ins id='Dr0m1'></ins><ul id='Dr0m1'></ul><sub id='Dr0m1'></sub></form><legend id='Dr0m1'></legend><bdo id='Dr0m1'><pre id='Dr0m1'><center id='Dr0m1'></center></pre></bdo></b><th id='Dr0m1'></th></span></q></dt></tr></i><div class="zbjbhvd" id='Dr0m1'><tfoot id='Dr0m1'></tfoot><dl id='Dr0m1'><fieldset id='Dr0m1'></fieldset></dl></div>
                  <legend id='Dr0m1'><style id='Dr0m1'><dir id='Dr0m1'><q id='Dr0m1'></q></dir></style></legend>

                  本文介紹了將經緯度坐標排序為順時針四邊形的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  問題

                  用戶最多可以按任意順序提供四個經緯度坐標.他們使用谷歌地圖這樣做.使用 Google 的 Polygon API (v3),他們選擇的坐標應該突出顯示四個坐標之間的選定區域.

                  Users can provide up to four latitude and longitude coordinates, in any order. They do so with Google Maps. Using Google's Polygon API (v3), the coordinates they select should highlight the selected area between the four coordinates.

                  問題

                  如何按(逆)順時針順序對一組經緯度坐標進行排序?

                  How do you sort an array of latitude and longitude coordinates in (counter-)clockwise order?

                  解決方案和搜索

                  StackOverflow 問題

                  • 繪制可調整大小(不相交)的多邊形
                  • 如何對 Google 地圖多邊形中的點進行排序以使線不會交叉?
                  • 按順時針順序對四個點進行排序

                  相關網站

                  • http://www.daftlogic.com/projects-google-maps-area-calculator-tool.htm
                  • http://en.literateprograms.org/Quickhull_%28Javascript%29
                  • http://www.geocodezip.com/map-markers_ConvexHull_Polygon.asp
                  • http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm

                  已知算法

                  • Graham 的掃描(太復雜)
                  • Jarvis March 算法(處理 N 個點)
                  • 遞歸凸包(移除一個點)

                  代碼

                  這是我目前所擁有的:

                  // Ensures the markers are sorted: NW, NE, SE, SW
                  function sortMarkers() {
                    var ns = markers.slice( 0 );
                    var ew = markers.slice( 0 );
                  
                    ew.sort( function( a, b ) {
                      if( a.position.lat() < b.position.lat() ) {
                        return -1;
                      }
                      else if( a.position.lat() > b.position.lat() ) {
                        return 1;
                      }
                  
                      return 0;
                    });
                  
                    ns.sort( function( a, b ) {
                      if( a.position.lng() < b.position.lng() ) {
                        return -1;
                      }
                      else if( a.position.lng() > b.position.lng() ) {
                        return 1;
                      }
                  
                      return 0;
                    });
                  
                    var nw;
                    var ne;
                    var se;
                    var sw;
                  
                    if( ew.indexOf( ns[0] ) > 1 ) {
                      nw = ns[0];
                    }
                    else {
                      ne = ns[0];
                    }
                  
                    if( ew.indexOf( ns[1] ) > 1 ) {
                      nw = ns[1];
                    }
                    else {
                      ne = ns[1];
                    }
                  
                    if( ew.indexOf( ns[2] ) > 1 ) {
                      sw = ns[2];
                    }
                    else {
                      se = ns[2];
                    }
                  
                    if( ew.indexOf( ns[3] ) > 1 ) {
                      sw = ns[3];
                    }
                    else {
                      se = ns[3];
                    }
                  
                    markers[0] = nw;
                    markers[1] = ne;
                    markers[2] = se;
                    markers[3] = sw;
                  }
                  

                  謝謝.

                  推薦答案

                  給出要點:

                     4  +        [d]            [g]                 
                        |                             
                     3 [a]            [e]                 
                        |                             
                     2  +                  [f]       [h]    
                        |                             
                     1  +   [b]                             
                        |                             
                     0  +----+---[c]---+----+----+----+
                        0    1    2    3    4    5    6
                  

                  你想找到以下綁定步行:

                  you want to find the following bound walk:

                     4  +     ___[d]------------[g]                 
                        |  __/                         
                     3 [a]/           [e]__                
                        |              \_ ```---      
                     2  +                `[f]   \___[h]    
                        |              __/            
                     1  +   [b]      __/                   
                        |          /                
                     0  +----+--`[c]---+----+----+----+
                        0    1    2    3    4    5    6
                  

                  ?

                  如果這是正確的,這里有一個方法:

                  If this is correct, here's a way:

                  • 在點集中找到最高點,Ptop.如果出現平局,則選擇 x 坐標最小的點
                  • 通過比較每對點的直線的斜率 mi 和 mj 對所有點進行排序(不包括 Ptop!) Pi 和 Pj 在通過 Ptop 時使
                    • 如果 mi 和 mj 相等,讓點 Pi 或 Pj 最接近Ptop先來
                    • 如果 mi 為正且 mj 為負(或零),則 Pj 在前
                    • 如果 mi 和 mj 都是正數或負數,讓屬于斜率最大的線的點在前
                    • find the upper most point, Ptop, in the set of points. In case of a tie, pick the point with the smallest x coordinate
                    • sort all points by comparing the slopes mi and mj of the lines each pair of points (excluding Ptop!) Pi and Pj make when passing through Ptop
                      • if mi and mj are equal, let the point Pi or Pj closest to Ptop come first
                      • if mi is positive and mj is negative (or zero), Pj comes first
                      • if both mi and mj are either positive or negative, let the point belonging to the line with the largest slope come first

                      這是地圖的快速演示:

                      (我對 JavaScript 知之甚少,所以我可能或可能已經違反了一些 JavaScript 代碼約定......):

                      (I know little JavaScript, so I might, or probably have, violated some JavaScript code conventions...):

                      var points = [
                          new Point("Stuttgard", 48.7771056, 9.1807688),
                          new Point("Rotterdam", 51.9226899, 4.4707867),
                          new Point("Paris", 48.8566667, 2.3509871),
                          new Point("Hamburg", 53.5538148, 9.9915752),
                          new Point("Praha", 50.0878114, 14.4204598),
                          new Point("Amsterdam", 52.3738007, 4.8909347),
                          new Point("Bremen", 53.074981, 8.807081),
                          new Point("Calais", 50.9580293, 1.8524129),
                      ];
                      var upper = upperLeft(points);
                      
                      print("points :: " + points);
                      print("upper  :: " + upper);
                      points.sort(pointSort);
                      print("sorted :: " + points);
                      
                      // A representation of a 2D Point.
                      function Point(label, lat, lon) {
                      
                          this.label = label;
                          this.x = (lon + 180) * 360;
                          this.y = (lat + 90) * 180;
                      
                          this.distance=function(that) {
                              var dX = that.x - this.x;
                              var dY = that.y - this.y;
                              return Math.sqrt((dX*dX) + (dY*dY));
                          }
                      
                          this.slope=function(that) {
                              var dX = that.x - this.x;
                              var dY = that.y - this.y;
                              return dY / dX;
                          }
                      
                          this.toString=function() {
                              return this.label;
                          }
                      }
                      
                      // A custom sort function that sorts p1 and p2 based on their slope
                      // that is formed from the upper most point from the array of points.
                      function pointSort(p1, p2) {
                          // Exclude the 'upper' point from the sort (which should come first).
                          if(p1 == upper) return -1;
                          if(p2 == upper) return 1;
                      
                          // Find the slopes of 'p1' and 'p2' when a line is 
                          // drawn from those points through the 'upper' point.
                          var m1 = upper.slope(p1);
                          var m2 = upper.slope(p2);
                      
                          // 'p1' and 'p2' are on the same line towards 'upper'.
                          if(m1 == m2) {
                              // The point closest to 'upper' will come first.
                              return p1.distance(upper) < p2.distance(upper) ? -1 : 1;
                          }
                      
                          // If 'p1' is to the right of 'upper' and 'p2' is the the left.
                          if(m1 <= 0 && m2 > 0) return -1;
                      
                          // If 'p1' is to the left of 'upper' and 'p2' is the the right.
                          if(m1 > 0 && m2 <= 0) return 1;
                      
                          // It seems that both slopes are either positive, or negative.
                          return m1 > m2 ? -1 : 1;
                      }
                      
                      // Find the upper most point. In case of a tie, get the left most point.
                      function upperLeft(points) {
                          var top = points[0];
                          for(var i = 1; i < points.length; i++) {
                              var temp = points[i];
                              if(temp.y > top.y || (temp.y == top.y && temp.x < top.x)) {
                                  top = temp;
                              }
                          }
                          return top;
                      }
                      

                      注意:您應該雙重或三重檢查從 lat,lonx,y 的轉換,因為我是 GIS 新手!!!但也許你甚至不需要轉換任何東西.如果不這樣做,upperLeft 函數可能只返回最低點而不是最高點,具體取決于相關點的位置.再次:三重檢查這些假設!

                      Note: your should double, or triple check the conversions from lat,lon to x,y as I am a novice if it comes to GIS!!! But perhaps you don't even need to convert anything. If you don't, the upperLeft function might just return the lowest point instead of the highest, depending on the locations of the points in question. Again: triple check these assumptions!

                      執行上面的代碼片段時,會打印以下內容:

                      When executing the snippet above, the following gets printed:

                      points :: Stuttgard,Rotterdam,Paris,Hamburg,Praha,Amsterdam,Bremen,Calais
                      upper  :: Hamburg
                      sorted :: Hamburg,Praha,Stuttgard,Paris,Bremen,Calais,Rotterdam,Amsterdam
                      

                      交替距離函數

                      function distance(lat1, lng1, lat2, lng2) {
                        var R = 6371; // km
                        var dLat = (lat2-lat1).toRad();
                        var dLon = (lng2-lng1).toRad();
                        var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
                                Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) *
                                Math.sin(dLon/2) * Math.sin(dLon/2);
                        var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
                        return R * c;
                      }
                      

                      這篇關于將經緯度坐標排序為順時針四邊形的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                      【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數據更新 Observable)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態元素 - Angular 2 amp;離子2)
                  • <i id='XEBmU'><tr id='XEBmU'><dt id='XEBmU'><q id='XEBmU'><span id='XEBmU'><b id='XEBmU'><form id='XEBmU'><ins id='XEBmU'></ins><ul id='XEBmU'></ul><sub id='XEBmU'></sub></form><legend id='XEBmU'></legend><bdo id='XEBmU'><pre id='XEBmU'><center id='XEBmU'></center></pre></bdo></b><th id='XEBmU'></th></span></q></dt></tr></i><div class="dhztnnx" id='XEBmU'><tfoot id='XEBmU'></tfoot><dl id='XEBmU'><fieldset id='XEBmU'></fieldset></dl></div>
                      <bdo id='XEBmU'></bdo><ul id='XEBmU'></ul>

                          <legend id='XEBmU'><style id='XEBmU'><dir id='XEBmU'><q id='XEBmU'></q></dir></style></legend>

                            <tbody id='XEBmU'></tbody>

                            <tfoot id='XEBmU'></tfoot>
                          • <small id='XEBmU'></small><noframes id='XEBmU'>

                          • 主站蜘蛛池模板: 天一线缆邯郸有限公司_煤矿用电缆厂家_矿用光缆厂家_矿用控制电缆_矿用通信电缆-天一线缆邯郸有限公司 | 河南空气能热水器-洛阳空气能采暖-洛阳太阳能热水工程-洛阳润达高科空气能商行 | 【灵硕展览集团】展台展会设计_展览会展台搭建_展览展示设计一站式服务公司 | 阳光1号桔柚_无核沃柑_柑橘新品种枝条苗木批发 - 苧金网 | 【电子厂招聘_普工招工网_工厂招聘信息平台】-工立方打工网 | 洁净实验室工程-成都手术室净化-无尘车间装修-四川华锐净化公司-洁净室专业厂家 | 全自动不干胶贴标机_套标机-上海今昂贴标机生产厂家 | 智成电子深圳tdk一级代理-提供TDK电容电感贴片蜂鸣器磁芯lambda电源代理经销,TDK代理商有哪些TDK一级代理商排名查询。-深圳tdk一级代理 | 福州时代广告制作装饰有限公司-福州广告公司广告牌制作,福州展厅文化墙广告设计, | 自动检重秤-动态称重机-重量分选秤-苏州金钻称重设备系统开发有限公司 | 河南生物显微镜,全自动冰冻切片机-河南荣程联合科技有限公司 | 骨龄仪_骨龄检测仪_儿童骨龄测试仪_品牌生产厂家【品源医疗】 | 中式装修设计_室内中式装修_【云臻轩】中式设计机构 | 对辊破碎机_四辊破碎机_双齿辊破碎机_华盛铭重工 | 全国冰箱|空调|洗衣机|热水器|燃气灶维修服务平台-百修家电 | 贝朗斯动力商城(BRCPOWER.COM) - 买叉车蓄电池上贝朗斯商城,价格更超值,品质有保障! | 上海租奔驰_上海租商务车_上海租车网-矢昂汽车服务公司 | 电动不锈钢套筒阀-球面偏置气动钟阀-三通换向阀止回阀-永嘉鸿宇阀门有限公司 | 轴承振动测量仪电箱-轴承测振动仪器-测试仪厂家-杭州居易电气 | 塑料异型材_PVC异型材_封边条生产厂家_PC灯罩_防撞扶手_医院扶手价格_东莞市怡美塑胶制品有限公司 | 超声波流量计_流量标准装置生产厂家 _河南盛天精密测控 | 智能监控-安防监控-监控系统安装-弱电工程公司_成都万全电子 | 上海办公室装修公司_办公室设计_直营办公装修-羚志悦装 | 隔爆型防爆端子分线箱_防爆空气开关箱|依客思 | 大型多片锯,圆木多片锯,方木多片锯,板材多片锯-祥富机械有限公司 | 在线浊度仪_悬浮物污泥浓度计_超声波泥位计_污泥界面仪_泥水界面仪-无锡蓝拓仪表科技有限公司 | 泡沫消防车_水罐消防车_湖北江南专用特种汽车有限公司 | 昆明挖掘机修理厂_挖掘机翻新再制造-昆明聚力工程机械维修有限公司 | LNG鹤管_内浮盘价格,上装鹤管,装车撬厂家-连云港赛威特机械 | YT保温材料_YT无机保温砂浆_外墙保温材料_南阳银通节能建材高新技术开发有限公司 | 分子精馏/精馏设备生产厂家-分子蒸馏工艺实验-新诺舜尧(天津)化工设备有限公司 | 污水/卧式/潜水/钻井/矿用/大型/小型/泥浆泵,价格,参数,型号,厂家 - 安平县鼎千泵业制造厂 | 桑茶-七彩贝壳桑叶茶 长寿茶 | 玻璃钢格栅盖板|玻璃钢盖板|玻璃钢格栅板|树篦子-长沙川皖玻璃钢制品有限公司 | 衢州装饰公司|装潢公司|办公楼装修|排屋装修|别墅装修-衢州佳盛装饰 | 骨密度仪-骨密度测定仪-超声骨密度仪-骨龄测定仪-天津开发区圣鸿医疗器械有限公司 | 中细软知识产权_专业知识产权解决方案提供商 | 锂离子电池厂家-山东中信迪生电源 | 成都LED显示屏丨室内户外全彩led屏厂家方案报价_四川诺显科技 | 挤出机_橡胶挤出机_塑料挤出机_胶片冷却机-河北伟源橡塑设备有限公司 | 粤丰硕水性环氧地坪漆-防静电自流平厂家-环保地坪涂料代理 |