当前位置: 首页>>代码示例>>C#>>正文


C# FeatureCollection.Add方法代码示例

本文整理汇总了C#中FeatureCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# FeatureCollection.Add方法的具体用法?C# FeatureCollection.Add怎么用?C# FeatureCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FeatureCollection的用法示例。


在下文中一共展示了FeatureCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SecondCallToAddThrowsException

        public void SecondCallToAddThrowsException()
        {
            var interfaces = new FeatureCollection();
            var thing = new Thing();

            interfaces.Add(typeof(IThing), thing);

            Assert.Throws<ArgumentException>(() => interfaces.Add(typeof(IThing), thing));
        }
开发者ID:mchenx,项目名称:HttpAbstractions,代码行数:9,代码来源:InterfaceDictionaryTests.cs

示例2: AddedInterfaceIsReturned

        public void AddedInterfaceIsReturned()
        {
            var interfaces = new FeatureCollection();
            var thing = new Thing();

            interfaces.Add(typeof(IThing), thing);

            Assert.Equal(interfaces[typeof(IThing)], thing);

            object thing2;
            Assert.True(interfaces.TryGetValue(typeof(IThing), out thing2));
            Assert.Equal(thing2, thing);
        }
开发者ID:mchenx,项目名称:HttpAbstractions,代码行数:13,代码来源:InterfaceDictionaryTests.cs

示例3: SetNullValueRemoves

        public void SetNullValueRemoves()
        {
            var interfaces = new FeatureCollection();
            var thing = new Thing();

            interfaces.Add(typeof(IThing), thing);
            Assert.Equal(interfaces[typeof(IThing)], thing);

            interfaces[typeof(IThing)] = null;

            object thing2;
            Assert.False(interfaces.TryGetValue(typeof(IThing), out thing2));
        }
开发者ID:mchenx,项目名称:HttpAbstractions,代码行数:13,代码来源:InterfaceDictionaryTests.cs

示例4: ClusterFeaturesAsync

        /// <summary>${WP_mapping_Clusterer_method_ClusterFeaturesAsync_D}</summary>
        /// <param name="features">${WP_mapping_Clusterer_method_ClusterFeaturesAsync_param_features}</param>
        /// <param name="resolution">${WP_mapping_Clusterer_method_ClusterFeaturesAsync_param_resolution}</param>
        public override void ClusterFeaturesAsync(IEnumerable<Feature> features, double resolution)
        {
            if (features == null)
            {
                base.OnClusteringCompleted(new FeatureCollection());
            }
            else
            {
                if (this.clusterThread != null)
                {
                    this.clusterThread.RunWorkerCompleted -= new RunWorkerCompletedEventHandler(clusterThread_RunWorkerCompleted);
                    if (this.clusterThread.IsBusy)
                    {
                        this.clusterThread.CancelAsync();
                    }
                    this.clusterThread = null;
                }
                this.clusterThread = new BackgroundWorker() { WorkerSupportsCancellation = true };
                this.clusterThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(clusterThread_RunWorkerCompleted);
                
                featuresClone = new FeatureCollection();
                foreach (Feature item in features)
                {
                    featuresClone.Add(item);
                }

                geosClone = new ObservableCollection<GeoRegion>();
                if (this.RegionCollection != null)
                {
                    foreach (var geo in this.RegionCollection)
                    {
                        geosClone.Add(geo);
                    }
                }

                this.clusterThread.DoWork += (s, e) =>
                {
                    e.Result = ClusterGeoPoints(featuresClone, this.Radius, resolution, this.clusterThread, geosClone);
                };
                this.clusterThread.RunWorkerAsync(new object[] { featuresClone, resolution, geosClone, this.Dispatcher });
            }
        }
开发者ID:SuperMap,项目名称:iClient-for-Win8,代码行数:45,代码来源:FeaturesClusterer.cs

示例5: ActivateFeatureInCollection

        /// <summary>
        /// FeaturedefinitionScope.None is the way to go OOTB features. http://stackoverflow.com/questions/17803291/failing-to-activate-a-feature-using-com-in-sharepoint-2010
        /// Both Site Collection and Web scoped custom features MUST use Scope.Site.
        /// </summary>
        /// <param name="clientContext"></param>
        /// <param name="featureInfo"></param>
        /// <param name="featureCollection"></param>
        /// <param name="scope"></param>
        private static void ActivateFeatureInCollection(ClientContext clientContext, ShFeature featureInfo, FeatureCollection featureCollection, FeatureDefinitionScope scope)
        {
            clientContext.Load(featureCollection);
            clientContext.ExecuteQuery();

            if (!DoesFeatureExistInCollection(featureCollection, featureInfo.FeatureId))
            {
                try
                {
                    Log.Info("Activating feature   " + featureInfo.FeatureName);
                    featureCollection.Add(featureInfo.FeatureId, true, scope);
                    clientContext.ExecuteQuery();
                }
                catch (ServerException)
                {
                    // Out of the box features will bomb using other scopes than FeatureDefinitionScope.None
                    // This is why we first try with the correct scope, then fallback to Scope.None
                    featureCollection.Add(featureInfo.FeatureId, true, FeatureDefinitionScope.None);
                    clientContext.ExecuteQuery();
                }
            }
        }
开发者ID:olemp,项目名称:sherpa,代码行数:30,代码来源:FeatureManager.cs

示例6: ToFeatureCollection

        /// <summary>
        /// Converts this route to a feature collection.
        /// </summary>
        /// <returns></returns>
        public FeatureCollection ToFeatureCollection()
        {
            var featureCollection = new FeatureCollection();
            if(this.Segments == null)
            {
                return featureCollection;
            }
            for (int i = 0; i < this.Segments.Length; i++)
            {
                // create a line string for the current segment.
                if (i > 0)
                { // but only do so when there is a previous point available.
                    var segmentLineString = new LineString(
                        new GeoCoordinate(this.Segments[i - 1].Latitude, this.Segments[i - 1].Longitude),
                        new GeoCoordinate(this.Segments[i].Latitude, this.Segments[i].Longitude));

                    var segmentTags = this.Segments[i].Tags;
                    var attributesTable = new SimpleGeometryAttributeCollection();
                    if (segmentTags != null)
                    { // there are tags.
                        foreach (var tag in segmentTags)
                        {
                            attributesTable.Add(tag.Key, tag.Value);
                        }
                    }
                    attributesTable.Add("time", this.Segments[i].Time);
                    attributesTable.Add("distance", this.Segments[i].Distance);
                    if (this.Segments[i].Vehicle != null)
                    {
                        attributesTable.Add("vehicle", this.Segments[i].Vehicle);
                    }
                    featureCollection.Add(new Feature(segmentLineString, attributesTable));
                }

                // create points.
                if (this.Segments[i].Points != null)
                {
                    foreach (var point in this.Segments[i].Points)
                    {
                        // build attributes.
                        var currentPointTags = point.Tags;
                        var attributesTable = new SimpleGeometryAttributeCollection();
                        if (currentPointTags != null)
                        { // there are tags.
                            foreach (var tag in currentPointTags)
                            {
                                attributesTable.Add(tag.Key, tag.Value);
                            }
                        }

                        // build feature.
                        var pointGeometry = new Point(new GeoCoordinate(point.Latitude, point.Longitude));
                        featureCollection.Add(new Feature(pointGeometry, attributesTable));
                    }
                }
            }
            return featureCollection;
        }
开发者ID:cmberryau,项目名称:routing,代码行数:62,代码来源:Route.cs

示例7: GetFeatures

        private async Task<FeatureCollection> GetFeatures(XElement ele, string spatialPropName)
        {
            Dictionary<string, string> attributes = new Dictionary<string, string>();
            FeatureCollection fs = new FeatureCollection();
            if (ele != null)
            {
                //加属性
                foreach (KeyValuePair<string, string> itemPair in (from subItem in ele.Elements()
                                                                   where (subItem.Name.LocalName != spatialPropName)
                                                                   select new KeyValuePair<string, string>(subItem.Name.LocalName, subItem.Value)
                 ))
                {
                    attributes.Add(itemPair.Key, itemPair.Value);
                }

                XElement geoElement = string.IsNullOrEmpty(spatialPropName) ? null : ele.Element(XName.Get(spatialPropName, this.FeatureNS));

                if (geoElement != null)
                {

                    XElement firstNode = geoElement.FirstNode as XElement;
                    string geometryTypeName = firstNode != null ? firstNode.Name.LocalName : string.Empty;
                    GeometryType type;

                    #region 这段代码主要用来处理混淆问题。如果删除这段代码,SampleCode的相应案例无法正常运行。
                    try
                    {
                        Enum.Parse(typeof(GeometryType), geometryTypeName, true);
                    }
                    catch (Exception e)
                    {
                        throw new OverflowException("转化出错了", e);
                    }
                    #endregion

                    await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        if (Enum.TryParse<GeometryType>(geometryTypeName, true, out type))
                        {
                            if (type == GeometryType.Point)
                            {
                                GeoPoint point = this.ParsePointCoordinates((geoElement.FirstNode as XElement).Value);
                                Feature col = new Feature();
                                foreach (var v in attributes)
                                {
                                    col.Attributes.Add(v.Key, v.Value);
                                }
                                col.Geometry = point;
                                fs.Add(col);
                            }
                            else if (type == GeometryType.LineString)
                            {
                                XElement lineStrEle = geoElement.Element(XName.Get("LineString", nameSpacePair["gml"]));
                                GeoLine line = ParseLineCoordinates(lineStrEle);
                                Feature col = new Feature();
                                foreach (var v in attributes)
                                {
                                    col.Attributes.Add(v.Key, v.Value);
                                }
                                col.Geometry = line;
                                fs.Add(col);
                            }
                            else if (type == GeometryType.Polygon)
                            {
                                XElement polygonEle = geoElement.Element(XName.Get("Polygon", nameSpacePair["gml"]));
                                GeoRegion region = ParseRegionCoordinates(polygonEle);
                                Feature col = new Feature();
                                foreach (var v in attributes)
                                {
                                    col.Attributes.Add(v.Key, v.Value);
                                }
                                col.Geometry = region;
                                fs.Add(col);
                            }
                            else if (type == GeometryType.MultiPoint)
                            {
                                //TODO:处理多点。
                                //暂时不做处理。
                            }
                            else if (type == GeometryType.MultiLineString)
                            {
                                IEnumerable<XElement> lineStringMemberEle = geoElement.Descendants(XName.Get("lineStringMember", nameSpacePair["gml"]));
                                foreach (XElement els in lineStringMemberEle)
                                {
                                    GeoLine line = ParseMultiLineCoordinates(els);
                                    Feature col = new Feature();
                                    foreach (var v in attributes)
                                    {
                                        col.Attributes.Add(v.Key, v.Value);
                                    }
                                    col.Geometry = line;
                                    fs.Add(col);
                                }

                            }
                            else if (type == GeometryType.MultiPolygon)
                            {
                                IEnumerable<XElement> polygonMemberEle = geoElement.Descendants(XName.Get("polygonMember", nameSpacePair["gml"]));

                                foreach (XElement els in polygonMemberEle)
//.........这里部分代码省略.........
开发者ID:SuperMap,项目名称:iClient-for-Win8,代码行数:101,代码来源:GetWFSFeature.cs

示例8: ProcessFeatureInternal

        /// <summary>
        /// Activates or deactivates a site collection or web scoped feature
        /// </summary>
        /// <param name="features">Feature Collection which contains the feature</param>
        /// <param name="featureID">ID of the feature to activate/deactivate</param>
        /// <param name="activate">True to activate, false to deactivate the feature</param>
        /// <param name="scope">Scope of the feature definition</param>
        /// <param name="pollingIntervalSeconds">The time in seconds between polls for "IsActive"</param>
        private static void ProcessFeatureInternal(FeatureCollection features, Guid featureID, bool activate, FeatureDefinitionScope scope, int pollingIntervalSeconds = 30)
        {
            if (activate)
            {
                // Feature enabling can take a long time, especially in case of the publishing feature...so let's make it more reliable
                bool cancel = false;
                features.Add(featureID, true, scope);

                if (pollingIntervalSeconds < 5)
                {
                    pollingIntervalSeconds = 5;
                }

                // Kick off a thread that checks for the feature activation to be complete
                Task.Run(() =>
                {
                    while (!cancel)
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(pollingIntervalSeconds));

                        if (!cancel)
                        {
                            cancel = IsFeatureActiveInternal(features, featureID);
                            Log.Info(Constants.LOGGING_SOURCE, CoreResources.FeatureExtensions_ProcessFeatureInternal_FeatureActivationState, cancel, featureID);
                        }
                    }
                });

                // Kick off a thread that enables the feature
                Task.Run(() =>
                {
                    try
                    {
                        features.Context.ExecuteQueryRetry();
                        Log.Info(Constants.LOGGING_SOURCE, CoreResources.FeatureExtensions_ProcessFeatureInternal_FeatureActive, featureID);
                    }
                    catch(Exception ex)
                    {
                        Log.Info(Constants.LOGGING_SOURCE, CoreResources.FeatureExtensions_ProcessFeatureInternal_FeatureException, ex.ToString());
                    }
                    finally
                    {
                        cancel = true;
                    }
                }).Wait();
            }
            else
            {
                try
                {
                    features.Remove(featureID, false);
                    features.Context.ExecuteQueryRetry();
                }
                catch (Exception ex)
                {
                    Log.Error(Constants.LOGGING_SOURCE, CoreResources.FeatureExtensions_FeatureActivationProblem, featureID, ex.Message);
                }
            }
        }
开发者ID:stijnbrouwers,项目名称:PnP-Sites-Core,代码行数:67,代码来源:FeatureExtensions.cs

示例9: MultimodalModule

        /// <summary>
        /// Creates the multi modal nancy module.
        /// </summary>
        public MultimodalModule()
        {
            JsonSettings.MaxJsonLength = Int32.MaxValue;

            Get["{instance}/multimodal"] = _ =>
            {
                this.EnableCors();

                // get request id.
                ulong requestId = MultimodalModule.GetRequestId();

                // get instance and check if active.
                string instance = _.instance;
                if (!ApiBootstrapper.IsActive(instance))
                { // oeps, instance not active!
                    return Negotiate.WithStatusCode(HttpStatusCode.NotFound);
                }

                // check transit support.
                if (!ApiBootstrapper.Get(instance).TransitSupport)
                { // not found, this is not active!
                    return Negotiate.WithStatusCode(HttpStatusCode.NotFound);
                }

                var startTicks = DateTime.Now.Ticks;
                OsmSharp.Logging.Log.TraceEvent(string.Format("MultimodalModal.{0}", instance), OsmSharp.Logging.TraceEventType.Information,
                    string.Format("Multimodal request #{1} from {0}.", this.Request.UserHostAddress, requestId));
                try
                {
                    // bind the query if any.
                    var query = this.Bind<RoutingQuery>();

                    // parse location.
                    if (string.IsNullOrWhiteSpace(query.loc))
                    { // no loc parameters.
                        return Negotiate.WithStatusCode(HttpStatusCode.NotAcceptable).WithModel("loc parameter not found or request invalid.");
                    }
                    var locs = query.loc.Split(',');
                    if (locs.Length < 2)
                    { // less than two loc parameters.
                        return Negotiate.WithStatusCode(HttpStatusCode.NotAcceptable).WithModel("only one loc parameter found or request invalid.");
                    }
                    var coordinates = new GeoCoordinate[locs.Length / 2];
                    for (int idx = 0; idx < coordinates.Length; idx++)
                    {
                        double lat, lon;
                        if (double.TryParse(locs[idx * 2], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out lat) &&
                            double.TryParse(locs[idx * 2 + 1], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out lon))
                        { // parsing was successful.
                            coordinates[idx] = new GeoCoordinate(lat, lon);
                        }
                        else
                        { // invalid formatting.
                            return Negotiate.WithStatusCode(HttpStatusCode.NotAcceptable).WithModel("location coordinates are invalid.");
                        }
                    }

                    // get vehicle.
                    string vehicleName = "car"; // assume car is the default.
                    if (!string.IsNullOrWhiteSpace(query.vehicle))
                    { // a vehicle was defined.
                        vehicleName = query.vehicle;
                    }
                    var vehicles = new List<Vehicle>();
                    var vehicleNames = vehicleName.Split('|');
                    for (int idx = 0; idx < vehicleNames.Length; idx++)
                    {
                        var vehicle = Vehicle.GetByUniqueName(vehicleNames[idx]);
                        if (vehicle == null)
                        { // vehicle not found or not registered.
                            return Negotiate.WithStatusCode(HttpStatusCode.NotAcceptable).WithModel(string.Format("vehicle with name '{0}' not found.", vehicleName));
                        }
                        vehicles.Add(vehicle);
                    }

                    // get operators.
                    HashSet<string> operators = null;
                    if (query.operators != null)
                    { // a vehicle was defined.
                        operators = new HashSet<string>();
                        var operatorNames = query.operators.Split('|');
                        for (int idx = 0; idx < operatorNames.Length; idx++)
                        {
                            operators.Add(operatorNames[idx]);
                        }
                    }

                    bool instructions = false;
                    if (!string.IsNullOrWhiteSpace(query.instructions))
                    { // there is an instruction flag.
                        instructions = query.instructions == "true";
                    }

                    bool complete = false;
                    if (!string.IsNullOrWhiteSpace(query.complete))
                    { // there is a complete flag.
                        complete = query.complete == "true";
//.........这里部分代码省略.........
开发者ID:nagyistoce,项目名称:OsmSharp-routing-api,代码行数:101,代码来源:MultimodalModule.cs

示例10: ToFeatureSet

        /// <summary>${iServer2_Query_Recordset_method_toFeatureSet_D}</summary>
        public FeatureCollection ToFeatureSet()
        {
            FeatureCollection featureSet = new FeatureCollection();
            if (this.Records == null)
            {
                return featureSet;
            }
            foreach (Record record in this.Records)
            {
                Feature feature = new Feature();

                ServerGeometry shape = record.Shape;
                if (shape != null)
                {
                    switch (shape.Feature)
                    {
                        case ServerFeatureType.Unknown:
                            break;
                        case ServerFeatureType.Point:
                            feature.Geometry = shape.ToGeoPoint();
                            break;
                        case ServerFeatureType.Line:
                            feature.Geometry = shape.ToGeoLine();
                            break;
                        case ServerFeatureType.Polygon:
                            feature.Geometry = shape.ToGeoRegion();
                            break;
                        case ServerFeatureType.Text:
                            break;
                        case ServerFeatureType.LineM:
                            break;
                        default:
                            feature.Geometry = null;
                            break;
                    }
                }
                //List<string> values = record.FieldValues;
                //List<string> key = this.ReturnFields; //没有用Caption

                if (record.FieldValues != null)
                {
                    for (int i = 0; i < this.ReturnFields.Count; i++)
                    {
                        feature.Attributes.Add(this.ReturnFields[i], record.FieldValues[i]);
                    }
                }
                featureSet.Add(feature);
            }
            return featureSet;
        }
开发者ID:SuperMap,项目名称:iClient-for-Silverlight,代码行数:51,代码来源:RecordSet.cs

示例11: SafelyActivateWebFeature

        private static Feature SafelyActivateWebFeature(ClientRuntimeContext context, FeatureCollection features,
            FeatureDefinition featureModel, Microsoft.SharePoint.Client.FeatureDefinitionScope scope)
        {
            var result = features.Add(featureModel.Id, featureModel.ForceActivate, scope);

            try
            {
                context.ExecuteQueryWithTrace();
            }
            catch (Exception e)
            {
                // sandbox site/web features?
                // they need to ne activated with SPFeatureDefinitionScope.Site scope
                if ((featureModel.Scope == FeatureDefinitionScope.Site || featureModel.Scope == FeatureDefinitionScope.Web)
                    && e.Message.ToUpper().Contains(featureModel.Id.ToString("D").ToUpper()))
                {
                    result = features.Add(featureModel.Id, featureModel.ForceActivate, Microsoft.SharePoint.Client.FeatureDefinitionScope.Site);
                    context.ExecuteQueryWithTrace();
                }
                else
                {
                    throw e;
                }
            }

            return result;
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:27,代码来源:FeatureModelHandler.cs

示例12: GetFeatures

        /// <summary>
        /// Gets a feature collection representing the given route based on the given aggregation type.
        /// </summary>
        /// <param name="route"></param>
        /// <param name="aggregationType"></param>
        /// <returns></returns>
        public override FeatureCollection GetFeatures(Route route, RouteAggregationType aggregationType)
        {
            if (route == null) { throw new ArgumentNullException("route"); }
            if (aggregationType == RouteAggregationType.All)
            {  // one LineString.
                var featureCollection = new FeatureCollection();
                var coordinates = route.GetPoints();
                if (coordinates.Count > 1)
                {
                    var lineString = new LineString(coordinates.ToArray());

                    var attributes = new SimpleGeometryAttributeCollection();
                    attributes.Add("osmsharp:total_time", route.TotalTime.ToInvariantString());
                    attributes.Add("osmsharp:total_distance", route.TotalDistance.ToInvariantString());

                    var feature = new Feature(lineString, attributes);

                    featureCollection.Add(feature);
                }
                return featureCollection;
            }
            else if(aggregationType == RouteAggregationType.Modal)
            { // modal.
                // aggregate.
                var aggregator = new ModalAggregator(new OsmRoutingInterpreter());
                var microPlanner = new ModalMicroPlanner(new ModalLanguageGenerator(), new OsmRoutingInterpreter());
                var aggregated = aggregator.Aggregate(route);
                var instructions = InstructionGenerator.Generate(microPlanner, route, aggregated);

                return this.GetFeatures(route, instructions);
            }
            else // modal and instructions.
            { // instructions.
                var instructions = this.GetInstructions(route);

                return this.GetFeatures(route, instructions);
            }
        }
开发者ID:nagyistoce,项目名称:OsmSharp-routing-api,代码行数:44,代码来源:MultimodalApi.cs

示例13: ProcessFeatureInternal

        /// <summary>
        /// Activates or deactivates a site collection or web scoped feature
        /// </summary>
        /// <param name="features">Feature Collection which contains the feature</param>
        /// <param name="featureID">ID of the feature to activate/deactivate</param>
        /// <param name="activate">True to activate, false to deactivate the feature</param>
        /// <param name="scope">Scope of the feature definition</param>
        /// <param name="pollingIntervalSeconds">The time in seconds between polls for "IsActive"</param>
        private static void ProcessFeatureInternal(FeatureCollection features, Guid featureID, bool activate, FeatureDefinitionScope scope, int pollingIntervalSeconds = 30)
        {
            if (activate)
            {
                // Feature enabling can take a long time, especially in case of the publishing feature...so let's make it more reliable
                features.Add(featureID, true, scope);

                if (pollingIntervalSeconds < 5)
                {
                    pollingIntervalSeconds = 5;
                }

                try
                {
                    string clientTag = $"{PnPCoreUtilities.PnPCoreVersionTag}:ProcessFeatureInternal";
                    if (clientTag.Length > 32)
                    {
                        clientTag = clientTag.Substring(0, 32);
                    }
                    features.Context.ClientTag = clientTag;
                    // Don't update this to ExecuteQueryRetry
                    features.Context.ExecuteQuery();
                    Log.Info(Constants.LOGGING_SOURCE, CoreResources.FeatureExtensions_ProcessFeatureInternal_FeatureActive, featureID);
                }
                catch (Exception ex)
                {
                    Log.Info(Constants.LOGGING_SOURCE, CoreResources.FeatureExtensions_ProcessFeatureInternal_FeatureException, ex.ToString());

                    // Don't wait for a "feature not found" exception, which is the typical exception we'll see
                    if (ex.HResult != -2146233088)
                    {
                        int retryAttempts = 10;
                        int retryCount = 0;

                        // wait and keep checking if the feature is active
                        while (retryAttempts > retryCount)
                        {
                            Thread.Sleep(TimeSpan.FromSeconds(pollingIntervalSeconds));
                            if (IsFeatureActiveInternal(features, featureID, true))
                            {
                                retryCount = retryAttempts;
                                Log.Info(Constants.LOGGING_SOURCE, CoreResources.FeatureExtensions_ProcessFeatureInternal_FeatureActivationState, true, featureID);
                            }
                            else
                            {
                                retryCount++;
                                Log.Info(Constants.LOGGING_SOURCE, CoreResources.FeatureExtensions_ProcessFeatureInternal_FeatureActivationState, false, featureID);
                            }
                        }
                    }
                }
            }
            else
            {
                try
                {
                    features.Remove(featureID, false);
                    features.Context.ExecuteQueryRetry();
                }
                catch (Exception ex)
                {
                    Log.Error(Constants.LOGGING_SOURCE, CoreResources.FeatureExtensions_FeatureActivationProblem, featureID, ex.Message);
                }
            }
        }
开发者ID:OfficeDev,项目名称:PnP-Sites-Core,代码行数:73,代码来源:FeatureExtensions.cs

示例14: clusterThread_RunWorkerCompleted

 private void clusterThread_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if ((!e.Cancelled) && (e.Result != null))
     {
         Dictionary<int, Cluster> result = e.Result as Dictionary<int, Cluster>;
         if (result != null)
         {
             FeatureCollection clusters = new FeatureCollection();
             int num = 0;
             foreach (int num2 in result.Keys)
             {
                 if (result.ContainsKey(num2))
                     num = Math.Max(result[num2].Count, num);
             }
             foreach (int num3 in result.Keys)
             {
                 if (result.ContainsKey(num3) && result[num3].Features.Count == 1)
                 {
                     clusters.Add(result[num3].Features[0]);
                 }
                 else if (result.ContainsKey(num3))
                 {
                     Feature item = this.OnCreateFeature(result[num3].Features, new GeoPoint(result[num3].X, result[num3].Y), num);
                     item.DisableToolTip = true;
                     item.SetValue(Clusterer.ClusterProperty, result[num3].Features);
                     clusters.Add(item);
                 }
             }
             base.OnClusteringCompleted(clusters);
         }
     }
 }
开发者ID:SuperMap,项目名称:iClient-for-Win8,代码行数:32,代码来源:FeaturesClusterer.cs

示例15: Interpret

        /// <summary>
        /// Interprets an OSM-object and returns the corresponding geometry.
        /// </summary>
        /// <param name="osmObject"></param>
        /// <returns></returns>
        public override FeatureCollection Interpret(ICompleteOsmGeo osmObject)
        {
            // DISCLAIMER: this is a very very very simple geometry interpreter and
            // contains hardcoded all relevant tags.

            var collection = new FeatureCollection();
            TagsCollectionBase tags;
            if (osmObject != null)
            {
                switch (osmObject.Type)
                {
                    case CompleteOsmType.Node:
                        var newCollection = new TagsCollection(
                            osmObject.Tags);
                        newCollection.RemoveKey("FIXME");
                        newCollection.RemoveKey("node");
                        newCollection.RemoveKey("source");

                        if (newCollection.Count > 0)
                        { // there is still some relevant information left.
                            collection.Add(new Feature(new Point((osmObject as Node).Coordinate),
                                new SimpleGeometryAttributeCollection(osmObject.Tags)));
                        }
                        break;
                    case CompleteOsmType.Way:
                        tags = osmObject.Tags;

                        bool isArea = false;
                        if ((tags.ContainsKey("building") && !tags.IsFalse("building")) ||
                            (tags.ContainsKey("landuse") && !tags.IsFalse("landuse")) ||
                            (tags.ContainsKey("amenity") && !tags.IsFalse("amenity")) ||
                            (tags.ContainsKey("harbour") && !tags.IsFalse("harbour")) ||
                            (tags.ContainsKey("historic") && !tags.IsFalse("historic")) ||
                            (tags.ContainsKey("leisure") && !tags.IsFalse("leisure")) ||
                            (tags.ContainsKey("man_made") && !tags.IsFalse("man_made")) ||
                            (tags.ContainsKey("military") && !tags.IsFalse("military")) ||
                            (tags.ContainsKey("natural") && !tags.IsFalse("natural")) ||
                            (tags.ContainsKey("office") && !tags.IsFalse("office")) ||
                            (tags.ContainsKey("place") && !tags.IsFalse("place")) ||
                            (tags.ContainsKey("power") && !tags.IsFalse("power")) ||
                            (tags.ContainsKey("public_transport") && !tags.IsFalse("public_transport")) ||
                            (tags.ContainsKey("shop") && !tags.IsFalse("shop")) ||
                            (tags.ContainsKey("sport") && !tags.IsFalse("sport")) ||
                            (tags.ContainsKey("tourism") && !tags.IsFalse("tourism")) ||
                            (tags.ContainsKey("waterway") && !tags.IsFalse("waterway")) ||
                            (tags.ContainsKey("wetland") && !tags.IsFalse("wetland")) ||
                            (tags.ContainsKey("water") && !tags.IsFalse("water")) ||
                            (tags.ContainsKey("aeroway") && !tags.IsFalse("aeroway")))
                        { // these tags usually indicate an area.
                            isArea = true;
                        }

                        if (tags.IsTrue("area"))
                        { // explicitly indicated that this is an area.
                            isArea = true;
                        }
                        else if (tags.IsFalse("area"))
                        { // explicitly indicated that this is not an area.
                            isArea = false;
                        }

                        if (isArea)
                        { // area tags leads to simple polygon
                            var lineairRing = new Feature(new LineairRing((osmObject as CompleteWay).GetCoordinates().ToArray<GeoCoordinate>()),
                                new SimpleGeometryAttributeCollection(tags));
                            collection.Add(lineairRing);
                        }
                        else
                        { // no area tag leads to just a line.
                            var lineString = new Feature(new LineString((osmObject as CompleteWay).GetCoordinates().ToArray<GeoCoordinate>()),
                                new SimpleGeometryAttributeCollection(tags));
                            collection.Add(lineString);
                        }
                        break;
                    case CompleteOsmType.Relation:
                        var relation = (osmObject as CompleteRelation);
                        tags = relation.Tags;

                        string typeValue;
                        if (tags.TryGetValue("type", out typeValue))
                        { // there is a type in this relation.
                            if (typeValue == "multipolygon")
                            { // this relation is a multipolygon.
                                var feature = this.InterpretMultipolygonRelation(relation);
                                if (feature != null)
                                { // add the geometry.
                                    collection.Add(feature);
                                }
                            }
                            else if (typeValue == "boundary")
                            { // this relation is a boundary.

                            }
                        }
                        break;
//.........这里部分代码省略.........
开发者ID:UnifyKit,项目名称:OsmSharp,代码行数:101,代码来源:SimpleFeatureInterpreter.cs


注:本文中的FeatureCollection.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。