/// <summary> /// 拷贝的构造函数。 /// </summary> /// <param name="locationAnalystParameter">LocationAnalystParameter 对象实例。</param> public LocationAnalystParameter(LocationAnalystParameter locationAnalystParameter) { if (locationAnalystParameter == null) { throw new ArgumentNullException("locationAnalystParameter"); } this.ExpectedSupplyCenterCount = locationAnalystParameter.ExpectedSupplyCenterCount; this.IsFromCenter = locationAnalystParameter.IsFromCenter; //this.NodeDemandField = locationAnalystParameter.NodeDemandField; this.ReturnEdgeFeatures = locationAnalystParameter.ReturnEdgeFeatures; this.ReturnEdgeGeometry = locationAnalystParameter.ReturnEdgeGeometry; this.ReturnNodeFeatures = locationAnalystParameter.ReturnNodeFeatures; if (locationAnalystParameter.SupplyCenters != null) { this.SupplyCenters = new List<SupplyCenter>(); for (int i = 0; i < locationAnalystParameter.SupplyCenters.Count; i++) { if (locationAnalystParameter.SupplyCenters[i] != null) { this.SupplyCenters.Add(new SupplyCenter(locationAnalystParameter.SupplyCenters[i])); } else { this.SupplyCenters.Add(null); } } } this.TurnWeightField = locationAnalystParameter.TurnWeightField; this.WeightName = locationAnalystParameter.WeightName; }
/// <summary> /// 选址分区分析。 /// </summary> /// <param name="networkDatasetName">用于唯一标识一个网络数据集的字符串,必设字段。</param> /// <param name="parameter">选址分析参数。</param> /// <returns>选址分析结果。</returns> /// <exception cref="ArgumentNullException">参数 networkDatasetName、parameter 为空时抛出异常。</exception> /// <exception cref="SuperMap.Connector.Utility.ServiceException">服务端处理错误时抛出异常。</exception> /// <remarks> /// <para>选址分区分析是为了确定一个或多个待建设施的最佳或最优位置, 使得设施可以用一种最经济有效的方式为需求方提供服务或者商品。 选址分区不仅仅是一个选址过程,还要将需求点的需求分配到相应的新建设施的服务区中,因此称之为选址与分区。</para> /// <para>在选址分区分析过程中,资源供给中心以及分析模式的设定是在 LocationAnalystParameter 类型的参数 parameter 中实现的,具体细节参见 <see cref="SuperMap.Connector.Utility.LocationAnalystParameter"/> 类。</para> /// <para>在分析过程中使用的需求点都为网络结点,即除了各种类型的中心点所对应的网络结点, 所有网络结点都作为资源需求点参与选址分区分析,如果要排除某部分结点,可以将其设置为障碍点。</para> /// <para>以下例子说明了选址分区的应用:某个区域还没有邮局,现要在这个区域内建立邮局,有15个待选地点(如左图所示,蓝色方框代表15个候选地点),将在这些待选点中选择7个最佳地点建立邮局。最佳选址要满足,居民点中的居民步行去邮局办理业务 /// 的步行时间要在30分钟以内,同时每个邮局能够服务的居民总人数有限,在同时满足这两个条件的基础上,选址分区分析会给出以个最佳的选址位置,并且圈出每个邮局的服务区域(如右图所示,红色点表示最后选出的7个建立邮局的最佳位置)。备注:下面 /// 两幅中的网络数据集的所有网络结点被看做是该区域的居民点全部参与选址分区分析,居民点中的居民数目即为该居民点所需服务的数量。</para> /// <para> /// <img src="../../../../CHM/interfacesimges/NetworkAnalyst/findlocation/findlocation1.png"></img> /// <img src="../../../../CHM/interfacesimges/NetworkAnalyst/findlocation/findlocation2.png"></img> /// </para> /// </remarks> /// <example> /// <code> ///using System; ///using System.Collections.Generic; ///using System.Text; ///using SuperMap.Connector; ///using SuperMap.Connector.Utility; /// ///class Program ///{ /// static void Main(string[] args) /// { /// //初始化。 /// NetworkAnalyst networkAnalyst = new NetworkAnalyst("http://*****:*****@Changchun", parameter); /// //需求结果个数为:13 /// //资源供给中心点结果个数为:2 /// } ///} /// </code> /// </example> public LocationAnalystResult FindLocation(string networkDatasetName, LocationAnalystParameter parameter) { return _netWorkAnalystProvider.FindLocation(networkDatasetName, parameter); }
public void FindLocation_CountSet() { NetworkAnalyst networkAnalyst = new NetworkAnalyst("http://" + ip + ":8090/iserver/services/transportationanalyst-sample/rest"); LocationAnalystParameter parameter = new LocationAnalystParameter(); parameter.WeightName = "length"; parameter.TurnWeightField = "TurnCost"; parameter.ReturnEdgeFeatures = true; parameter.ReturnEdgeGeometry = true; parameter.ReturnNodeFeatures = true; parameter.IsFromCenter = true; parameter.SupplyCenters = new List<SupplyCenter>(); parameter.SupplyCenters.Add(new SupplyCenter() { NodeID = -11, MaxWeight = 100, Type = SupplyCenterType.FIXEDCENTER }); parameter.SupplyCenters.Add(new SupplyCenter() { NodeID = 12, MaxWeight = 100, Type = SupplyCenterType.OPTIONALCENTER }); parameter.ExpectedSupplyCenterCount = 1; LocationAnalystResult result = networkAnalyst.FindLocation("RoadNet@Changchun", parameter); Assert.IsNotNull(result); Assert.IsTrue(result.DemandResults != null); Assert.IsTrue(result.DemandResults.Count == 0); Assert.IsTrue(result.SupplyResults.Count == 1); Assert.IsTrue(result.SupplyResults != null); Assert.IsTrue(result.SupplyResults[0].AverageWeight == -1.0); }
public void FindLocation_NetworkDatasetNameNotFound() { NetworkAnalyst networkAnalyst = new NetworkAnalyst("http://" + ip + ":8090/iserver/services/transportationanalyst-sample/rest"); LocationAnalystParameter parameter = new LocationAnalystParameter(); parameter.WeightName = "length"; parameter.TurnWeightField = "TurnCost"; parameter.ReturnEdgeFeatures = true; parameter.ReturnEdgeGeometry = true; parameter.ReturnNodeFeatures = true; parameter.IsFromCenter = true; parameter.SupplyCenters = new List<SupplyCenter>(); parameter.SupplyCenters.Add(new SupplyCenter() { NodeID = 11, MaxWeight = 100, Type = SupplyCenterType.FIXEDCENTER }); parameter.SupplyCenters.Add(new SupplyCenter() { NodeID = 12, MaxWeight = 100, Type = SupplyCenterType.OPTIONALCENTER }); parameter.ExpectedSupplyCenterCount = 2; try { LocationAnalystResult result = networkAnalyst.FindLocation("RoadNet1@Changchun", parameter); } catch (ServiceException exception) { Assert.IsTrue("不存在RoadNet1@Changchun对应的网络数据集。" == exception.Message); Assert.IsTrue(exception.Code == 400); } }