public SegmentsForm(xRouteWSService.RouteResponse routeResp) { InitializeComponent(); foreach (var item in routeResp.segments) { segmentBindingSource.Add(item); } }
public void CalcRoute() { dynMap.Layers.Remove(routingLayer); setFeatureLayerConfiguration(); lbxTollSummary.Items.Clear(); tbxRouteResultTime.Clear(); tbxRouteResultDistance.Clear(); tbxRouteResultViolations.Clear(); List <xRouteWSService.InputWaypoint> wayPointList = new List <xRouteWSService.InputWaypoint>(); xRouteWSService.InputWaypoint[] ipw = null; routeRequest = new xRouteWSService.RouteRequest { coordinateFormat = cbxCoordFormat.Text,//"EPSG:76131", storedProfile = cbxStoredProfile.Text, }; var emissionOptionsSet = new xRouteWSService.EmissionValueScenario[] { }; if (cbxEmissions.Checked == true) { emissionOptionsSet = new xRouteWSService.EmissionValueScenario[] { new xRouteWSService.EmissionValueScenario_HBEFA_3_2() { scenarios = new xRouteWSService.EmissionValueScenarioType_HBEFA_3_2[] { xRouteWSService.EmissionValueScenarioType_HBEFA_3_2.CURRENT_ROUTE } } }; } else { emissionOptionsSet = null; } routeRequest.routeOptions = new xRouteWSService.RouteOptions() { emissionOptions = new xRouteWSService.EmissionOptions { valueScenarios = emissionOptionsSet, } }; string nCList = tbxNetworkClassPenalties.Text; List <int> nCs = nCList.Split(',').Select(int.Parse).ToList(); routeRequest.requestProfile = new xRouteWSService.RequestProfile() { featureLayerProfile = new xRouteWSService.FeatureLayerProfile() { themes = new xRouteWSService.Theme[] { truckAttributesTheme, generalTruckRestrictionsTheme, trafficIncidentsTheme, speedPatternsTheme }, }, routingProfile = new xRouteWSService.RoutingProfile() { linking = new xRouteWSService.Linking() { maximumDistanceToSegmentSpecified = true, maximumDistanceToSegment = double.Parse(tbxMaximumDistanceToSegment.Text), }, course = new xRouteWSService.Course() { distanceTimeWeightingSpecified = true, distanceTimeWeighting = double.Parse(tbxDistanceTimeWeighting.Text.Replace(".", ",")), violations = new xRouteWSService.Violations() { enabledSpecified = true, enabled = Boolean.Parse(tbxViolationsEnabled.Text), costSpecified = true, cost = int.Parse(tbxViolationsCost.Text) }, specialAreas = new xRouteWSService.SpecialAreas() { residentsOnlyPenaltySpecified = true, residentsOnlyPenalty = int.Parse(tbxResidentsOnlyPenalty.Text), urbanPenaltySpecified = true, urbanPenalty = int.Parse(tbxUrbanPenalty.Text), minimumUrbanNetworkClassSpecified = true, minimumUrbanNetworkClass = int.Parse(tbxMinimumUrbanNetworkClass.Text), forbiddenLowEmissionZonePenaltySpecified = true, forbiddenLowEmissionZonePenalty = int.Parse(tbxForbiddenLEZPenal.Text), deliveryOnlyPenaltySpecified = true, deliveryOnlyPenalty = int.Parse(tbxDeliveryOnlyPenalty.Text), deliveryOnlyGateCostSpecified = true, deliveryOnlyGateCost = int.Parse(tbxDeliveryOnlyGateCost.Text), }, toll = new xRouteWSService.Toll() { tollPenaltySpecified = true, tollPenalty = int.Parse(tbxTollPenalty.Text), }, network = new xRouteWSService.Network() { rampPenaltySpecified = true, rampPenalty = 10, penaltiesByNetworkClass = new xRouteWSService.PenaltiesByNetworkClass() { penalties = nCs.ToArray() //penalties = new int[8] { 2500, 2500, 2500, 2500, 15, 50, 100, 100 } } }, }, }, vehicleProfile = new xRouteWSService.VehicleProfile() { engine = new xRouteWSService.Engine() { cylinderCapacitySpecified = true, cylinderCapacity = int.Parse(textBoxCylinderCapacity.Text), fuelTypeSpecified = true, fuelType = (xRouteWSService.FuelType)System.Enum.Parse(typeof(xRouteWSService.FuelType), cbxFuelType.Text), emissionTechnologySpecified = true, emissionTechnology = (xRouteWSService.EmissionTechnology)System.Enum.Parse(typeof(xRouteWSService.EmissionTechnology), cbxEmissionTechnology.Text), fuelConsumptionSpecified = true, fuelConsumption = double.Parse(textBoxFuelConsumption.Text), bioFuelRatioSpecified = true, bioFuelRatio = double.Parse(textBoxBioFuelRatio.Text), emissionStandardEUSpecified = true, emissionStandardEU = (xRouteWSService.EmissionStandardEU)System.Enum.Parse(typeof(xRouteWSService.EmissionStandardEU), cbxEmissionStandardEU.Text), }, weight = new xRouteWSService.Weight() { emptyWeightSpecified = true, emptyWeight = double.Parse(tbxEmptyWeight.Text), totalPermittedWeightSpecified = true, totalPermittedWeight = double.Parse(tbxTotalPermWeight.Text), loadWeightSpecified = true, loadWeight = double.Parse(tbxLoadWeight.Text), }, dimensions = new xRouteWSService.Dimensions() { heightSpecified = true, height = double.Parse(tbxHeight.Text), widthSpecified = true, width = double.Parse(tbxWidth.Text), lengthSpecified = true, length = double.Parse(tbxLength.Text), }, load = new xRouteWSService.Load() { loadTypeSpecified = true, loadType = (xRouteWSService.LoadType)System.Enum.Parse(typeof(xRouteWSService.LoadType), cbxLoadType.Text), hazardousGoodsTypes = cbxHazardousGoodsType.Text, tunnelRestrictionCodeSpecified = true, tunnelRestrictionCode = (xRouteWSService.TunnelRestrictionCode)System.Enum.Parse(typeof(xRouteWSService.TunnelRestrictionCode), cbxTunnelRestrictionCode.Text), }, legalCondition = new xRouteWSService.LegalCondition() { isDeliverySpecified = true, isDelivery = cbxIsDelivery.Checked, isEmergencySpecified = true, isEmergency = cbxIsEmergency.Checked, } } }; if (tbxStartX.Text != "") { //var bla = (xRouteWSService.InputWaypoint)System.Enum.Parse(typeof(xRouteWSService.InputWaypoint), cbxWptTypeDest.Text); var wptStart = new xRouteWSService.OffRoadWaypoint() { name = "Start", location = new xRouteWSService.OffRoadRouteLocation() { offRoadCoordinate = new xRouteWSService.Coordinate() { x = double.Parse(tbxStartX.Text.Replace(".", ",")), y = double.Parse(tbxStartY.Text.Replace(".", ",")) } } }; wayPointList.Add(wptStart); if (cbxManipulateWpt.Checked == true) { var wptVia = new xRouteWSService.ManipulateRouteWaypoint() { name = "Via", radiusSpecified = true, radius = double.Parse(tbxRadiusValue.Text), coordinate = new xRouteWSService.Coordinate() { x = double.Parse(tbxViaX.Text.Replace(".", ",")), y = double.Parse(tbxViaY.Text.Replace(".", ",")) } }; wayPointList.Add(wptVia); } var wptDest = new xRouteWSService.OffRoadWaypoint() { name = "Destination", location = new xRouteWSService.OffRoadRouteLocation() { offRoadCoordinate = new xRouteWSService.Coordinate() { x = double.Parse(tbxDestX.Text.Replace(".", ",")), y = double.Parse(tbxDestY.Text.Replace(".", ",")) } } }; wayPointList.Add(wptDest); } else { MessageBox.Show("Not enough waypoints!"); return; } ipw = wayPointList.ToArray(); routeRequest.waypoints = ipw; //verwijs hier naar een array van het type inputwaypoint routeRequest.resultFields = new xRouteWSService.ResultFields() { legs = new xRouteWSService.LegResultFields() { enabledSpecified = true, enabled = cbxLegs.Checked, }, segments = new xRouteWSService.SegmentResultFields() { enabledSpecified = true, enabled = cbxSegments.Checked, //polylineSpecified = true, //polyline = true, descriptorsSpecified = true, descriptors = cbxDescriptors.Checked, //emissionsSpecified = true, //emissions = true, roadAttributesSpecified = true, roadAttributes = cbxRoadAttributes.Checked, //featureThemeIds = new }, polyline = cbxPolyline.Checked, polylineSpecified = true, toll = new xRouteWSService.TollResultFields() { enabledSpecified = true, enabled = cbxTollCalculation.Checked, sectionsSpecified = true, sections = cbxTollSections.Checked, systemsSpecified = true, systems = cbxTollSystems.Checked, }, emissionsSpecified = true, emissions = cbxEmissions.Checked, }; try { routeResponse = xRouteClient.calculateRoute(routeRequest); } catch (System.Web.Services.Protocols.SoapException soapException) { System.Windows.Forms.MessageBox.Show(soapException.Detail.InnerXml.Replace(">", ">\r\n")); return; } catch (System.ServiceModel.FaultException faultException) { System.Windows.Forms.MessageBox.Show("Error when trying to calculate the route" + "\r\n" + faultException.Message); return; } catch (Exception ex) { MessageBox.Show(ex.Message); return; } tbxRouteResultTime.Text = Math.Round((routeResponse.travelTime / 3600.0), 2).ToString(); tbxRouteResultDistance.Text = Math.Round((routeResponse.distance / 1000.0), 2).ToString(); tbxRouteResultViolations.Text = routeResponse.violated.ToString(); if (routeResponse.toll.summary != null) { foreach (xRouteWSService.Cost cost in routeResponse.toll.summary.costs) { lbxTollSummary.Items.Add(cost.currency + " - " + cost.amount); } } if (cbxSegments.Checked == true) { dataGridRouteSegments.AutoResizeColumns(); dataGridRouteSegments.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; foreach (var item in routeResponse.segments) { segmentBindingSource.Add(item); } } //EXPERIMENTAL UNTIL EMISSIONS WORKS /*/if (cbxEmissions.Checked == true) * { * DataTable transposedTable = GenerateTransposedTable(ToDataTable<xRouteWSService.EmissionValues_HBEFA_3_2>(routeResponse.emissions.values.Select(e => e as xRouteWSService.EmissionValues_HBEFA_3_2).ToList())); * * dataGridViewEmissions.DataSource = GenerateTransposedTable(ToDataTable<xRouteWSService.EmissionValues_HBEFA_3_2>(routeResponse.emissions.values.Select(e => e as xRouteWSService.EmissionValues_HBEFA_3_2).ToList())) as DataTable; * }/*/ ShowRouteInDynMap(); }