/// <summary>
 /// Densifies a coordinate sequence.
 /// </summary>
 /// <param name="pts">The coordinate sequence to densify</param>
 /// <param name="distanceTolerance">The distance tolerance (<see cref="DistanceTolerance"/>)</param>
 /// <param name="precModel">The precision model to apply on the new coordinates</param>
 /// <returns>The densified coordinate sequence</returns>
 private static Coordinate[] DensifyPoints(Coordinate[] pts,
                                            double distanceTolerance, IPrecisionModel precModel)
 {
     var seg = new LineSegment();
     var coordList = new CoordinateList();
     for (int i = 0; i < pts.Length - 1; i++)
     {
         seg.P0 = pts[i];
         seg.P1 = pts[i + 1];
         coordList.Add(seg.P0, false);
         double len = seg.Length;
         int densifiedSegCount = (int) (len/distanceTolerance) + 1;
         if (densifiedSegCount > 1)
         {
             double densifiedSegLen = len/densifiedSegCount;
             for (int j = 1; j < densifiedSegCount; j++)
             {
                 double segFract = (j*densifiedSegLen)/len;
                 var p = seg.PointAlong(segFract);
                 precModel.MakePrecise(p);
                 coordList.Add(p, false);
             }
         }
     }
     coordList.Add(pts[pts.Length - 1], false);
     return coordList.ToCoordinateArray();
 }
Beispiel #2
0
 /// <summary>
 /// Constructs a GeometryFactory that generates Geometries having the given
 /// PrecisionModel, spatial-reference ID, and CoordinateSequence implementation.
 /// </summary>        
 /// <param name="precisionModel"></param>
 /// <param name="SRID"></param>
 /// <param name="coordinateSequenceFactory"></param>       
 public GeometryFactory(IPrecisionModel precisionModel, int SRID,
     ICoordinateSequenceFactory coordinateSequenceFactory)
 {
     this.precisionModel = precisionModel;
     this.coordinateSequenceFactory = coordinateSequenceFactory;
     this.srid = SRID;
 }
 public OffsetCurveBuilder(
     IPrecisionModel precisionModel,
     IBufferParameters bufParams
     )
 {
     _precisionModel = precisionModel;
     _bufParams = bufParams;
 }
Beispiel #4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="precisionModel"></param>
 /// <param name="quadrantSegments"></param>
 public OffsetCurveBuilder(IPrecisionModel precisionModel, int quadrantSegments)
 {
     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();
     var limitedQuadSegs = quadrantSegments < 1 ? 1 : quadrantSegments;
     filletAngleQuantum = Math.PI / 2.0 / limitedQuadSegs;
 }
        private static void PreciseCoordinateTester(IPrecisionModel pm,
            double x1, double y1,
            double x2, double y2)
        {
            var p = new Coordinate(x1, y1);
            pm.MakePrecise(p);

            var pPrecise = new Coordinate(x2, y2);
            Assert.IsTrue(p.Equals2D(pPrecise), "Expected {0}, but got {1}", pPrecise, p);
        }
Beispiel #6
0
        public WKBReader(IGeometryServices services)
        {
            services = services ?? GeometryServiceProvider.Instance;
            _geometryServices = services;
            _precisionModel = services.DefaultPrecisionModel;
            _sequenceFactory = services.DefaultCoordinateSequenceFactory;

            HandleSRID = true;
            HandleOrdinates = AllowedOrdinates;
        }
Beispiel #7
0
        public WKBReader(IGeometryFactory factory)
        {
            _geometryServices = GeometryServiceProvider.Instance;

            _factory = factory;
            _sequenceFactory = factory.CoordinateSequenceFactory;
            _precisionModel = factory.PrecisionModel;

            HandleSRID = true;
            HandleOrdinates = AllowedOrdinates;
        }
        public OffsetSegmentGenerator(IPrecisionModel precisionModel,
            IBufferParameters bufParams, double distance)
        {
            _precisionModel = precisionModel;
            _bufParams = bufParams;

            // compute intersections in full precision, to provide accuracy
            // the points are rounded as they are inserted into the curve line
            _li = new RobustLineIntersector();
            _filletAngleQuantum = Math.PI / 2.0 / bufParams.QuadrantSegments;

            /**
             * Non-round joins cause issues with short closing segments, so don't use
             * them. In any case, non-round joins only really make sense for relatively
             * small buffer distances.
             */
            if (bufParams.QuadrantSegments >= 8
                && bufParams.JoinStyle == JoinStyle.Round)
                _closingSegLengthFactor = MaxClosingSegLenFactor;
            Init(distance);
        }
        public OldOffsetCurveBuilder(
                      IPrecisionModel precisionModel,
                      IBufferParameters bufParams
                      )
        {
            _precisionModel = precisionModel;
            _bufParams = bufParams;

            // compute intersections in full precision, to provide accuracy
            // the points are rounded as they are inserted into the curve line
            _li = new RobustLineIntersector();
            _filletAngleQuantum = Math.PI / 2.0 / bufParams.QuadrantSegments;

            /**
             * Non-round joins cause issues with short closing segments,
             * so don't use them.  In any case, non-round joins
             * only really make sense for relatively small buffer distances.
             */
            if (bufParams.QuadrantSegments >= 8
                && bufParams.JoinStyle == JoinStyle.Round)
                closingSegFactor = MAX_CLOSING_SEG_FRACTION;
        }
Beispiel #10
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="precisionModel"></param>
 public OffsetCurveBuilder(IPrecisionModel precisionModel)
     : this(precisionModel, DefaultQuadrantSegments)
 {
 }
        /// <summary>
        /// Get Envelope in external coordinates.
        /// </summary>
        /// <param name="precisionModel">The precision model to use</param>
        /// <param name="envelope">The envelope to get</param>
        /// <returns></returns>
        public static Envelope GetEnvelopeExternal(IPrecisionModel precisionModel, Envelope envelope)
        {
            // Get envelope in external coordinates
            var min = new Coordinate(envelope.MinX, envelope.MinY);
            precisionModel.MakePrecise(min);
            var max = new Coordinate(envelope.MaxX, envelope.MaxY);
            precisionModel.MakePrecise(max);
            var bounds = new Envelope(min.X, max.X, min.Y, max.Y);

            return bounds;

            //return GetEnvelopeExternal(envelope);
        }
        private static ICoordinateSequence ReadCompressedXY(byte[] buffer, ref int offset, int number, GaiaImport import, ICoordinateSequenceFactory factory, IPrecisionModel precisionModel)
        {
            var startOrdinateValues = import.GetDoubles(buffer, ref offset, 2);
            var ret = factory.Create(number, import.HandleOrdinates);

            var x = startOrdinateValues[0];
            var y = startOrdinateValues[1];

            ret.SetOrdinate(0, Ordinate.X, precisionModel.MakePrecise(x));
            ret.SetOrdinate(0, Ordinate.Y, precisionModel.MakePrecise(y));

            if (number == 1)
            {
                return(ret);
            }

            var ordinateValues = import.GetSingles(buffer, ref offset, (number - 2) * 2);

            var j = 0;
            int i;

            for (i = 1; i < number - 1; i++)
            {
                x = x + ordinateValues[j++];
                y = y + ordinateValues[j++];
                ret.SetOrdinate(i, Ordinate.X, precisionModel.MakePrecise(x));
                ret.SetOrdinate(i, Ordinate.Y, precisionModel.MakePrecise(y));
            }

            startOrdinateValues = import.GetDoubles(buffer, ref offset, 2);
            ret.SetOrdinate(i, Ordinate.X, precisionModel.MakePrecise(startOrdinateValues[0]));
            ret.SetOrdinate(i, Ordinate.Y, precisionModel.MakePrecise(startOrdinateValues[1]));

            return(ret);
        }
 public EnvelopeTest()
 {
     precisionModel = new PrecisionModel(1);
     geometryFactory = new GeometryFactory(precisionModel, 0);
     reader = new WKTReader(geometryFactory);
 }
Beispiel #14
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="fixedPM"></param>
        private void BufferFixedPrecision(IPrecisionModel fixedPM)
        {
            INoder noder = new ScaledNoder(new MCIndexSnapRounder(new PrecisionModel(1.0)), fixedPM.Scale);

            var bufBuilder = new BufferBuilder
            {
                WorkingPrecisionModel = fixedPM,
                Noder = noder,
                QuadrantSegments = quadrantSegments,
                EndCapStyle = endCapStyle
            };
            // this may throw an exception, if robustness errors are encountered
            resultGeometry = bufBuilder.Buffer(argGeom, distance);
        }
 public GeometryPrecisionReducer(IPrecisionModel pm)
 {
     _targetPrecModel = pm;
 }
Beispiel #16
0
        //private bool isValidityChecked = false;

        /// <summary>
        /// Creates a new noder which snap-rounds to a grid specified by the given <see cref="IPrecisionModel"/>
        /// </summary>
        /// <param name="pm">The precision model for the grid to snap-round to.</param>
        public GeometryNoder(IPrecisionModel pm)
        {
            _pm = pm;
        }
Beispiel #17
0
        /// <summary>
        /// Converts a <c>Coordinate</c> to Point format, then appends
        /// it to the writer.
        /// </summary>
        /// <param name="coordinate">The <c>Coordinate</c> to process.</param>
        /// <param name="writer">The output writer to append to.</param>
        /// <param name="precisionModel">
        /// The <c>PrecisionModel</c> to use to convert
        /// from a precise coordinate to an external coordinate.
        /// </param>
        private void AppendCoordinate(ICoordinate coordinate, TextWriter writer, IPrecisionModel precisionModel)
        {
			writer.Write(WriteNumber(coordinate.X) + " " + WriteNumber(coordinate.Y));
			if (!double.IsNaN(coordinate.Z))
			{
				writer.Write(" " + WriteNumber(coordinate.Z));
			}
        }
Beispiel #18
0
        private static IList <ISegmentString> ExtractTaggedSegmentStrings(IGeometry geom, IPrecisionModel pm)
        {
            var segStrings = new List <ISegmentString>();
            var filter     = new GeometryComponentFilter(
                delegate(IGeometry fgeom)
            {
                // Extract linework for lineal components only
                if (!(fgeom is ILineString))
                {
                    return;
                }
                // skip empty lines
                if (geom.NumPoints <= 0)
                {
                    return;
                }
                var roundPts = Round(((ILineString)fgeom).CoordinateSequence, pm);
                segStrings.Add(new NodedSegmentString(roundPts, fgeom));
            });

            geom.Apply(filter);
            return(segStrings);
        }
Beispiel #19
0
 /// <summary>
 /// Creates a new snap-rounder which snap-rounds to a grid specified
 /// by the given <see cref="IPrecisionModel"/>.
 /// </summary>
 /// <param name="pm">The precision model for the grid to snap-round to</param>
 public GeometrySnapRounder(IPrecisionModel pm)
 {
     _pm = pm;
 }
        /// <summary>
        /// Reads a <see cref="ICoordinateSequence"/> from the stream
        /// </summary>
        /// <param name="reader">The binary reader</param>
        /// <param name="factory">The geometry factory to use for geometry creation.</param>
        /// <param name="precisionModel">The precision model used to make x- and y-ordinates precise.</param>
        /// <param name="numPoints">The number of points in the coordinate sequence.</param>
        /// <param name="ordinates">The ordinates to read. <see cref="Ordinates.XY"/> are always read.</param>
        /// <returns>The coordinate sequence</returns>
        protected ICoordinateSequence ReadCoordinateSequence(BinaryReader reader, ICoordinateSequenceFactory factory, IPrecisionModel precisionModel, int numPoints, Ordinates ordinates)
        {
            var sequence = factory.Create(numPoints, HandleOrdinates);

            var ordinateZ = Coordinate.NullOrdinate;
            var ordinateM = Coordinate.NullOrdinate;

            var getZ = (ordinates & Ordinates.Z) == Ordinates.Z;
            var getM = (ordinates & Ordinates.M) == Ordinates.M;

            var handleZ = (HandleOrdinates & Ordinates.Z) == Ordinates.Z;
            var handleM = (HandleOrdinates & Ordinates.M) == Ordinates.M;

            for (var i = 0; i < numPoints; i++)
            {
                sequence.SetOrdinate(i, Ordinate.X, precisionModel.MakePrecise(reader.ReadDouble()));
                sequence.SetOrdinate(i, Ordinate.Y, precisionModel.MakePrecise(reader.ReadDouble()));
                if (getZ)
                {
                    ordinateZ = reader.ReadDouble();
                }
                if (handleZ)
                {
                    sequence.SetOrdinate(i, Ordinate.Z, ordinateZ);
                }
                if (getM)
                {
                    ordinateM = reader.ReadDouble();
                }
                if (handleM)
                {
                    sequence.SetOrdinate(i, Ordinate.M, ordinateM);
                }
            }
            return(sequence);
        }
        /// <summary>
        /// Reads a coordinate sequence from the stream, which length is not yet known.
        /// </summary>
        /// <param name="reader">The binary reader</param>
        /// <param name="factory">The geometry factory to use for geometry creation.</param>
        /// <param name="precisionModel">The precision model used to make x- and y-ordinates precise.</param>
        /// <param name="ordinates">The ordinates to read. <see cref="Ordinates.XY"/> are always read.</param>
        /// <returns>The coordinate sequence</returns>
        protected ICoordinateSequence ReadCoordinateSequenceRing(BinaryReader reader, ICoordinateSequenceFactory factory, IPrecisionModel precisionModel, Ordinates ordinates)
        {
            var numPoints = reader.ReadInt32();
            var sequence  = ReadCoordinateSequence(reader, factory, precisionModel, numPoints, ordinates);

            if (!RepairRings)
            {
                return(sequence);
            }
            if (CoordinateSequences.IsRing(sequence))
            {
                return(sequence);
            }
            return(CoordinateSequences.EnsureValidRing(factory, sequence));
        }
        /// <summary>
        /// Reads a coordinate sequence from the stream, which length is not yet known.
        /// </summary>
        /// <param name="reader">The binary reader</param>
        /// <param name="factory">The geometry factory to use for geometry creation.</param>
        /// <param name="precisionModel">The precision model used to make x- and y-ordinates precise.</param>
        /// <param name="ordinates">The ordinates to read. <see cref="Ordinates.XY"/> are always read.</param>
        /// <returns>The coordinate sequence</returns>
        protected ICoordinateSequence ReadCoordinateSequence(BinaryReader reader, ICoordinateSequenceFactory factory, IPrecisionModel precisionModel, Ordinates ordinates)
        {
            var numPoints = reader.ReadInt32();

            return(ReadCoordinateSequence(reader, factory, precisionModel, numPoints, ordinates));
        }
 /// <summary>
 /// Constructs a GeometryFactory that generates Geometries having the given
 /// {PrecisionModel} and the default CoordinateSequence
 /// implementation.
 /// </summary>
 /// <param name="precisionModel">The PrecisionModel to use.</param>
 public GeometryFactory(IPrecisionModel precisionModel) 
     : this(precisionModel, 0, GetDefaultCoordinateSequenceFactory()) { }
 /// <summary>
 ///
 /// </summary>
 /// <param name="otherPrecisionModel"></param>
 /// <returns></returns>
 public bool Equals(IPrecisionModel otherPrecisionModel)
 {
     return(Equals((PrecisionModel)otherPrecisionModel));
 }
Beispiel #25
0
 /// <summary>
 /// Converts a <c>Coordinate</c> to Point Tagged Text format,
 /// then appends it to the writer.
 /// </summary>
 /// <param name="coordinate">The <c>Coordinate</c> to process.</param>
 /// <param name="level"></param>
 /// <param name="writer">The output writer to append to.</param>
 /// <param name="precisionModel"> 
 /// The <c>PrecisionModel</c> to use to convert
 /// from a precise coordinate to an external coordinate.
 /// </param>
 private void AppendPointTaggedText(ICoordinate coordinate, int level, TextWriter writer, IPrecisionModel precisionModel)
 {
     writer.Write("POINT");
     AppendPointText(coordinate, level, writer, precisionModel);
 }
Beispiel #26
0
 /// <summary>
 /// Constructs a GeometryFactory that generates Geometries having the given
 /// {PrecisionModel} and the default CoordinateSequence
 /// implementation.
 /// </summary>
 /// <param name="precisionModel">The PrecisionModel to use.</param>
 public GeometryFactory(IPrecisionModel precisionModel)
     : this(precisionModel, 0, GetDefaultCoordinateSequenceFactory())
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MCIndexSnapRounder"/> class.
 /// </summary>
 /// <param name="pm">The <see cref="PrecisionModel" /> to use.</param>
 public MCIndexSnapRounder(IPrecisionModel pm)
 {
     _li = new RobustLineIntersector { PrecisionModel = pm };
     _scaleFactor = pm.Scale;
 }
Beispiel #28
0
 /// <summary>
 /// Converts a <c>Coordinate</c> to Point Tagged Text format,
 /// then appends it to the writer.
 /// </summary>
 /// <param name="coordinate">The <c>Coordinate</c> to process.</param>
 /// <param name="level"></param>
 /// <param name="writer">The output writer to append to.</param>
 /// <param name="precisionModel">
 /// The <c>PrecisionModel</c> to use to convert
 /// from a precise coordinate to an external coordinate.
 /// </param>
 private void AppendPointTaggedText(Coordinate coordinate, int level, TextWriter writer, IPrecisionModel precisionModel)
 {
     writer.Write("POINT ");
     AppendPointText(coordinate, level, writer, precisionModel);
 }
 /// <summary>
 /// Creates an instance of this class using the provided <see cref="ICoordinateSequenceFactory"/> and <see cref="IPrecisionModel"/> to use.
 /// </summary>
 public GeoPackageGeoWriter(ICoordinateSequenceFactory coordinateSequenceFactory, IPrecisionModel precisionModel)
     : this(coordinateSequenceFactory, precisionModel, Ordinates.XYZM)
 {
 }
Beispiel #30
0
 /// <summary>
 /// Converts a <c>Coordinate</c> to Point Text format, then
 /// appends it to the writer.
 /// </summary>
 /// <param name="coordinate">The <c>Coordinate</c> to process.</param>
 /// <param name="level"></param>
 /// <param name="writer">The output writer to append to.</param>
 /// <param name="precisionModel">
 /// The <c>PrecisionModel</c> to use to convert
 /// from a precise coordinate to an external coordinate.
 /// </param>
 private void AppendPointText(Coordinate coordinate, int level, TextWriter writer, IPrecisionModel precisionModel)
 {
     if (coordinate == null)
     {
         writer.Write("EMPTY");
     }
     else
     {
         writer.Write("(");
         AppendCoordinate(coordinate, writer, precisionModel);
         writer.Write(")");
     }
 }
        private static ICoordinateSequence ReadXYZM(byte[] buffer, ref int offset, int number, GaiaImport import, ICoordinateSequenceFactory factory, IPrecisionModel precisionModel)
        {
            var ordinateValues = import.GetDoubles(buffer, ref offset, number * 4);
            var ret            = factory.Create(number, import.HandleOrdinates);
            var handleZ        = (ret.Ordinates & Ordinates.Z) == Ordinates.Z;
            var handleM        = (ret.Ordinates & Ordinates.M) == Ordinates.M;
            var j = 0;

            for (var i = 0; i < number; i++)
            {
                ret.SetOrdinate(i, Ordinate.X, precisionModel.MakePrecise(ordinateValues[j++]));
                ret.SetOrdinate(i, Ordinate.Y, precisionModel.MakePrecise(ordinateValues[j++]));
                if (handleZ)
                {
                    ret.SetOrdinate(i, Ordinate.Z, precisionModel.MakePrecise(ordinateValues[j]));
                }
                j++;
                if (handleM)
                {
                    ret.SetOrdinate(i, Ordinate.M, precisionModel.MakePrecise(ordinateValues[j]));
                }
                j++;
            }
            return(ret);
        }
Beispiel #32
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="precisionModel"></param>
 public OffsetCurveBuilder(IPrecisionModel precisionModel) : this(precisionModel, DefaultQuadrantSegments)
 {
 }
        private static ICoordinateSequence ReadCompressedXYZM(byte[] buffer, ref int offset, int number, GaiaImport import, ICoordinateSequenceFactory factory, IPrecisionModel precisionModel)
        {
            var startOrdinateValues = import.GetDoubles(buffer, ref offset, 4);
            var ret = factory.Create(number, Ordinates.XYM);

            var handleZ = (ret.Ordinates & Ordinates.Z) == Ordinates.Z;
            var handleM = (ret.Ordinates & Ordinates.M) == Ordinates.M;

            var x = startOrdinateValues[0];

            ret.SetOrdinate(0, Ordinate.X, precisionModel.MakePrecise(x));
            var y = startOrdinateValues[1];

            ret.SetOrdinate(0, Ordinate.Y, precisionModel.MakePrecise(y));
            var z = handleZ ? startOrdinateValues[2] : Coordinate.NullOrdinate;

            ret.SetOrdinate(0, Ordinate.Z, z);
            var m = handleM ? startOrdinateValues[3] : Coordinate.NullOrdinate;

            ret.SetOrdinate(0, Ordinate.M, m);

            if (number == 1)
            {
                return(ret);
            }

            var ordinateValues = import.GetSingles(buffer, ref offset, (number - 2) * 4);

            var j = 0;
            int i;

            for (i = 1; i < number - 1; i++)
            {
                x += ordinateValues[j++];
                ret.SetOrdinate(i, Ordinate.X, precisionModel.MakePrecise(x));
                y += ordinateValues[j++];
                ret.SetOrdinate(i, Ordinate.Y, precisionModel.MakePrecise(y));
                if (handleZ)
                {
                    z += ordinateValues[j++];
                }
                ret.SetOrdinate(i, Ordinate.Z, z);
                if (handleM)
                {
                    m += ordinateValues[j++];
                }
                ret.SetOrdinate(i, Ordinate.M, m);
            }

            startOrdinateValues = import.GetDoubles(buffer, ref offset, 4);
            ret.SetOrdinate(i, Ordinate.X, precisionModel.MakePrecise(startOrdinateValues[0]));
            ret.SetOrdinate(i, Ordinate.Y, precisionModel.MakePrecise(startOrdinateValues[1]));
            z = handleZ ? startOrdinateValues[2] : Coordinate.NullOrdinate;
            ret.SetOrdinate(i, Ordinate.Z, z);
            m = handleM ? startOrdinateValues[3] : Coordinate.NullOrdinate;
            ret.SetOrdinate(i, Ordinate.M, m);
            return(ret);
        }
 public PrecisionReducerCoordinateOperation(IPrecisionModel targetPrecModel, bool removeCollapsed)
 {
     _targetPrecModel = targetPrecModel;
     _removeCollapsed = removeCollapsed;
 }
 private static double RandomOrdinate(Ordinate o, IPrecisionModel pm)
 {
     switch (o)
     {
         case Ordinate.X:
             return pm.MakePrecise(-180 + 360 * Rnd.NextDouble());
         case Ordinate.Y:
             return pm.MakePrecise(-90 + 180 * Rnd.NextDouble());
         case Ordinate.Z:
             return 200 * Rnd.NextDouble();
         case Ordinate.M:
             return 200 + 200 * Rnd.NextDouble();
         default:
             throw new NotSupportedException();
     }
 }
 /// Creates an instance of this class using the default
 /// values for <see cref="GeometryFactory.SRID"/>,
 /// <see cref="GeometryFactory.CoordinateSequenceFactory"/> but the
 /// specified <paramref name="pm"/>.
 public OgcCompliantGeometryFactory(IPrecisionModel pm)
     : base(pm)
 {
 }
Beispiel #37
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="otherPrecisionModel"></param>
 /// <returns></returns>
 public bool Equals(IPrecisionModel otherPrecisionModel)
 {
     return(_modelType == otherPrecisionModel.PrecisionModelType &&
            _scale == otherPrecisionModel.Scale);
 }
 public OgcCompliantGeometryFactory(IPrecisionModel pm, int srid)
     : base(pm, srid)
 {
 }
 /// <summary>
 /// Method to write the bounding box of x- and y- ordinates (aka envelope)
 /// </summary>
 /// <param name="writer">The writer to use</param>
 /// <param name="precisionModel">The precision model to precise</param>
 /// <param name="envelope">The envelope to write</param>
 protected static void WriteEnvelope(BinaryWriter writer, IPrecisionModel precisionModel, Envelope envelope)
 {
     //precise the envelope
     envelope = GetEnvelopeExternal(precisionModel, envelope);
     
     writer.Write(envelope.MinX);
     writer.Write(envelope.MinY);
     writer.Write(envelope.MaxX);
     writer.Write(envelope.MaxY);
 }
 public OgcCompliantGeometryFactory(IPrecisionModel pm, int srid, ICoordinateSequenceFactory factory)
     : base(pm, srid, factory)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="IteratedNoder"/> class.
 /// </summary>
 /// <param name="pm"></param>
 public IteratedNoder(IPrecisionModel pm)
 {
     _li = new RobustLineIntersector {PrecisionModel = pm};
 }
Beispiel #42
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="precisionModel"></param>
        /// <returns></returns>
        private INoder GetNoder(IPrecisionModel precisionModel)
        {
            if (workingNoder != null) 
                return workingNoder;

            // otherwise use a fast (but non-robust) noder
            LineIntersector li = new RobustLineIntersector();
            li.PrecisionModel = precisionModel;
            MCIndexNoder noder = new MCIndexNoder(new IntersectionAdder(li));                     
            return noder;
        }
Beispiel #43
0
 /// <summary>
 /// Converts a <c>Coordinate</c> to Point Text format, then
 /// appends it to the writer.
 /// </summary>
 /// <param name="coordinate">The <c>Coordinate</c> to process.</param>
 /// <param name="level"></param>
 /// <param name="writer">The output writer to append to.</param>
 /// <param name="precisionModel">
 /// The <c>PrecisionModel</c> to use to convert
 /// from a precise coordinate to an external coordinate.
 /// </param>
 private void AppendPointText(ICoordinate coordinate, int level, TextWriter writer, IPrecisionModel precisionModel)
 {
     if (coordinate == null) 
         writer.Write(" EMPTY");
     else 
     {
         writer.Write("(");
         AppendCoordinate(coordinate, writer, precisionModel);
         writer.Write(")");
     }
 }
 public AreaLengthTest()
 {
     precisionModel = new PrecisionModel(1);
     geometryFactory = new GeometryFactory(precisionModel, 0);
     reader = new WKTReader(geometryFactory);
 }
Beispiel #45
0
        /// <summary>  
        /// Creates the <c>NumberFormatInfo</c> used to write <c>double</c>s
        /// with a sufficient number of decimal places.
        /// </summary>
        /// <param name="precisionModel"> 
        /// The <c>PrecisionModel</c> used to determine
        /// the number of decimal places to write.
        /// </param>
        /// <returns>
        /// A <c>NumberFormatInfo</c> that write <c>double</c>
        /// s without scientific notation.
        /// </returns>
        private static NumberFormatInfo CreateFormatter(IPrecisionModel precisionModel) 
        {
            // the default number of decimal places is 16, which is sufficient
            // to accomodate the maximum precision of a double.
            int decimalPlaces = precisionModel.MaximumSignificantDigits;

            // specify decimal separator explicitly to avoid problems in other locales
            NumberFormatInfo nfi = new NumberFormatInfo();
            nfi.NumberDecimalSeparator = ".";            
            nfi.NumberDecimalDigits = decimalPlaces;            
            nfi.NumberGroupSeparator = String.Empty;
            nfi.NumberGroupSizes = new int[] { };
            return nfi;            
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public int CompareTo(IPrecisionModel other)
 {
     int sigDigits = MaximumSignificantDigits;
     int otherSigDigits = other.MaximumSignificantDigits;
     return (sigDigits).CompareTo(otherSigDigits);
 }
        //private bool isValidityChecked = false;

        /// <summary>
        /// Creates a new noder which snap-rounds to a grid specified by the given <see cref="IPrecisionModel"/>
        /// </summary>
        /// <param name="pm">The precision model for the grid to snap-round to.</param>
        public GeometryNoder(IPrecisionModel pm)
        {
            _pm = pm;
        }
Beispiel #48
0
 /// <summary>
 /// Get Envelope in external coordinates.
 /// </summary>
 /// <param name="precisionModel"></param>
 /// <param name="envelope"></param>
 /// <returns></returns>
 public static IEnvelope GetEnvelopeExternal(IPrecisionModel precisionModel, IEnvelope envelope)
 {
     return(GetEnvelopeExternal(envelope));
 }
 /// <summary>
 /// Creates an instance of this class using the provided <see cref="ICoordinateSequenceFactory"/> and <see cref="IPrecisionModel"/> to use.
 /// Additionally the ordinate values that are to be handled can be set.
 /// </summary>
 public GeoPackageGeoWriter(ICoordinateSequenceFactory coordinateSequenceFactory, IPrecisionModel precisionModel, Ordinates handleOrdinates)
 {
     _coordinateSequenceFactory = coordinateSequenceFactory;
     _precisionModel            = precisionModel;
     _handleOrdinates           = handleOrdinates;
 }
Beispiel #50
0
 /// <summary>
 /// Creates a <c>WKTReader</c> that creates objects using the given
 /// <c>GeometryFactory</c>.
 /// </summary>
 /// <param name="geometryFactory">The factory used to create <c>Geometry</c>s.</param>
 public WKTReader(IGeometryFactory geometryFactory)
 {
     _coordinateSequencefactory = geometryFactory.CoordinateSequenceFactory;
     _precisionModel            = geometryFactory.PrecisionModel;
     DefaultSRID = geometryFactory.SRID;
 }
 public PointImplTest()
 {
     precisionModel  = new PrecisionModel(1000);
     geometryFactory = new GeometryFactory(precisionModel, 0);
     reader          = new WKTReader(geometryFactory);
 }
        /// <summary>
        /// Convenience method for doing precision reduction
        /// on a single geometry,
        /// with collapses removed
        /// and keeping the geometry precision model the same,
        /// and preserving polygonal topology.
        /// </summary>
        /// <param name="g">The geometry to reduce</param>
        /// <param name="precModel">The precision model to use</param>
        /// <returns>The reduced geometry</returns>
        public static IGeometry Reduce(IGeometry g, IPrecisionModel precModel)
        {
            var reducer = new GeometryPrecisionReducer(precModel);

            return(reducer.Reduce(g));
        }
Beispiel #53
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="bufferSegStrList"></param>
 /// <param name="precisionModel"></param>
 private void ComputeNodedEdges(IList bufferSegStrList, IPrecisionModel precisionModel)
 {
     INoder noder = GetNoder(precisionModel);
     noder.ComputeNodes(bufferSegStrList);
     IList nodedSegStrings = noder.GetNodedSubstrings();
     
     foreach(object obj in nodedSegStrings)
     {
         SegmentString segStr = (SegmentString) obj;
         Label oldLabel = (Label) segStr.Data;
         Edge edge = new Edge(segStr.Coordinates, new Label(oldLabel));
         InsertEdge(edge);
     }
 }
 /// <summary>
 /// Create a shape factory which will create shapes using the given GeometryFactory.
 /// </summary>
 /// <param name="geomFact">The factory to use.</param>
 public GeometricShapeFactory(IGeometryFactory geomFact)
 {
     GeomFact  = geomFact;
     PrecModel = geomFact.PrecisionModel;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="otherPrecisionModel"></param>
 /// <returns></returns>
 public bool Equals(IPrecisionModel otherPrecisionModel)
 {
     return _modelType == otherPrecisionModel.PrecisionModelType &&
             _scale == otherPrecisionModel.Scale;
 }
 public GaiaGeoReader(ICoordinateSequenceFactory coordinateSequenceFactory, IPrecisionModel precisionModel)
     : this(coordinateSequenceFactory, precisionModel, Ordinates.XYZM)
 {
 }
 ///<summary>
 /// Determines which of two <see cref="IPrecisionModel"/>s is the most precise
 ///</summary>
 /// <param name="pm1">A precision model</param>
 /// <param name="pm2">A precision model</param>
 /// <returns>The PrecisionModel which is most precise</returns>
 public static IPrecisionModel MostPrecise(IPrecisionModel pm1, IPrecisionModel pm2)
 {
     if (pm1.CompareTo(pm2) >= 0)
         return pm1;
     return pm2;
 }
        private static ICoordinateSequence ReadXY(byte[] buffer, ref int offset, int number, GaiaImport import, ICoordinateSequenceFactory factory, IPrecisionModel precisionModel)
        {
            var ordinateValues = import.GetDoubles(buffer, ref offset, number * 2);
            var ret            = factory.Create(number, Ordinates.XY);
            var j = 0;

            for (var i = 0; i < number; i++)
            {
                ret.SetOrdinate(i, Ordinate.X, precisionModel.MakePrecise(ordinateValues[j++]));
                ret.SetOrdinate(i, Ordinate.Y, precisionModel.MakePrecise(ordinateValues[j++]));
            }
            return(ret);
        }
 /// <summary>
 /// Creates a new noder which snap-rounds to a grid specified
 /// by the given <see cref="IPrecisionModel"/>.
 /// </summary>
 /// <param name="pm">The precision model for the grid to snap-round to</param>
 public GeometrySnapRounder(IPrecisionModel pm)
 {
     _pm = pm;
 }
 public GaiaGeoReader(ICoordinateSequenceFactory coordinateSequenceFactory, IPrecisionModel precisionModel, Ordinates handleOrdinates)
 {
     _coordinateSequenceFactory = coordinateSequenceFactory;
     _precisionModel            = precisionModel;
     _handleOrdinates           = handleOrdinates;
 }