public void ComputeWeightMatrix_Points() { NetworkAnalyst networkAnalyst = new NetworkAnalyst("http://" + ip + ":8090/iserver/services/transportationanalyst-sample/rest"); Point2D[] points = new Point2D[2]; points[0] = new Point2D() { X = 32.754, Y = 23.205 }; points[1] = new Point2D() { X = 415.55, Y = 87.66 }; double[][] weightMatrix = networkAnalyst.ComputeWeightMatrix("RoadNet@Changchun", points); Assert.IsNotNull(weightMatrix); Assert.IsTrue(weightMatrix.Length == 2); Assert.IsTrue(weightMatrix[0].Length == 2); Assert.IsTrue(weightMatrix[1][0] == 446.26723858569954); }
public void ComputeWeightMatrix_IDError() { NetworkAnalyst networkAnalyst = new NetworkAnalyst("http://" + ip + ":8090/iserver/services/transportationanalyst-sample/rest"); TransportationAnalystParameter parameter = new TransportationAnalystParameter(); parameter.WeightFieldName = "length"; parameter.TurnWeightField = "TurnCost"; List<int> nodes = new List<int>() { -2, 6, 9 }; try { double[][] weightMatrix = networkAnalyst.ComputeWeightMatrix("RoadNet@Changchun", nodes.ToArray()); } catch (ServiceException exception) { //Assert.IsTrue("执行 findWeightMatrix 操作时出错,原因是:网络数据集中节点ID数组错误" == exception.Message); Assert.IsTrue(exception.Code == 400); } }
public void ComputeWeightMatrix_NodeIDs() { NetworkAnalyst networkAnalyst = new NetworkAnalyst("http://" + ip + ":8090/iserver/services/transportationanalyst-sample/rest"); TransportationAnalystParameter parameter = new TransportationAnalystParameter(); parameter.WeightFieldName = "length"; parameter.TurnWeightField = "TurnCost"; List<int> nodes = new List<int>() { 2, 6, 9 }; double[][] weightMatrix = networkAnalyst.ComputeWeightMatrix("RoadNet@Changchun", nodes.ToArray(), null); Assert.IsNotNull(weightMatrix); Assert.IsTrue(weightMatrix.Length == 3); Assert.IsTrue(weightMatrix[0].Length == 3); Assert.IsTrue(weightMatrix[0][1] == 454); }