Exemple #1
0
        private IGeometry ReducePointwise(IGeometry geom)
        {
            GeometryEditor geomEdit;

            if (_changePrecisionModel)
            {
                var newFactory = CreateFactory(geom.Factory, _targetPrecModel);
                geomEdit = new GeometryEditor(newFactory);
            }
            else
            {
                // don't change geometry factory
                geomEdit = new GeometryEditor();
            }

            /**
             * For polygonal geometries, collapses are always removed, in order
             * to produce correct topology
             */
            bool finalRemoveCollapsed = _removeCollapsed;

            if (geom.Dimension >= Dimension.Surface)
            {
                finalRemoveCollapsed = true;
            }

            var reduceGeom = geomEdit.Edit(geom,
                                           new PrecisionReducerCoordinateOperation(_targetPrecModel, finalRemoveCollapsed));

            return(reduceGeom);
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="g"></param>
        /// <returns>
        /// A clone of g based on a CoordinateSequence created by this
        /// GeometryFactory's CoordinateSequenceFactory.
        /// </returns>
        public IGeometry CreateGeometry(IGeometry g)
        {
            // could this be cached to make this more efficient? Or maybe it isn't enough overhead to bother
            GeometryEditor editor = new GeometryEditor(this);

            return(editor.Edit(g, new AnonymousCoordinateOperationImpl()));
        }
Exemple #3
0
        /// <summary>
        /// Creates a deep copy of the input <see cref="IGeometry"/>.
        /// The <see cref="ICoordinateSequenceFactory"/> defined for this factory
        /// is used to copy the <see cref="ICoordinateSequence"/>s
        /// of the input geometry.
        /// <para/>
        /// This is a convenient way to change the <tt>CoordinateSequence</tt>
        /// used to represent a geometry, or to change the
        /// factory used for a geometry.
        /// <para/>
        /// <see cref="IGeometry.Copy()"/> can also be used to make a deep copy,
        /// but it does not allow changing the CoordinateSequence type.
        /// </summary>
        /// <param name="g">The geometry</param>
        /// <returns>A deep copy of the input geometry, using the CoordinateSequence type of this factory</returns>
        /// <seealso cref="IGeometry.Copy"/>
        public IGeometry CreateGeometry(IGeometry g)
        {
            // NOTE: don't move lambda to a separate variable!
            //       make a variable and you've broke WinPhone build.
            var operation = new GeometryEditor.CoordinateSequenceOperation((x, y) => _coordinateSequenceFactory.Create(x));
            var editor    = new GeometryEditor(this);

            return(editor.Edit(g, operation));
        }
        private IGeometry ReplaceLines(IGeometry geom, IList <ISegmentString> segStrings)
        {
            var nodedLinesMap = NodedLinesMap(segStrings);
            var lineReplacer  = new GeometryCoordinateReplacer(nodedLinesMap);
            var geomEditor    = new GeometryEditor();
            var snapped       = geomEditor.Edit(geom, lineReplacer);

            return(snapped);
        }
Exemple #5
0
        /// <summary>
        /// Creates a deep copy of the input <see cref="IGeometry"/>.
        /// The <see cref="ICoordinateSequenceFactory"/> defined for this factory
        /// is used to copy the <see cref="ICoordinateSequence"/>s
        /// of the input geometry.
        /// <para/>
        /// This is a convenient way to change the <tt>CoordinateSequence</tt>
        /// used to represent a geometry, or to change the
        /// factory used for a geometry.
        /// <para/>
        /// <see cref="IGeometry.Clone()"/> can also be used to make a deep copy,
        /// but it does not allow changing the CoordinateSequence type.
        /// </summary>
        /// <param name="g">The geometry</param>
        /// <returns>A deep copy of the input geometry, using the CoordinateSequence type of this factory</returns>
        /// <seealso cref="IGeometry.Clone"/>
        public IGeometry CreateGeometry(IGeometry g)
        {
            var editor = new GeometryEditor(this);

            //        return editor.Edit(g, new GeometryEditor.CoordinateSequenceOperation() {
            //  public CoordinateSequence edit(CoordinateSequence coordSeq, Geometry geometry) {
            //              return coordinateSequenceFactory.create(coordSeq);
            //      }
            //});
            return(editor.Edit(g, new GeometryEditor.CoordinateSequenceOperation(
                                   (x, y) => _coordinateSequenceFactory.Create(x))));
        }
Exemple #6
0
        private static GeometryEditor CreateEditor(IGeometryFactory geomFactory, IPrecisionModel newPrecModel)
        {
            // no need to change if precision model is the same
            if (geomFactory.PrecisionModel == newPrecModel)
            {
                return(new GeometryEditor());
            }

            // otherwise create a geometry editor which changes PrecisionModel
            var newFactory = CreateFactory(geomFactory, newPrecModel);
            var geomEdit   = new GeometryEditor(newFactory);

            return(geomEdit);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="geom"></param>
        /// <returns></returns>
        public IGeometry Reduce(IGeometry geom)
        {
            GeometryEditor geomEdit;

            if (_changePrecisionModel)
            {
                GeometryFactory newFactory = new GeometryFactory(_newPrecisionModel);
                geomEdit = new GeometryEditor(newFactory);
            }
            else
            {
                // don't change point factory
                geomEdit = new GeometryEditor();
            }
            return(geomEdit.Edit(geom, new PrecisionReducerCoordinateOperation(this)));
        }
        public IGeometry Node(IGeometry geom)
        {
            var geomList = new List <IGeometry>();

            geomList.Add(geom);
            var segStrings = ExtractSegmentStrings(geomList);
            //Noder sr = new SimpleSnapRounder(pm);
            var sr = new MCIndexSnapRounder(_pm);

            sr.ComputeNodes(segStrings);


            var nodedPtsMap  = GetNodedPtsMap(segStrings);
            var lineReplacer = new GeometryLineReplacer(nodedPtsMap);
            var geomEditor   = new GeometryEditor();
            var snapped      = geomEditor.Edit(geom, lineReplacer);

            return(snapped);
        }
        public virtual Geometry Reduce(Geometry geom)
        {
            GeometryEditor geomEdit;

            if (changePrecisionModel)
            {
                GeometryFactory factory = geom.Factory;

                GeometryFactory newFactory = new GeometryFactory(
                    newPrecisionModel, factory.CoordinateType,
                    factory.CoordinateDimension, factory.Properties);

                geomEdit = new GeometryEditor(newFactory);
            }
            else             // don't change geometry factory
            {
                geomEdit = new GeometryEditor();
            }

            return(geomEdit.Edit(geom, new PrecisionReducerCoordinateOperation(this)));
        }
Exemple #10
0
        /// <returns>
        /// a clone of g based on a CoordinateCollection created by this
        /// GeometryFactory's ICoordinateSequenceFactory
        /// </returns>
        public virtual Geometry CreateGeometry(Geometry g)
        {
            GeometryEditor editor = new GeometryEditor(this);

            return(editor.Edit(g, new CoordinateOperation()));
        }
Exemple #11
0
 private static void CreateCube()
 {
     GeometryEditor.Create(Shape.Cube, Settings.LastBuiltGeometryPosition ?? Vector3.zero);
 }