/// <summary> /// 求出点到公路网的对应点 /// </summary> /// <param name="featureLayer"></param> /// <param name="stopPoints"></param> /// <param name="barryPoints"></param> /// <param name="newStopPoints"></param> /// <param name="newBarryPoints"></param> /// <returns></returns> bool UpdatePointsToRouteCore(IFeatureLayer featureLayer) { List <IPoint> newStopPoints = new List <IPoint>(); List <IPoint> newBarryPoints = new List <IPoint>(); foreach (var point in stopPoints) { double distance = 0; int disNum = 0; IFeature feature = null; IPoint rightPoint = DistanceUtil.GetNearestLineInFeatureLayer(featureLayer, point, ref feature, ref distance, ref disNum, 0.15); if (rightPoint == null) { return(false); } newStopPoints.Add(rightPoint); } foreach (var point in barryPoints) { double distance = 0; int disNum = 0; IFeature feature = null; IPoint rightPoint = DistanceUtil.GetNearestLineInFeatureLayer(featureLayer, point, ref feature, ref distance, ref disNum, 0.1); if (rightPoint == null) { return(false); } newBarryPoints.Add(rightPoint); } this.stopPoints = newStopPoints; this.barryPoints = newBarryPoints; return(true); }
public bool QueryTheRoue(IPoint breakPoint, AxMapControl mapControl, IFeatureLayer featureLayer, string dbPath, string featureSetName, string ndsName, ref IPoint rightPoint) { IFeature feature = null; double distance = 0; int distNum = 0; rightPoint = DistanceUtil.GetNearestLineInFeatureLayer(featureLayer, breakPoint, ref feature, ref distance, ref distNum); if (rightPoint == null) { return(false); } //获取线要素的点集合 IPointCollection lineCollection = feature.Shape as IPointCollection; //实例化站点和障碍点要素 IFeatureClass stopFeatureClass = FeatureClassUtil.CreateMemorySimpleFeatureClass(esriGeometryType.esriGeometryPoint, mapControl.SpatialReference, "stops"); IFeatureClass barriesFeatureClass = FeatureClassUtil.CreateMemorySimpleFeatureClass(esriGeometryType.esriGeometryPoint, mapControl.SpatialReference, "barries"); //添加站点 FeatureClassUtil.InsertSimpleFeature(lineCollection.get_Point(0), stopFeatureClass); FeatureClassUtil.InsertSimpleFeature(lineCollection.get_Point(lineCollection.PointCount - 1), stopFeatureClass); //添加障碍 FeatureClassUtil.InsertSimpleFeature(rightPoint, barriesFeatureClass); //组装站点和障碍点要素 IDictionary <string, DecorateRouteFeatureClass> featureClasses = new Dictionary <string, DecorateRouteFeatureClass>(); featureClasses.Add("Stops", new DecorateRouteFeatureClass(0.2, stopFeatureClass)); featureClasses.Add("Barriers", new DecorateRouteFeatureClass(0.2, barriesFeatureClass)); ILayer routeLayer = null; //最短路径分析 return(NormalNetworkUtil.Short_Path(mapControl, dbPath, featureSetName, ndsName, featureClasses, false, false, ref routeLayer)); }
private double calculateTotalDistance(BasicGeoposition lastPos, BasicGeoposition newPos) { if (newPos.Equals(lastPos)) { return(this.dist); } DistanceUtil util = new DistanceUtil(); double tmpDist = util.distance(lastPosition.Latitude, lastPosition.Longitude, newPos.Latitude, newPos.Longitude, 'K'); return(this.dist + tmpDist); }
void GetAnchorDistancesForTestPoint(int testPointIndex) { BluetoothConnector.States bluetoothConnectorAction = BluetoothConnector.currentAction(); bool bluetoothConnectorSuccess = BluetoothConnector.actionSuccessful(); if (bluetoothConnectorAction == BluetoothConnector.States.Subscribe && bluetoothConnectorSuccess) { BluetoothBytes bluetoothBytes = CurrentBluetoothBytes(); foreach (string anchorName in AnchorNames) { int distance = DistanceUtil.DistanceToNode(anchorName, bluetoothBytes); anchorToTestPoints[anchorName][testPointIndex] = (double)distance; } } }
/// <summary> /// 查询配置文件中线要素集合中离点最近的元素 /// </summary> /// <param name="point"></param> /// <param name="map"></param> /// <param name="featureLayer"></param> /// <param name="p"></param> /// <returns></returns> private IFeature QueryTheRightFeatureByPoint(IPoint point, IFeatureLayer featureLayer, ref IPoint rightPoint) { List <IFeature> featuers = QueryAllFeatureInConfig(featureLayer); IFeature feature = null; double resultDistance = 9999999999; foreach (IFeature value in featuers) { double tempValue = 0; int disNum = 0; IPoint tempPoint = DistanceUtil.GetNearestLine(value.Shape as IPolyline, point, ref tempValue, ref disNum); if (tempValue < resultDistance) { resultDistance = tempValue; feature = value; rightPoint = tempPoint; } } return(feature); }
public IPolyline QueryTheRoue2(IPoint breakPoint, IMap pMap, IFeatureLayer featureLayer, string dbPath, ref IPoint rightPoint) { IFeature feature = null; double distance = 0; int distNum = 0; rightPoint = DistanceUtil.GetNearestLineInFeatureLayer(featureLayer, breakPoint, ref feature, ref distance, ref distNum); if (rightPoint == null) { return(null); } //获取线要素的点集合 IPointCollection lineCollection = feature.Shape as IPointCollection; //将线要素的起点和终点加入路线点集合中 IPointCollection routePointCollection = new MultipointClass(); routePointCollection.AddPoint(lineCollection.get_Point(0)); routePointCollection.AddPoint(lineCollection.get_Point(lineCollection.PointCount - 1)); //查询最短路径 IPolyline polyline = UtilityNetWorkUtil.DistanceFun(pMap, dbPath, "roads", 1, routePointCollection, "length", 50); return(polyline); }
public CustomJsonResult List(string operater, string clientUserId, RupStoreList rup) { var result = new CustomJsonResult(); var stores = CurrentDb.Store.Where(m => m.MerchId == rup.MerchId && m.IsDelete == false).ToList(); var storeModels = new List <StoreModel>(); foreach (var m in stores) { double distance = 0; string distanceMsg = ""; if (rup.Lat == 0 || rup.Lng == 0) { distanceMsg = ""; } else { distance = DistanceUtil.GetDistance(m.Lat, m.Lng, rup.Lat, rup.Lng); distanceMsg = string.Format("{0}km", distance.ToString("f2")); } storeModels.Add(new StoreModel { Id = m.Id, Name = m.Name, Address = m.Address, Distance = distance, DistanceMsg = distanceMsg }); } storeModels = storeModels.OrderBy(m => m.Distance).ToList(); result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "", storeModels); return(result); }
public double CalculateDistance(Coordinate p1, Coordinate p2) { return(DistanceUtil.GetDistance(p1.ToNative(), p2.ToNative())); }