Example #1
0
        /// <summary>
        /// Initializes a buffer computation for the given geometry.
        /// </summary>
        /// <param name="g">The geometry to buffer.</param>
        /// <param name="quadrantSegments">
        /// The number of segments used to approximate a quarter circle.
        /// </param>
        public BufferOp(Geometry g, int quadrantSegments)
        {
            m_nQuadrantSegments = quadrantSegments;
            m_enumEndCapStyle   = BufferCapType.Round;

            m_objTargetGeometry = g;
        }
Example #2
0
        /// <summary>
        /// Initializes a buffer computation for the given geometry.
        /// </summary>
        /// <param name="g">The geometry to buffer.</param>
        /// <param name="capStyle">
        /// The end cap style of the generated buffer.
        /// </param>
        public BufferOp(Geometry g, BufferCapType capStyle)
        {
            m_nQuadrantSegments = OffsetCurveBuilder.DefaultQuadrantSegments;
            m_enumEndCapStyle   = capStyle;

            m_objTargetGeometry = g;
        }
Example #3
0
        /// <summary>
        /// Computes the buffer for a geometry for a given buffer distance
        /// and accuracy of approximation.
        /// </summary>
        /// <param name="g">The geometry to buffer.</param>
        /// <param name="distance">The buffer distance.</param>
        /// <param name="quadrantSegments">
        /// The number of segments used to approximate a quarter circle.
        /// </param>
        /// <param name="capStyle">
        /// The end cap style of the generated buffer.
        /// </param>
        /// <returns>
        /// The buffer of the input geometry.
        /// </returns>
        public static Geometry Buffer(Geometry g, double distance,
                                      int quadrantSegments, BufferCapType capStyle)
        {
            BufferOp bufOp   = new BufferOp(g, capStyle, quadrantSegments);
            Geometry geomBuf = bufOp.Buffer(distance);

            return(geomBuf);
        }
Example #4
0
        /// <summary>
        /// Computes the buffer of a geometry for a given buffer distance.
        /// </summary>
        /// <param name="g">The geometry to buffer.</param>
        /// <param name="distance">The buffer distance.</param>
        /// <param name="capStyle">
        /// The end cap style of the generated buffer.
        /// </param>
        /// <returns>The buffer of the input geometry.</returns>
        public static Geometry Buffer(Geometry g, double distance,
                                      BufferCapType capStyle)
        {
            BufferOp gBuf    = new BufferOp(g, capStyle);
            Geometry geomBuf = gBuf.Buffer(distance);

            return(geomBuf);
        }
        public OffsetCurveBuilder(PrecisionModel precisionModel, int quadrantSegments)
        {
            GeometryFactory factory = new GeometryFactory(precisionModel);

            endCapStyle = BufferCapType.Round;
            seg0        = new LineSegment(factory);
            seg1        = new LineSegment(factory);
            offset0     = new LineSegment(factory);
            offset1     = new LineSegment(factory);

            this.precisionModel = precisionModel;
            // compute intersections in full precision, to provide accuracy
            // the points are rounded as they are inserted into the curve line
            li = new RobustLineIntersector();

            int limitedQuadSegs = quadrantSegments < 1?1:quadrantSegments;

            filletAngleQuantum = Math.PI / 2.0 / limitedQuadSegs;
        }
Example #6
0
		/// <summary> Creates a new BufferBuilder</summary>
		public BufferBuilder()
		{
            quadrantSegments = OffsetCurveBuilder.DefaultQuadrantSegments;
            endCapStyle      = BufferCapType.Round;
            edgeList         = new EdgeList();
        }
        protected override void RunCore(Dictionary <string, string> parameters)
        {
            bool parametersValid = parameterNames.All(name => parameters.ContainsKey(name));

            if (parametersValid)
            {
                double        distance     = 0;
                int           smoothness   = 0;
                BufferCapType capType      = BufferCapType.Butt;
                GeographyUnit mapUnit      = GeographyUnit.Unknown;
                DistanceUnit  distanceUnit = DistanceUnit.Feet;

                var featuresToBuffer = GetFeaturesToBuffer(parameters[parameterNames[0]]);
                double.TryParse(parameters[parameterNames[1]], out distance);
                int.TryParse(parameters[parameterNames[2]], out smoothness);
                Enum.TryParse <BufferCapType>(parameters[parameterNames[3]], out capType);
                Enum.TryParse <GeographyUnit>(parameters[parameterNames[4]], out mapUnit);
                Enum.TryParse <DistanceUnit>(parameters[parameterNames[5]], out distanceUnit);

                int bufferdFeaturesCount = 0;
                Collection <Feature> bufferedFeatures = new Collection <Feature>();
                foreach (Feature feature in featuresToBuffer)
                {
                    try
                    {
                        BaseShape         shape           = feature.GetShape();
                        MultipolygonShape bufferedShape   = shape.Buffer(distance, smoothness, capType, mapUnit, distanceUnit);
                        Feature           bufferedFeature = new Feature(bufferedShape.GetWellKnownBinary(), feature.Id, feature.ColumnValues);
                        bufferedFeature.Tag = feature.Tag;
                        bufferedFeatures.Add(bufferedFeature);
                    }
                    catch (Exception ex)
                    {
                        UpdatingProgressLongRunningTaskPluginEventArgs errorEventArgs = new UpdatingProgressLongRunningTaskPluginEventArgs(LongRunningTaskState.Error);
                        errorEventArgs.ExceptionInfo = new LongRunningTaskExceptionInfo(ex.Message, ex.StackTrace);
                        errorEventArgs.Message       = feature.Id;
                        OnUpdatingProgress(errorEventArgs);

                        continue;
                    }

                    Interlocked.Increment(ref bufferdFeaturesCount);
                    OnUpdatingProgress(new UpdatingProgressLongRunningTaskPluginEventArgs(LongRunningTaskState.Updating)
                    {
                        Current = bufferdFeaturesCount * 100 / featuresToBuffer.Count
                    });
                }

                OnUpdatingProgress(new UpdatingProgressLongRunningTaskPluginEventArgs(LongRunningTaskState.Updating)
                {
                    Message = "Creating File"
                });

                string outputPath = parameters[parameterNames[6]];
                string projection = parameters[parameterNames[7]];
                Output(bufferedFeatures, outputPath, projection);

                OnUpdatingProgress(new UpdatingProgressLongRunningTaskPluginEventArgs(LongRunningTaskState.Updating)
                {
                    Message = "Finished"
                });
            }
        }