Ejemplo n.º 1
0
        /// <summary>
        /// This method will return an ArrayList of <see cref="ITimeSpaceAdaptedOutput"/> that the ElementMapper
        /// provides when mapping from the ElementType specified in the method argument.
        /// </summary>
        /// <remarks>
        ///  Each <see cref="ITimeSpaceAdaptedOutput"/> object will contain:
        ///  <p> [Key]              [Value]                      [ReadOnly]    [Description]----------------- </p>
        ///  <p> ["Type"]           ["SpatialMapping"]           [true]        ["Using the ElementMapper"] </p>
        ///  <p> ["Caption"]        [The Operation Caption]      [true]        ["Internal ElementMapper adaptedOutput Caption"] </p>
        ///  <p> ["Description"]    [The Operation Description]  [true]        ["Using the ElementMapper"] </p>
        ///  <p> ["ToElementType"]  [ElementType]                [true]        ["Valid To-Element Types"]  </p>
        /// </remarks>
        /// <returns>
        ///  ArrayList which contains the available <see cref="ITimeSpaceAdaptedOutput"/>.
        /// </returns>
        public static List <IArgument> GetAdaptedOutputArguments(IIdentifiable methodIdentifier)
        {
            if (!(methodIdentifier.Id.StartsWith(_ElementMapperPrefix) || methodIdentifier.Id.StartsWith(_ElementOperationPrefix)))
            {
                throw new Exception("Unknown method identifier: " + methodIdentifier);
            }

            for (int i = 0; i < _AvailableMethods.Count; i++)
            {
                SpatialMethod method = _AvailableMethods[i];
                if (String.Compare(method.Id, methodIdentifier.Id) == 0)
                {
                    if (method.ElementMapperMethod == ElementMapperMethod.None)
                    {
                        var arguments = new List <IArgument>();
                        arguments.Add(new ArgumentString("Caption", method.Id,
                                                         "Internal ElementOperation AdaptedOutput Caption"));
                        arguments.Add(new ArgumentString("Description", method.Description,
                                                         "Operation description"));
                        arguments.Add(new ArgumentString("Type", "SpatialOperation", "Using an Element Operator"));
                        arguments.Add(new ArgumentString("FromElementType",
                                                         method.FromElementsShapeType.ToString(),
                                                         "Valid From-Element Types"));
                        return(arguments);
                    }
                    else
                    {
                        var arguments = new List <IArgument>();
                        arguments.Add(new ArgumentString("Caption", method.Id,
                                                         "Internal ElementMapper AdaptedOutput Caption"));
                        arguments.Add(new ArgumentString("Description", method.Description,
                                                         "Mapping description"));
                        arguments.Add(new ArgumentString("Type", "SpatialMapping", "Using the ElementMapper"));
                        arguments.Add(new ArgumentString("FromElementType",
                                                         method.FromElementsShapeType.ToString(),
                                                         "Valid From-Element Types"));
                        arguments.Add(new ArgumentString("ToElementType",
                                                         method.ToElementsShapeType.ToString(),
                                                         "Valid To-Element Types"));
                        return(arguments);
                    }
                }
            }
            throw new Exception("Unknown methodID: " + methodIdentifier.Id);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gives a list of descriptions (strings) for available operation methods
        /// given the source ElementType
        /// </summary>
        /// <param name="sourceElementType">Element type of the elements in the source Elementset</param>
        /// <returns>
        public static void GetAvailableOperationMethods(ref IList <IIdentifiable> methods, ElementType sourceElementType)
        {
            for (int i = 0; i < _AvailableMethods.Count; i++)
            {
                SpatialMethod availableMethod = _AvailableMethods[i];

                // Check if operation or mapping, only add operations here
                if (availableMethod.ElementMapperMethod == ElementMapperMethod.None)
                {
                    // In case of an operation, the target is not important
                    if (sourceElementType == _AvailableMethods[i].FromElementsShapeType)
                    {
                        methods.Add(new Identifier(_AvailableMethods[i].Id)
                        {
                            Description = _AvailableMethods[i].Description
                        });
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static ITimeSpaceAdaptedOutput CreateAdaptedOutputMethod(IIdentifiable adaptedOutputId, IBaseOutput adaptee, IElementSet targetElmtSet)
        {
            SpatialMethod method = FindSMethod(adaptedOutputId);

            ITimeSpaceAdaptedOutput adaptedOutput = null;

            if (method.ElementMapperMethod != ElementMapperMethod.None)
            {
                if (targetElmtSet == null)
                {
                    throw new ArgumentException("Target not defined or spatial definition is not an element set. Can not create adaptor");
                }
                adaptedOutput = new ElementMapperAdaptedOutput(adaptedOutputId, (ITimeSpaceOutput)adaptee, targetElmtSet);
            }
            else
            {
                if (string.Equals(_ElementOperationPrefix + "200", adaptedOutputId.Id, StringComparison.OrdinalIgnoreCase))
                {
                    adaptedOutput = new ElementLineLengthOperationAdaptor(adaptedOutputId.Id, (ITimeSpaceOutput)adaptee);
                }
                else if (string.Equals(_ElementOperationPrefix + "300", adaptedOutputId.Id, StringComparison.OrdinalIgnoreCase))
                {
                    adaptedOutput = new ElementAreaOperationAdaptor(adaptedOutputId.Id, (ITimeSpaceOutput)adaptee);
                }
            }

            if (adaptedOutput == null)
            {
                throw new ArgumentException("Adapted output id could not be found", "adaptedOutputId");
            }

            // Connect adaptor and adaptee
            if (!adaptee.AdaptedOutputs.Contains(adaptedOutput))
            {
                adaptee.AddAdaptedOutput(adaptedOutput);
            }

            return(adaptedOutput);
        }
        private void cboSelectionmethod_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.cboSelectionmethod.SelectedIndex == -1)
            {
                return;
            }
            hasQueried = false;
            switch (this.cboSelectionmethod.SelectedIndex)
            {
            case 0:
                m_SpatialMethod = SpatialMethod.Intersect;
                break;

            case 1:
                m_SpatialMethod = SpatialMethod.Contains;
                break;

            case 2:
                m_SpatialMethod = SpatialMethod.Within;
                break;
            }
        }
Ejemplo n.º 5
0
        public static IDescribable GetAdaptedOutputDescription(IIdentifiable identifiable)
        {
            SpatialMethod spatialMethod = FindSMethod(identifiable);

            return(new Describable(spatialMethod.Id, spatialMethod.Description));
        }
Ejemplo n.º 6
0
        static SpatialAdaptedOutputFactory()
        {
            SpatialMethod method;

            _AvailableMethods = new List <SpatialMethod>();

            // Operation values:
            // Id        :   0- 99
            // Point     : 100-199
            // Polyline  : 200-299
            // Polygon   : 100-199
            // Polyhedron: 100-199
            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.PolyLine,
                ToElementsShapeType   = ElementType.PolyLine,
                ElementMapperMethod   = ElementMapperMethod.None,
                Description           = "Polyline operation, multiply by line length",
                Id = _ElementOperationPrefix + "200",
            };
            _AvailableMethods.Add(method);

            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.Polygon,
                ToElementsShapeType   = ElementType.Polygon,
                ElementMapperMethod   = ElementMapperMethod.None,
                Description           = "Polygon operation, multiply by area",
                Id = _ElementOperationPrefix + "300",
            };
            _AvailableMethods.Add(method);

            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.Point,
                ToElementsShapeType   = ElementType.Point,
                ElementMapperMethod   = ElementMapperMethod.Nearest,
                Description           = "Point-to-point Nearest",
                Id = _ElementMapperPrefix + "100",
            };
            _AvailableMethods.Add(method);


            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.Point,
                ToElementsShapeType   = ElementType.Point,
                ElementMapperMethod   = ElementMapperMethod.Inverse,
                Description           = "Point-to-point Inverse",
                Id = _ElementMapperPrefix + "101",
            };
            _AvailableMethods.Add(method);


            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.Point,
                ToElementsShapeType   = ElementType.PolyLine,
                ElementMapperMethod   = ElementMapperMethod.Nearest,
                Description           = "Point-to-polyline Nearest",
                Id = _ElementMapperPrefix + "200",
            };
            _AvailableMethods.Add(method);


            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.Point,
                ToElementsShapeType   = ElementType.PolyLine,
                ElementMapperMethod   = ElementMapperMethod.Inverse,
                Description           = "Point-to-polyline Inverse",
                Id = _ElementMapperPrefix + "201",
            };
            _AvailableMethods.Add(method);


            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.Point,
                ToElementsShapeType   = ElementType.Polygon,
                ElementMapperMethod   = ElementMapperMethod.Mean,
                Description           = "Point-to-polygon Mean",
                Id = _ElementMapperPrefix + "300",
            };
            _AvailableMethods.Add(method);


            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.Point,
                ToElementsShapeType   = ElementType.Polygon,
                ElementMapperMethod   = ElementMapperMethod.Sum,
                Description           = "Point-to-polygon Sum",
                Id = _ElementMapperPrefix + "301",
            };
            _AvailableMethods.Add(method);


            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.PolyLine,
                ToElementsShapeType   = ElementType.Point,
                ElementMapperMethod   = ElementMapperMethod.Nearest,
                Description           = "Polyline-to-point Nearest",
                Id = _ElementMapperPrefix + "400",
            };
            _AvailableMethods.Add(method);


            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.PolyLine,
                ToElementsShapeType   = ElementType.Point,
                ElementMapperMethod   = ElementMapperMethod.Inverse,
                Description           = "Polyline-to-point Inverse",
                Id = _ElementMapperPrefix + "401",
            };
            _AvailableMethods.Add(method);


            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.PolyLine,
                ToElementsShapeType   = ElementType.Polygon,
                ElementMapperMethod   = ElementMapperMethod.WeightedMean,
                Description           = "Polyline-to-polygon Weighted Mean",
                Id = _ElementMapperPrefix + "500",
            };
            _AvailableMethods.Add(method);


            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.PolyLine,
                ToElementsShapeType   = ElementType.Polygon,
                ElementMapperMethod   = ElementMapperMethod.WeightedSum,
                Description           = "Polyline-to-polygon Weighted Sum",
                Id = _ElementMapperPrefix + "501",
            };
            _AvailableMethods.Add(method);


            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.Polygon,
                ToElementsShapeType   = ElementType.Point,
                ElementMapperMethod   = ElementMapperMethod.Value,
                Description           = "Polygon-to-point Value",
                Id = _ElementMapperPrefix + "600",
            };
            _AvailableMethods.Add(method);


            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.Polygon,
                ToElementsShapeType   = ElementType.PolyLine,
                ElementMapperMethod   = ElementMapperMethod.WeightedMean,
                Description           = "Polygon-to-polyline Weighted Mean",
                Id = _ElementMapperPrefix + "700",
            };
            _AvailableMethods.Add(method);


            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.Polygon,
                ToElementsShapeType   = ElementType.PolyLine,
                ElementMapperMethod   = ElementMapperMethod.WeightedSum,
                Description           = "Polygon-to-polyline Weighted Sum",
                Id = _ElementMapperPrefix + "701",
            };
            _AvailableMethods.Add(method);


            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.Polygon,
                ToElementsShapeType   = ElementType.Polygon,
                ElementMapperMethod   = ElementMapperMethod.WeightedMean,
                Description           = "Polygon-to-polygon Weighted Mean",
                Id = _ElementMapperPrefix + "800",
            };
            _AvailableMethods.Add(method);


            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.Polygon,
                ToElementsShapeType   = ElementType.Polygon,
                ElementMapperMethod   = ElementMapperMethod.WeightedSum,
                Description           = "Polygon-to-polygon Weighted Sum",
                Id = _ElementMapperPrefix + "801",
            };
            _AvailableMethods.Add(method);


            method = new SpatialMethod()
            {
                FromElementsShapeType = ElementType.Polygon,
                ToElementsShapeType   = ElementType.Polygon,
                ElementMapperMethod   = ElementMapperMethod.Distribute,
                Description           = "Polygon-to-polygon Distribute",
                Id = _ElementMapperPrefix + "802",
            };
            _AvailableMethods.Add(method);
        }