ArcGIS(js-api)中是否有像leaflet-knn这样的解决方案,用于在geoJSON多点要素中找到距离给定点最近的点?
创始人
2024-09-12 05:30:46
0

在ArcGIS中,可以使用SpatialReference、Graphic、geometryEngine和query相关类来查找距离给定点最近的点。

以下是一个示例代码,其中包含一个示例geoJSON多点要素数组和一个用于查找最近点的函数findClosestPoint:

require([
  "esri/geometry/Point",
  "esri/tasks/GeometryService",
  "esri/tasks/support/ProjectParameters",
  "esri/geometry/geometryEngine",
  "esri/Graphic",
  "dojo/domReady!"
], function(Point, GeometryService, ProjectParameters, geometryEngine, Graphic) {

  // GeoJSON multi-point feature example
  var multiPointFeature = {
    "type": "Feature",
    "geometry": {
      "type": "MultiPoint",
      "coordinates": [
        [0, 0],
        [2, 2],
        [4, 4],
        [6, 6]
      ]
    }
  };

  // Function to find closest point to given point in multi-point feature
  function findClosestPoint(point, multiPointFeature) {
    // Project point to spatial reference of multi-point feature
    var geometryService = new GeometryService("https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
    var projectParameters = new ProjectParameters({
      geometries: [point],
      outSR: multiPointFeature.geometry.spatialReference
    });
    geometryService.project(projectParameters).then(function(result) {
      // Find closest point using geometryEngine.nearestCoordinate
      var closestPoint = geometryEngine.nearestCoordinate(multiPointFeature.geometry, result[0]);
      // Create a graphic for the closest point and add it to the map
      var graphic = new Graphic({
        geometry: closestPoint.coordinate,
        symbol: {
          type: "simple-marker",
          style: "square",
          color: "blue",
          size: "12px",
          outline: {
            color: [255, 255, 0],
            width: 3
          }
        }
      });

相关内容

热门资讯

七分钟科普!钱塘13水打牌,微... 七分钟科普!钱塘13水打牌,微扑克网页版辅助,雀神辅助在哪下载(有挂攻略);亲,关键说明,钱塘13水...
we poke软件免费版!手机... we poke软件免费版!手机德州软件透明挂,聚星扑克原来真的有挂(详细辅助挂教程);1、we po...
六分钟辅助!天涯手机麻将有挂吗... 六分钟辅助!天涯手机麻将有挂吗,wpk德州ai机器人,雀神辅助器免费版v3.0(有挂攻略)1、打开软...
微扑克这软件有问题!线上wpk... 微扑克这软件有问题!线上wpk德州软件透明挂,云扑克德州一直真的有挂(详细辅助黑科技教程)1、微扑克...
wpk俱乐部系统!手机德州软件... wpk俱乐部系统!手机德州软件透明挂,wpk德州果然真的有挂(详细智能ai代打教程)1、打开软件启动...
十分钟科普!胖猪竞技有外 挂没... 十分钟科普!胖猪竞技有外 挂没,德扑数据软件,广东雀神智能辅助软件(有挂细节)1、进入到胖猪竞技有外...
哈糖大菠萝可以弄的!红龙软件德... 哈糖大菠萝可以弄的!红龙软件德州扑克软件透明挂,wePokE一般真的有挂(详细辅助工具教程);1、哈...
七分钟辅助挂!闲逸游戏有辅助工... 七分钟辅助挂!闲逸游戏有辅助工具吗,欢乐棋牌有挂,微信雀神小程序能开挂吗(有挂细节)1、闲逸游戏有辅...
德扑ai人工智能!WPk软件透... 德扑ai人工智能!WPk软件透明挂,aapoKer一直真的有挂(详细辅助教程);1、玩家可以在德扑a...
9分钟辅助挂!九九互娱有挂吗,... 9分钟辅助挂!九九互娱有挂吗,德州alphax辅助,雀神辅助器插件(有挂细节)1、实时九九互娱有挂吗...