public static dynamic GetTSObject(LineAttributes dynObject) { if (dynObject is null) { return(null); } return(dynObject.teklaObject); }
public T[] LineAttributeArray <T>(Symbol name) { if (LineAttributes.TryGetValue(name, out Array array)) { return((T[])array); } return(null); }
private Geometry CreatePolyline() { if (Point1 == null || Point2 == null) { return(null); } var nameConverter = new EnumToFriendlyNameConverter(); GeodeticCurveType curveType = DeriveCurveType(LineType); LinearUnit lu = DeriveUnit(LineDistanceType); try { // create line var polyline = QueuedTask.Run(() => { var point2Proj = GeometryEngine.Instance.Project(Point2, Point1.SpatialReference); var segment = LineBuilder.CreateLineSegment(Point1, (MapPoint)point2Proj); return(PolylineBuilder.CreatePolyline(segment)); }).Result; Geometry newline = GeometryEngine.Instance.GeodeticDensifyByLength(polyline, 0, lu, curveType); var displayValue = nameConverter.Convert(LineDistanceType, typeof(string), new object(), CultureInfo.CurrentCulture); // Hold onto the attributes in case user saves graphics to file later LineAttributes lineAttributes = new LineAttributes() { mapPoint1 = Point1, mapPoint2 = Point2, distance = distance, angle = (double)azimuth, angleunit = LineAzimuthType.ToString(), distanceunit = displayValue.ToString(), originx = Point1.X, originy = Point1.Y, destinationx = Point2.X, destinationy = Point2.Y }; CreateLineFeature(newline, lineAttributes); ResetPoints(); return((Geometry)newline); } catch (Exception ex) { // do nothing System.Diagnostics.Debug.WriteLine(ex.Message); return(null); } }
private async void CreateLineFeature(Geometry geom, LineAttributes lineAttributes) { string message = string.Empty; await QueuedTask.Run(async() => message = await AddFeatureToLayer(geom, lineAttributes)); RaisePropertyChanged(() => HasMapGraphics); if (!string.IsNullOrEmpty(message)) { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(message, DistanceAndDirectionLibrary.Properties.Resources.ErrorFeatureCreateTitle); } }
private Geometry CreatePolyline() { if (Point1 == null || Point2 == null) { return(null); } GeodeticCurveType curveType = DeriveCurveType(LineType); LinearUnit lu = DeriveUnit(LineDistanceType); try { // create line var polyline = QueuedTask.Run(() => { var point2Proj = GeometryEngine.Instance.Project(Point2, Point1.SpatialReference); var segment = LineBuilder.CreateLineSegment(Point1, (MapPoint)point2Proj); return(PolylineBuilder.CreatePolyline(segment)); }).Result; Geometry newline = GeometryEngine.Instance.GeodeticDensifyByLength(polyline, 0, lu, curveType); // Hold onto the attributes in case user saves graphics to file later LineAttributes lineAttributes = new LineAttributes() { mapPoint1 = Point1, mapPoint2 = Point2, _distance = distance, angle = (double)azimuth, angleunit = LineAzimuthType.ToString(), distanceunit = LineDistanceType.ToString(), originx = Point1.X, originy = Point1.Y, destinationx = Point2.X, destinationy = Point2.Y }; AddGraphicToMap(newline, (ProGraphicAttributes)lineAttributes); ResetPoints(); return(newline as Geometry); } catch (Exception ex) { // do nothing return(null); } }
private async Task <string> AddFeatureToLayer(Geometry geom, LineAttributes attributes) { string message = String.Empty; if (attributes == null) { message = "Attributes are Empty"; // For debug does not need to be resource return(message); } FeatureClass lineFeatureClass = await GetFeatureClass(addToMapIfNotPresent : true); if (lineFeatureClass == null) { message = DistanceAndDirectionLibrary.Properties.Resources.ErrorFeatureClassNotFound + this.GetLayerName(); return(message); } bool creationResult = false; FeatureClassDefinition lineDefinition = lineFeatureClass.GetDefinition(); EditOperation editOperation = new EditOperation(); editOperation.Name = "Line Feature Insert"; editOperation.Callback(context => { try { RowBuffer rowBuffer = lineFeatureClass.CreateRowBuffer(); if (lineDefinition.FindField("Distance") >= 0) { rowBuffer["Distance"] = attributes.distance; // Double } if (lineDefinition.FindField("DistUnit") >= 0) { rowBuffer["DistUnit"] = attributes.distanceunit; // Text } if (lineDefinition.FindField("Angle") >= 0) { rowBuffer["Angle"] = attributes.angle; // Double } if (lineDefinition.FindField("AngleUnit") >= 0) { rowBuffer["AngleUnit"] = attributes.angleunit; // Text } if (lineDefinition.FindField("OriginX") >= 0) { rowBuffer["OriginX"] = attributes.originx; // Double } if (lineDefinition.FindField("OriginY") >= 0) { rowBuffer["OriginY"] = attributes.originy; // Double } if (lineDefinition.FindField("DestX") >= 0) { rowBuffer["DestX"] = attributes.destinationx; // Double } if (lineDefinition.FindField("DestY") >= 0) { rowBuffer["DestY"] = attributes.destinationy; // Double } // Ensure Geometry Has Z var geomZ = geom; if (!geom.HasZ) { PolylineBuilder pb = new PolylineBuilder((Polyline)geom); pb.HasZ = true; geomZ = pb.ToGeometry(); } rowBuffer["Shape"] = GeometryEngine.Instance.Project(geomZ, lineDefinition.GetSpatialReference()); Feature feature = lineFeatureClass.CreateRow(rowBuffer); feature.Store(); //To Indicate that the attribute table has to be updated context.Invalidate(feature); } catch (GeodatabaseException geodatabaseException) { message = geodatabaseException.Message; } catch (Exception ex) { message = ex.Message; } }, lineFeatureClass); await QueuedTask.Run(async() => { creationResult = await editOperation.ExecuteAsync(); }); if (!creationResult) { message = editOperation.ErrorMessage; } return(message); }
protected override void AddSpecifiedAttributes() { //Add IRequestAttribute types AddAttribute(RoutingMode); foreach (var wp in Waypoints) { AddAttribute(wp); } if (Resolution != null) { AddAttribute(Resolution); } if (JsonAttributes != null) { AddAttribute(JsonAttributes); } if (GeneralizationTolerances != null) { AddAttribute(GeneralizationTolerances); } if (VehicleType != null) { AddAttribute(VehicleType); } if (ConsumptionModel != null) { AddAttribute(ConsumptionModel); } if (CustomConsumptionDetails != null) { AddAttribute(CustomConsumptionDetails); } AddAttribute(new JsonRepresentation(JsonAttribute.Include_TypeElement, JsonAttribute.UsePluralNamingForCollections, JsonAttribute.SupressJsonResponseObjectWrapper)); //Other parameters if (RequestId != null) { AddAttribute(PropertyHelper.GetDescription(() => RequestId), RequestId); } if (AvoidAreas != null) { AddAttribute(PropertyHelper.GetDescription(() => AvoidAreas), string.Join("!", AvoidAreas.Select(aa => aa.GetAttributeValue()).ToArray())); } if (AvoidLinks != null) { AddAttribute(PropertyHelper.GetDescription(() => AvoidLinks), string.Join(",", AvoidLinks.Select(al => al.GetAttributeValue()).ToArray())); } if (AvoidSeasonalClosures != null) { AddAttribute(PropertyHelper.GetDescription(() => AvoidSeasonalClosures), AvoidSeasonalClosures.ToString().ToLower()); } if (AvoidTurns != null) { AddAttribute(PropertyHelper.GetDescription(() => AvoidTurns), string.Join(",", AvoidTurns.Select(at => EnumHelper.GetDescription(at)))); } if (ExcludeZones != null) { AddAttribute(PropertyHelper.GetDescription(() => ExcludeZones), string.Join(",", ExcludeZones)); } if (ExcludeCountries != null) { AddAttribute(PropertyHelper.GetDescription(() => ExcludeCountries), string.Join(",", ExcludeCountries)); } if (Departure != null) { AddAttribute(PropertyHelper.GetDescription(() => Departure), ((DateTime)Departure).ToString("s")); } if (Arrival != null) { AddAttribute(PropertyHelper.GetDescription(() => Arrival), ((DateTime)Arrival).ToString("s")); } if (Alternatives != null) { AddAttribute(PropertyHelper.GetDescription(() => Alternatives), Alternatives.ToString()); } if (UnitSystem != null) { AddAttribute(PropertyHelper.GetDescription(() => UnitSystem), EnumHelper.GetDescription(UnitSystem)); } if (ViewBounds != null) { AddAttribute(PropertyHelper.GetDescription(() => ViewBounds), ViewBounds.GetAttributeValue()); } if (InstructionFormat != null) { AddAttribute(PropertyHelper.GetDescription(() => InstructionFormat), EnumHelper.GetDescription(InstructionFormat)); } if (Language != null) { AddAttribute(PropertyHelper.GetDescription(() => Language), EnumHelper.GetDescription(Language)); } if (JsonCallback != null) { AddAttribute(PropertyHelper.GetDescription(() => JsonCallback), JsonCallback); } if (Representation != null) { AddAttribute(PropertyHelper.GetDescription(() => Representation), EnumHelper.GetDescription(Representation)); } if (RouteAttributes != null) { AddAttribute(PropertyHelper.GetDescription(() => RouteAttributes), string.Join(",", RouteAttributes.Select(ra => EnumHelper.GetDescription(ra)))); } if (LegAttributes != null) { AddAttribute(PropertyHelper.GetDescription(() => LegAttributes), string.Join(",", LegAttributes.Select(la => EnumHelper.GetDescription(la)))); } if (ManeuverAttributes != null) { AddAttribute(PropertyHelper.GetDescription(() => ManeuverAttributes), string.Join(",", ManeuverAttributes.Select(ma => EnumHelper.GetDescription(ma)))); } if (LinkAttributes != null) { AddAttribute(PropertyHelper.GetDescription(() => LinkAttributes), string.Join(",", LinkAttributes.Select(la => EnumHelper.GetDescription(la)))); } if (LineAttributes != null) { AddAttribute(PropertyHelper.GetDescription(() => LineAttributes), string.Join(",", LineAttributes.Select(la => EnumHelper.GetDescription(la)))); } if (MaxNumberOfChanges != null) { AddAttribute(PropertyHelper.GetDescription(() => MaxNumberOfChanges), MaxNumberOfChanges.ToString()); } if (AvoidTransportTypes != null) { AddAttribute(PropertyHelper.GetDescription(() => AvoidTransportTypes), string.Join(",", AvoidTransportTypes.Select(tt => EnumHelper.GetDescription(tt)))); } if (WalkTimeMultiplier != null) { AddAttribute(PropertyHelper.GetDescription(() => WalkTimeMultiplier), WalkTimeMultiplier.Value.ToString(HereAPISession.Culture)); } if (WalkSpeed != null) { AddAttribute(PropertyHelper.GetDescription(() => WalkSpeed), WalkSpeed.Value.ToString(HereAPISession.Culture)); } if (WalkRadius != null) { AddAttribute(PropertyHelper.GetDescription(() => WalkRadius), WalkRadius.Value.ToString(HereAPISession.Culture)); } if (CombineChange != null) { AddAttribute(PropertyHelper.GetDescription(() => CombineChange), CombineChange.ToString().ToLower()); } if (TruckType != null) { AddAttribute(PropertyHelper.GetDescription(() => TruckType), EnumHelper.GetDescription(TruckType)); } if (TrailersCount != null) { AddAttribute(PropertyHelper.GetDescription(() => TrailersCount), TrailersCount.ToString()); } if (ShippedHazardousGoods != null) { AddAttribute(PropertyHelper.GetDescription(() => ShippedHazardousGoods), string.Join(",", ShippedHazardousGoods.Select(sg => EnumHelper.GetDescription(sg)))); } if (LimitedWeight != null) { AddAttribute(PropertyHelper.GetDescription(() => LimitedWeight), LimitedWeight.Value.ToString(HereAPISession.Culture)); } if (WeightPerAxle != null) { AddAttribute(PropertyHelper.GetDescription(() => WeightPerAxle), WeightPerAxle.Value.ToString(HereAPISession.Culture)); } if (Height != null) { AddAttribute(PropertyHelper.GetDescription(() => Height), Height.Value.ToString(HereAPISession.Culture)); } if (Width != null) { AddAttribute(PropertyHelper.GetDescription(() => Width), Width.Value.ToString(HereAPISession.Culture)); } if (Length != null) { AddAttribute(PropertyHelper.GetDescription(() => Length), Length.Value.ToString(HereAPISession.Culture)); } if (TunnelCategory != null) { AddAttribute(PropertyHelper.GetDescription(() => TunnelCategory), EnumHelper.GetDescription(TunnelCategory)); } if (TruckRestrictionPenalty != null) { AddAttribute(PropertyHelper.GetDescription(() => TruckRestrictionPenalty), EnumHelper.GetDescription(TruckRestrictionPenalty)); } if (ReturnElevation != null) { AddAttribute(PropertyHelper.GetDescription(() => ReturnElevation), ReturnElevation.ToString().ToLower()); } }