美文网首页程序员
ArcGIS开发之geometryService的relatio

ArcGIS开发之geometryService的relatio

作者: 知足常乐晨 | 来源:发表于2018-05-29 15:14 被阅读18次

    坐标转换

    将原始坐标转换成wkid:32652坐标,并且使用回调将数据返回

    back.coordinateConvert = function(geometry,callback){
        var geometryService = new GeometryService(baseURL+"/Utilities/Geometry/GeometryServer");            
         var params = new ProjectParameters();
          params.geometries = [geometry];
          params.outSR = new SpatialReference(32652);
          geometryService.project(params).then(function(resGeometry){
              callback(resGeometry);
          })
    }
    

    数据查询

    区域图层数据查询,并且使用回调将数据返回

    back.getReginData = function(callback){
      var query = new Query();
      query.where = "1=1";
      query.returnGeometry = true;
      query.outFields = ["*"];
      var queryTask = new QueryTask("http://localhost:6080/arcgis/rest/services/dt1124/MapServer/18");
      queryTask.execute(query,function(response){
          callback(response);
      })
    }
    

    relation

    用于判断geometry之间的关系,如相交,包含,相切等

    back.relation = function(geometries1,geometries2){
        var geometryService = new GeometryService(baseURL+"Utilities/Geometry/GeometryServer");
        var relationParams = new RelationParameters();
        relationParams.geometries1 = geometries1;
        relationParams.geometries2 = geometries2;
        relationParams.relation = RelationParameters.SPATIAL_REL_INTERSECTION;
        var result = geometryService.relation(relationParams);
        return result;
    }
    

    SPATIAL_REL_INTERSECTION:相交。可选择不同的关系
    返回值result是个Deferred对象,调用时:

    var relation = back.relation(resGeometry,geometryArray);
    relation.then(function(data){
        console.dir(data);
    })
    

    结果如下图所示:

    image.png

    表示存在两个相交关系:geometries1[0]geometries2[3]相交,geometries1[1]geometries2[0]相交

    相关文章

      网友评论

        本文标题:ArcGIS开发之geometryService的relatio

        本文链接:https://www.haomeiwen.com/subject/svhajftx.html