Geometry Bing Maps SpatialMath模块交点对于具有相同坐标的多个接点不精确

Geometry Bing Maps SpatialMath模块交点对于具有相同坐标的多个接点不精确,geometry,geospatial,bing-maps,intersection,bing-api,Geometry,Geospatial,Bing Maps,Intersection,Bing Api,我发现了一个问题,虽然我在地图上有数千个图钉,但我正在使用绘图工具徒手绘制形状,然后在“drawingEnded”事件上执行交叉点,而我可以看到交叉点返回的应该比实际返回的多 我错过什么了吗?例如,如果在绘制的新区域下有大约500个管脚,则“相交”方法仅返回100个或更多的管脚 我的Spider群集配置: `Microsoft.Maps.loadModule(['SpiderClusterManager'],函数(){ ` “drawingEnded”事件后触发的交叉口功能代码: `函数find

我发现了一个问题,虽然我在地图上有数千个图钉,但我正在使用绘图工具徒手绘制形状,然后在“drawingEnded”事件上执行交叉点,而我可以看到交叉点返回的应该比实际返回的多

我错过什么了吗?例如,如果在绘制的新区域下有大约500个管脚,则“相交”方法仅返回100个或更多的管脚

我的Spider群集配置: `Microsoft.Maps.loadModule(['SpiderClusterManager'],函数(){

`

“drawingEnded”事件后触发的交叉口功能代码: `函数findIntersectingData(搜索区域){ //确保搜索区域是一个有效的多边形,当它自动关闭时,它的环中应该有4个位置。 if(searchArea&&searchArea.getLocations().length>=4){

//从pinLayer获取所有图钉。
//var pins=spiderManager.\u数据;
//使用空间数学查找与绘制的搜索区域相交的所有图钉。
//返回的数据是相交数据的副本,而不是对原始形状的引用,
//因此,对其进行编辑不会导致地图上的任何更新。
var intersectingPins=Microsoft.Maps.SpatialMath.Geometry.intersection(pins,searchArea);
//交集函数返回的数据可以是null、单个形状或形状数组。
if(交叉销){
//为便于使用,请将单个形状包装在阵列中。
if(相交管脚和!(阵列的相交管脚实例)){
相交管脚=[相交管脚];
}
var-selectedPins=[];
//通过比较相交图钉的坐标,将相交图钉循环并映射回其原始图钉。
对于(var j=0;j
`

函数未返回准确的pin数据, 我是不是遗漏了什么

感谢您的帮助

谢谢和问候, 肖希尔·塞提亚

更新:

刚刚计算过,这是一个假设,我在图层上有多个坐标相同的管脚,这是它只返回与地图上不同坐标相交的管脚的原因吗

谢谢和问候,
Shohil Sethia

该方法返回表示交叉点的对象,而不是输入形状的精确副本。因此,是的,如果多个具有相同坐标的图钉位于该区域内,则结果中将仅包含该坐标的一个图钉,因为仅此一个图钉就足以作为表示

您可以尝试以下示例,只返回一个图钉:

// Creates a polygon of current map bounds
var polygon = new Microsoft.Maps.SpatialMath.locationRectToPolygon(map.getBounds());

// Creates a bunch of the pushpins of the same coordinates(map center)
var pushpin1 = new Microsoft.Maps.Pushpin(map.getCenter());
var pushpin2 = new Microsoft.Maps.Pushpin(map.getCenter());
var pushpin3 = new Microsoft.Maps.Pushpin(map.getCenter());
var pushpin4 = new Microsoft.Maps.Pushpin(map.getCenter());
var pushpin5 = new Microsoft.Maps.Pushpin(map.getCenter());

// Adds the shapes to map for some visualization
map.entities.push([polygon, pushpin1, pushpin2, pushpin3, pushpin4, pushpin5]);

// Only one pushpin is returned as result
var intersectingPin = Microsoft.Maps.SpatialMath.Geometry.intersection([pushpin1, pushpin2, pushpin3, pushpin4, pushpin5], polygon);

您是否检查了在考虑重复销时结果的数量是否增加了?

我得到了一个解决方案,因为相交API忽略了具有相同坐标的多个图钉,因此有另一个名为的API包含,它采用两个参数,即形状和图钉,并返回s是否包含在该形状中。如果图钉位于该形状中,则为true,反之为false

        function findIntersectingData(searchArea) {
        //Ensure that the search area is a valid polygon, should have 4 Locations in it's ring as it automatically closes.
        if (searchArea && searchArea.getLocations().length >= 4) {
            var selectedPins = [];
            for (var i = 0; i < pins.length; i++) {
                if (Microsoft.Maps.SpatialMath.Geometry.contains(searchArea, pins[i])) {
                    selectedPins.push(pins[i]);
                }
            }
            //Return the pushpins that were selected.
            console.log(selectedPins);
            //return updatePrescriberTerr(selectedPins);
            return selectedPins;
        }
        return null;
    }
函数findIntersectingData(搜索区域){
//确保搜索区域是一个有效的多边形,当它自动关闭时,它的环中应该有4个位置。
if(searchArea&&searchArea.getLocations().length>=4){
var-selectedPins=[];
对于(变量i=0;i
因此,在上述函数中,我们可以从图钉数组循环它,并根据布尔值形成相应的交集

希望对类似情况的人有所帮助

问候,


Shohil Sethia

它没有加起来,预计大约300个,它返回大约100个或更多,我正在尝试找到一个替代解决方案,有没有?您是否确定了任何样本图钉,其坐标应该在区域多边形中,但不在相交结果中?如果有,您可以创建该场景的样本代码吗?我有一个解决方案,请参考答案并发表您的评论。
// Creates a polygon of current map bounds
var polygon = new Microsoft.Maps.SpatialMath.locationRectToPolygon(map.getBounds());

// Creates a bunch of the pushpins of the same coordinates(map center)
var pushpin1 = new Microsoft.Maps.Pushpin(map.getCenter());
var pushpin2 = new Microsoft.Maps.Pushpin(map.getCenter());
var pushpin3 = new Microsoft.Maps.Pushpin(map.getCenter());
var pushpin4 = new Microsoft.Maps.Pushpin(map.getCenter());
var pushpin5 = new Microsoft.Maps.Pushpin(map.getCenter());

// Adds the shapes to map for some visualization
map.entities.push([polygon, pushpin1, pushpin2, pushpin3, pushpin4, pushpin5]);

// Only one pushpin is returned as result
var intersectingPin = Microsoft.Maps.SpatialMath.Geometry.intersection([pushpin1, pushpin2, pushpin3, pushpin4, pushpin5], polygon);
        function findIntersectingData(searchArea) {
        //Ensure that the search area is a valid polygon, should have 4 Locations in it's ring as it automatically closes.
        if (searchArea && searchArea.getLocations().length >= 4) {
            var selectedPins = [];
            for (var i = 0; i < pins.length; i++) {
                if (Microsoft.Maps.SpatialMath.Geometry.contains(searchArea, pins[i])) {
                    selectedPins.push(pins[i]);
                }
            }
            //Return the pushpins that were selected.
            console.log(selectedPins);
            //return updatePrescriberTerr(selectedPins);
            return selectedPins;
        }
        return null;
    }