Ejemplo n.º 1
0
 /// <summary>
 /// Changes this envelope to be the intersection of itself with the other
 /// envelope.
 /// </summary>
 /// <param name="other">The envelope to intersect.</param>
 /// <returns>Returns true if the result is not empty.</returns>
 public virtual bool Intersect(com.epl.geometry.Envelope other)
 {
     _touch();
     com.epl.geometry.Envelope2D e2d = new com.epl.geometry.Envelope2D();
     other.QueryEnvelope2D(e2d);
     return(m_envelope.Intersect(e2d));
 }
 // clementini's disjoint
 private static int QuickTest2DEnvelopeEnvelope(com.epl.geometry.Envelope geomA, com.epl.geometry.Envelope geomB, double tolerance)
 {
     com.epl.geometry.Envelope2D geomAEnv = new com.epl.geometry.Envelope2D();
     geomA.QueryEnvelope2D(geomAEnv);
     com.epl.geometry.Envelope2D geomBEnv = new com.epl.geometry.Envelope2D();
     geomB.QueryEnvelope2D(geomBEnv);
     return(QuickTest2DEnvelopeEnvelope(geomAEnv, geomBEnv, tolerance));
 }
 private static int QuickTest2DEnvelopePoint(com.epl.geometry.Envelope geomA, com.epl.geometry.Point geomB, double tolerance)
 {
     com.epl.geometry.Envelope2D geomAEnv = new com.epl.geometry.Envelope2D();
     geomA.QueryEnvelope2D(geomAEnv);
     com.epl.geometry.Point2D ptB;
     ptB = geomB.GetXY();
     return(QuickTest2DEnvelopePoint(geomAEnv, ptB, tolerance));
 }
 // return the input point
 internal static com.epl.geometry.Geometry PointMinusEnvelope_(com.epl.geometry.Point point, com.epl.geometry.Envelope envelope, double tolerance, com.epl.geometry.ProgressTracker progress_tracker)
 {
     com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D();
     envelope.QueryEnvelope2D(env);
     env.Inflate(tolerance, tolerance);
     com.epl.geometry.Point2D pt = point.GetXY();
     if (!env.Contains(pt))
     {
         return(point);
     }
     return(point.CreateInstance());
 }
        private com.epl.geometry.Geometry DensifyEnvelope(com.epl.geometry.Envelope geom)
        {
            com.epl.geometry.Polygon polygon = new com.epl.geometry.Polygon(geom.GetDescription());
            polygon.AddEnvelope(geom, false);
            com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
            geom.QueryEnvelope2D(env2D);
            double w = env2D.GetWidth();
            double h = env2D.GetHeight();

            if (w <= m_maxLength && h <= m_maxLength)
            {
                return((com.epl.geometry.Geometry)polygon);
            }
            return(DensifyMultiPath((com.epl.geometry.MultiPath)polygon));
        }
        internal static com.epl.geometry.Geometry MultiPointMinusEnvelope_(com.epl.geometry.MultiPoint multi_point, com.epl.geometry.Envelope envelope, double tolerance, com.epl.geometry.ProgressTracker progress_tracker)
        {
            com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D();
            envelope.QueryEnvelope2D(env);
            env.Inflate(tolerance, tolerance);
            int  point_count     = multi_point.GetPointCount();
            bool b_found_covered = false;

            bool[] covered = new bool[point_count];
            for (int i = 0; i < point_count; i++)
            {
                covered[i] = false;
            }
            com.epl.geometry.Point2D pt = new com.epl.geometry.Point2D();
            for (int i_1 = 0; i_1 < point_count; i_1++)
            {
                multi_point.GetXY(i_1, pt);
                if (!env.Contains(pt))
                {
                    continue;
                }
                b_found_covered = true;
                covered[i_1]    = true;
            }
            if (!b_found_covered)
            {
                return(multi_point);
            }
            com.epl.geometry.MultiPoint new_multipoint = (com.epl.geometry.MultiPoint)multi_point.CreateInstance();
            for (int i_2 = 0; i_2 < point_count; i_2++)
            {
                if (!covered[i_2])
                {
                    new_multipoint.Add(multi_point, i_2, i_2 + 1);
                }
            }
            return(new_multipoint);
        }
        // return -1;
        private static int ExportEnvelopeToESRIShape(int exportFlags, com.epl.geometry.Envelope envelope, System.IO.BinaryWriter shapeBuffer)
        {
            bool bExportZs    = envelope.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z) && (exportFlags & com.epl.geometry.ShapeExportFlags.ShapeExportStripZs) == 0;
            bool bExportMs    = envelope.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M) && (exportFlags & com.epl.geometry.ShapeExportFlags.ShapeExportStripMs) == 0;
            bool bExportIDs   = envelope.HasAttribute(com.epl.geometry.VertexDescription.Semantics.ID) && (exportFlags & com.epl.geometry.ShapeExportFlags.ShapeExportStripIDs) == 0;
            bool bArcViewNaNs = (exportFlags & com.epl.geometry.ShapeExportFlags.ShapeExportTrueNaNs) == 0;
            bool bEmpty       = envelope.IsEmpty();
            int  partCount    = bEmpty ? 0 : 1;
            int  pointCount   = bEmpty ? 0 : 5;
            int  size         = (4) + (4 * 8) + (4) + (4) + (partCount * 4) + pointCount * 2 * 8;

            /* type */
            /* envelope */
            /* part count */
            /* point count */
            /* start indices */
            /* xy coordinates */
            if (bExportZs)
            {
                size += (2 * 8) + (pointCount * 8);
            }
            /* min max */
            /* zs */
            if (bExportMs)
            {
                size += (2 * 8) + (pointCount * 8);
            }
            /* min max */
            /* ms */
            if (bExportIDs)
            {
                size += (pointCount * 4);
            }
            /* ids */
            if (shapeBuffer == null)
            {
                return(size);
            }
            else
            {
                if (((System.IO.MemoryStream)shapeBuffer.BaseStream).Capacity < size)
                {
                    throw new com.epl.geometry.GeometryException("buffer is too small");
                }
            }
            int type;

            // Determine the shape type
            if (!bExportZs && !bExportMs)
            {
                if (bExportIDs)
                {
                    type = com.epl.geometry.ShapeType.ShapeGeneralPolygon | com.epl.geometry.ShapeModifiers.ShapeHasIDs;
                }
                else
                {
                    type = com.epl.geometry.ShapeType.ShapePolygon;
                }
            }
            else
            {
                if (bExportZs && !bExportMs)
                {
                    if (bExportIDs)
                    {
                        type = com.epl.geometry.ShapeType.ShapeGeneralPolygon | com.epl.geometry.ShapeModifiers.ShapeHasZs | com.epl.geometry.ShapeModifiers.ShapeHasIDs;
                    }
                    else
                    {
                        type = com.epl.geometry.ShapeType.ShapePolygonZ;
                    }
                }
                else
                {
                    if (bExportMs && !bExportZs)
                    {
                        if (bExportIDs)
                        {
                            type = com.epl.geometry.ShapeType.ShapeGeneralPolygon | com.epl.geometry.ShapeModifiers.ShapeHasMs | com.epl.geometry.ShapeModifiers.ShapeHasIDs;
                        }
                        else
                        {
                            type = com.epl.geometry.ShapeType.ShapePolygonM;
                        }
                    }
                    else
                    {
                        if (bExportIDs)
                        {
                            type = com.epl.geometry.ShapeType.ShapeGeneralPolygon | com.epl.geometry.ShapeModifiers.ShapeHasZs | com.epl.geometry.ShapeModifiers.ShapeHasMs | com.epl.geometry.ShapeModifiers.ShapeHasIDs;
                        }
                        else
                        {
                            type = com.epl.geometry.ShapeType.ShapePolygonZM;
                        }
                    }
                }
            }
            int offset = 0;

            // write type
            shapeBuffer.Write(type);
            offset += 4;
            // write Envelope
            com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D();
            envelope.QueryEnvelope2D(env);
            // calls _VerifyAllStreams
            shapeBuffer.Write(env.xmin);
            offset += 8;
            shapeBuffer.Write(env.ymin);
            offset += 8;
            shapeBuffer.Write(env.xmax);
            offset += 8;
            shapeBuffer.Write(env.ymax);
            offset += 8;
            // write part count
            shapeBuffer.Write(partCount);
            offset += 4;
            // write pointCount
            shapeBuffer.Write(pointCount);
            offset += 4;
            if (!bEmpty)
            {
                // write start index
                shapeBuffer.Write(0);
                offset += 4;
                // write xy coordinates
                shapeBuffer.Write(env.xmin);
                offset += 8;
                shapeBuffer.Write(env.ymin);
                offset += 8;
                shapeBuffer.Write(env.xmin);
                offset += 8;
                shapeBuffer.Write(env.ymax);
                offset += 8;
                shapeBuffer.Write(env.xmax);
                offset += 8;
                shapeBuffer.Write(env.ymax);
                offset += 8;
                shapeBuffer.Write(env.xmax);
                offset += 8;
                shapeBuffer.Write(env.ymin);
                offset += 8;
                shapeBuffer.Write(env.xmin);
                offset += 8;
                shapeBuffer.Write(env.ymin);
                offset += 8;
            }
            // write Zs
            if (bExportZs)
            {
                com.epl.geometry.Envelope1D zInterval;
                zInterval = envelope.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0);
                double zmin = bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(zInterval.vmin) : zInterval.vmin;
                double zmax = bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(zInterval.vmax) : zInterval.vmax;
                // write min max values
                shapeBuffer.Write(zmin);
                offset += 8;
                shapeBuffer.Write(zmax);
                offset += 8;
                if (!bEmpty)
                {
                    // write arbitrary z values
                    shapeBuffer.Write(zmin);
                    offset += 8;
                    shapeBuffer.Write(zmax);
                    offset += 8;
                    shapeBuffer.Write(zmin);
                    offset += 8;
                    shapeBuffer.Write(zmax);
                    offset += 8;
                    shapeBuffer.Write(zmin);
                    offset += 8;
                }
            }
            // write Ms
            if (bExportMs)
            {
                com.epl.geometry.Envelope1D mInterval;
                mInterval = envelope.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0);
                double mmin = bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(mInterval.vmin) : mInterval.vmin;
                double mmax = bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(mInterval.vmax) : mInterval.vmax;
                // write min max values
                shapeBuffer.Write(mmin);
                offset += 8;
                shapeBuffer.Write(mmax);
                offset += 8;
                if (!bEmpty)
                {
                    // write arbitrary m values
                    shapeBuffer.Write(mmin);
                    offset += 8;
                    shapeBuffer.Write(mmax);
                    offset += 8;
                    shapeBuffer.Write(mmin);
                    offset += 8;
                    shapeBuffer.Write(mmax);
                    offset += 8;
                    shapeBuffer.Write(mmin);
                    offset += 8;
                }
            }
            // write IDs
            if (bExportIDs && !bEmpty)
            {
                com.epl.geometry.Envelope1D idInterval;
                idInterval = envelope.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0);
                int idmin = (int)idInterval.vmin;
                int idmax = (int)idInterval.vmax;
                // write arbitrary id values
                shapeBuffer.Write(idmin);
                offset += 4;
                shapeBuffer.Write(idmax);
                offset += 4;
                shapeBuffer.Write(idmin);
                offset += 4;
                shapeBuffer.Write(idmax);
                offset += 4;
                shapeBuffer.Write(idmin);
                offset += 4;
            }
            return(offset);
        }
 // Checked vs. Jan 11, 2011
 protected internal virtual void _updateEnvelope(com.epl.geometry.Envelope2D env)
 {
     _updateAllDirtyIntervals(true);
     m_envelope.QueryEnvelope2D(env);
 }
Ejemplo n.º 9
0
		internal virtual com.epl.geometry.Geometry TryNativeImplementation_(com.epl.geometry.Geometry input_geom)
		{
			// A note on attributes:
			// 1. The geometry with lower dimension wins in regard to the
			// attributes.
			// 2. If the dimensions are the same, the input_geometry attributes win.
			// 3. The exception to the 2. is when the input is an Envelope, and the
			// intersector is a polygon, then the intersector wins.
			// A note on the tolerance:
			// This operator performs a simple intersection operation. Should it use
			// the tolerance?
			// Example: Point is intersected by the envelope.
			// If it is slightly outside of the envelope, should we still return it
			// if it is closer than the tolerance?
			// Should we do crack and cluster and snap the point coordinates to the
			// envelope boundary?
			//
			// Consider floating point arithmetics approach. When you compare
			// doubles, you should use an epsilon (equals means ::fabs(a - b) <
			// eps), however when you add/subtract, etc them, you do not use
			// epsilon.
			// Shouldn't we do same here? Relational operators use tolerance, but
			// the action operators don't.
			com.epl.geometry.Envelope2D mergedExtent = com.epl.geometry.InternalUtils.GetMergedExtent(input_geom, m_geomIntersector);
			double tolerance = com.epl.geometry.InternalUtils.CalculateToleranceFromGeometry(m_spatial_reference, mergedExtent, false);
			int gtInput = input_geom.GetType().Value();
			bool bInputEmpty = input_geom.IsEmpty();
			bool bGeomIntersectorEmpty = m_geomIntersector.IsEmpty();
			bool bResultIsEmpty = bInputEmpty || bGeomIntersectorEmpty;
			if (!bResultIsEmpty)
			{
				// test envelopes
				com.epl.geometry.Envelope2D env2D1 = new com.epl.geometry.Envelope2D();
				input_geom.QueryEnvelope2D(env2D1);
				com.epl.geometry.Envelope2D env2D2 = new com.epl.geometry.Envelope2D();
				m_geomIntersector.QueryEnvelope2D(env2D2);
				env2D2.Inflate(2.0 * tolerance, 2.0 * tolerance);
				bResultIsEmpty = !env2D1.IsIntersecting(env2D2);
			}
			if (!bResultIsEmpty)
			{
				// try accelerated test
				int res = com.epl.geometry.OperatorInternalRelationUtils.QuickTest2D_Accelerated_DisjointOrContains(m_geomIntersector, input_geom, tolerance);
				if (res == com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint)
				{
					// disjoint
					bResultIsEmpty = true;
				}
				else
				{
					if ((res & com.epl.geometry.OperatorInternalRelationUtils.Relation.Within) != 0)
					{
						// intersector
						// is
						// within
						// the
						// input_geom
						// TODO:
						// assign
						// input_geom
						// attributes
						// first
						return m_geomIntersector;
					}
					else
					{
						if ((res & com.epl.geometry.OperatorInternalRelationUtils.Relation.Contains) != 0)
						{
							// intersector
							// contains
							// input_geom
							return input_geom;
						}
					}
				}
			}
			if (bResultIsEmpty)
			{
				// When one geometry or both are empty, we need to
				// return an empty geometry.
				// Here we do that end also ensure the type is
				// correct.
				// That is the lower dimension need to be
				// returned. Also, for Point vs Multi_point, an
				// empty Point need to be returned.
				int dim1 = com.epl.geometry.Geometry.GetDimensionFromType(gtInput);
				int dim2 = com.epl.geometry.Geometry.GetDimensionFromType(m_geomIntersectorType);
				if (dim1 < dim2)
				{
					return ReturnEmpty_(input_geom, bInputEmpty);
				}
				else
				{
					if (dim1 > dim2)
					{
						return ReturnEmptyIntersector_();
					}
					else
					{
						if (dim1 == 0)
						{
							if (gtInput == com.epl.geometry.Geometry.GeometryType.MultiPoint && m_geomIntersectorType == com.epl.geometry.Geometry.GeometryType.Point)
							{
								// point
								// vs
								// Multi_point
								// need
								// special
								// treatment
								// to
								// ensure
								// Point
								// is
								// returned
								// always.
								return ReturnEmptyIntersector_();
							}
							else
							{
								// Both input and intersector have same gtype, or input is
								// Point.
								return ReturnEmpty_(input_geom, bInputEmpty);
							}
						}
						else
						{
							return ReturnEmpty_(input_geom, bInputEmpty);
						}
					}
				}
			}
			// Note: No empty geometries after this point!
			// Warning: Do not try clip for polylines and polygons.
			// Try clip of Envelope with Envelope.
			if ((m_dimensionMask == -1 || m_dimensionMask == (1 << 2)) && gtInput == com.epl.geometry.Geometry.GeometryType.Envelope && m_geomIntersectorType == com.epl.geometry.Geometry.GeometryType.Envelope)
			{
				com.epl.geometry.Envelope env1 = (com.epl.geometry.Envelope)input_geom;
				com.epl.geometry.Envelope env2 = (com.epl.geometry.Envelope)m_geomIntersector;
				com.epl.geometry.Envelope2D env2D_1 = new com.epl.geometry.Envelope2D();
				env1.QueryEnvelope2D(env2D_1);
				com.epl.geometry.Envelope2D env2D_2 = new com.epl.geometry.Envelope2D();
				env2.QueryEnvelope2D(env2D_2);
				env2D_1.Intersect(env2D_2);
				com.epl.geometry.Envelope result_env = new com.epl.geometry.Envelope();
				env1.CopyTo(result_env);
				result_env.SetEnvelope2D(env2D_1);
				return result_env;
			}
			// Use clip for Point and Multi_point with Envelope
			if ((gtInput == com.epl.geometry.Geometry.GeometryType.Envelope && com.epl.geometry.Geometry.GetDimensionFromType(m_geomIntersectorType) == 0) || (m_geomIntersectorType == com.epl.geometry.Geometry.GeometryType.Envelope && com.epl.geometry.Geometry.GetDimensionFromType(gtInput
				) == 0))
			{
				com.epl.geometry.Envelope env = gtInput == com.epl.geometry.Geometry.GeometryType.Envelope ? (com.epl.geometry.Envelope)input_geom : (com.epl.geometry.Envelope)m_geomIntersector;
				com.epl.geometry.Geometry other = gtInput == com.epl.geometry.Geometry.GeometryType.Envelope ? m_geomIntersector : input_geom;
				com.epl.geometry.Envelope2D env_2D = new com.epl.geometry.Envelope2D();
				env.QueryEnvelope2D(env_2D);
				return com.epl.geometry.Clipper.Clip(other, env_2D, tolerance, 0);
			}
			if ((com.epl.geometry.Geometry.GetDimensionFromType(gtInput) == 0 && com.epl.geometry.Geometry.GetDimensionFromType(m_geomIntersectorType) > 0) || (com.epl.geometry.Geometry.GetDimensionFromType(gtInput) > 0 && com.epl.geometry.Geometry.GetDimensionFromType(m_geomIntersectorType
				) == 0))
			{
				// multipoint
				// intersection
				double tolerance1 = com.epl.geometry.InternalUtils.CalculateToleranceFromGeometry(m_spatial_reference, input_geom, false);
				if (gtInput == com.epl.geometry.Geometry.GeometryType.MultiPoint)
				{
					return com.epl.geometry.TopologicalOperations.Intersection((com.epl.geometry.MultiPoint)input_geom, m_geomIntersector, tolerance1);
				}
				if (gtInput == com.epl.geometry.Geometry.GeometryType.Point)
				{
					return com.epl.geometry.TopologicalOperations.Intersection((com.epl.geometry.Point)input_geom, m_geomIntersector, tolerance1);
				}
				if (m_geomIntersectorType == com.epl.geometry.Geometry.GeometryType.MultiPoint)
				{
					return com.epl.geometry.TopologicalOperations.Intersection((com.epl.geometry.MultiPoint)m_geomIntersector, input_geom, tolerance1);
				}
				if (m_geomIntersectorType == com.epl.geometry.Geometry.GeometryType.Point)
				{
					return com.epl.geometry.TopologicalOperations.Intersection((com.epl.geometry.Point)m_geomIntersector, input_geom, tolerance1);
				}
				throw com.epl.geometry.GeometryException.GeometryInternalError();
			}
			// Try Polyline vs Polygon
			if ((m_dimensionMask == -1 || m_dimensionMask == (1 << 1)) && (gtInput == com.epl.geometry.Geometry.GeometryType.Polyline) && (m_geomIntersectorType == com.epl.geometry.Geometry.GeometryType.Polygon))
			{
				return TryFastIntersectPolylinePolygon_((com.epl.geometry.Polyline)(input_geom), (com.epl.geometry.Polygon)(m_geomIntersector));
			}
			// Try Polygon vs Polyline
			if ((m_dimensionMask == -1 || m_dimensionMask == (1 << 1)) && (gtInput == com.epl.geometry.Geometry.GeometryType.Polygon) && (m_geomIntersectorType == com.epl.geometry.Geometry.GeometryType.Polyline))
			{
				return TryFastIntersectPolylinePolygon_((com.epl.geometry.Polyline)(m_geomIntersector), (com.epl.geometry.Polygon)(input_geom));
			}
			return null;
		}
 private static int QuickTest2DMultiPointEnvelope(com.epl.geometry.MultiPoint geomA, com.epl.geometry.Envelope geomB, double tolerance, int testType)
 {
     com.epl.geometry.Envelope2D geomBEnv = new com.epl.geometry.Envelope2D();
     geomB.QueryEnvelope2D(geomBEnv);
     return(QuickTest2DMultiPointEnvelope(geomA, geomBEnv, tolerance, testType));
 }
 internal static com.epl.geometry.Geometry CalculateConvexHull_(com.epl.geometry.Geometry geom, com.epl.geometry.ProgressTracker progress_tracker)
 {
     if (geom.IsEmpty())
     {
         return(geom.CreateInstance());
     }
     com.epl.geometry.Geometry.Type type = geom.GetType();
     if (com.epl.geometry.Geometry.IsSegment(type.Value()))
     {
         // Segments are always returned either as a Point or Polyline
         com.epl.geometry.Segment segment = (com.epl.geometry.Segment)geom;
         if (segment.GetStartXY().Equals(segment.GetEndXY()))
         {
             com.epl.geometry.Point point = new com.epl.geometry.Point();
             segment.QueryStart(point);
             return(point);
         }
         else
         {
             com.epl.geometry.Point    pt       = new com.epl.geometry.Point();
             com.epl.geometry.Polyline polyline = new com.epl.geometry.Polyline(geom.GetDescription());
             segment.QueryStart(pt);
             polyline.StartPath(pt);
             segment.QueryEnd(pt);
             polyline.LineTo(pt);
             return(polyline);
         }
     }
     else
     {
         if (type == com.epl.geometry.Geometry.Type.Envelope)
         {
             com.epl.geometry.Envelope   envelope = (com.epl.geometry.Envelope)geom;
             com.epl.geometry.Envelope2D env      = new com.epl.geometry.Envelope2D();
             envelope.QueryEnvelope2D(env);
             if (env.xmin == env.xmax && env.ymin == env.ymax)
             {
                 com.epl.geometry.Point point = new com.epl.geometry.Point();
                 envelope.QueryCornerByVal(0, point);
                 return(point);
             }
             else
             {
                 if (env.xmin == env.xmax || env.ymin == env.ymax)
                 {
                     com.epl.geometry.Point    pt       = new com.epl.geometry.Point();
                     com.epl.geometry.Polyline polyline = new com.epl.geometry.Polyline(geom.GetDescription());
                     envelope.QueryCornerByVal(0, pt);
                     polyline.StartPath(pt);
                     envelope.QueryCornerByVal(1, pt);
                     polyline.LineTo(pt);
                     return(polyline);
                 }
                 else
                 {
                     com.epl.geometry.Polygon polygon = new com.epl.geometry.Polygon(geom.GetDescription());
                     polygon.AddEnvelope(envelope, false);
                     return(polygon);
                 }
             }
         }
     }
     if (IsConvex_(geom, progress_tracker))
     {
         if (type == com.epl.geometry.Geometry.Type.MultiPoint)
         {
             // Downgrade to a Point for simplistic output
             com.epl.geometry.MultiPoint multi_point = (com.epl.geometry.MultiPoint)geom;
             com.epl.geometry.Point      point       = new com.epl.geometry.Point();
             multi_point.GetPointByVal(0, point);
             return(point);
         }
         return(geom);
     }
     System.Diagnostics.Debug.Assert((com.epl.geometry.Geometry.IsMultiVertex(type.Value())));
     com.epl.geometry.Geometry convex_hull = com.epl.geometry.ConvexHull.Construct((com.epl.geometry.MultiVertexGeometry)geom);
     return(convex_hull);
 }
        /// <exception cref="com.fasterxml.jackson.core.JsonParseException"/>
        /// <exception cref="System.IO.IOException"/>
        internal virtual bool TestEnvelope()
        {
            bool bAnswer = true;

            com.epl.geometry.Envelope envelope = new com.epl.geometry.Envelope();
            envelope.SetCoords(-109.55, 25.76, -86.39, 49.94);
            {
                com.fasterxml.jackson.core.JsonParser envelopeWGS84Parser = factory.CreateParser(com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWGS84, envelope));
                com.epl.geometry.MapGeometry          envelopeWGS84MP     = com.epl.geometry.GeometryEngine.JsonToGeometry(envelopeWGS84Parser);
                NUnit.Framework.Assert.IsTrue(envelope.IsEmpty() == envelopeWGS84MP.GetGeometry().IsEmpty());
                NUnit.Framework.Assert.IsTrue(envelope.GetXMax() == ((com.epl.geometry.Envelope)envelopeWGS84MP.GetGeometry()).GetXMax());
                NUnit.Framework.Assert.IsTrue(envelope.GetYMax() == ((com.epl.geometry.Envelope)envelopeWGS84MP.GetGeometry()).GetYMax());
                NUnit.Framework.Assert.IsTrue(envelope.GetXMin() == ((com.epl.geometry.Envelope)envelopeWGS84MP.GetGeometry()).GetXMin());
                NUnit.Framework.Assert.IsTrue(envelope.GetYMin() == ((com.epl.geometry.Envelope)envelopeWGS84MP.GetGeometry()).GetYMin());
                NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.GetID() == envelopeWGS84MP.GetSpatialReference().GetID());
                if (!CheckResultSpatialRef(envelopeWGS84MP, 4326, 0))
                {
                    bAnswer = false;
                }
            }
            {
                // export
                com.epl.geometry.Envelope e = new com.epl.geometry.Envelope();
                e.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
                e.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
                string s = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWebMerc1, e);
                NUnit.Framework.Assert.IsTrue(s.Equals("{\"xmin\":null,\"ymin\":null,\"xmax\":null,\"ymax\":null,\"zmin\":null,\"zmax\":null,\"mmin\":null,\"mmax\":null,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}"));
                e.SetCoords(0, 1, 2, 3);
                com.epl.geometry.Envelope1D z = new com.epl.geometry.Envelope1D();
                com.epl.geometry.Envelope1D m = new com.epl.geometry.Envelope1D();
                z.SetCoords(5, 7);
                m.SetCoords(11, 13);
                e.SetInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0, z);
                e.SetInterval(com.epl.geometry.VertexDescription.Semantics.M, 0, m);
                s = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWebMerc1, e);
                NUnit.Framework.Assert.IsTrue(s.Equals("{\"xmin\":0,\"ymin\":1,\"xmax\":2,\"ymax\":3,\"zmin\":5,\"zmax\":7,\"mmin\":11,\"mmax\":13,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}"));
            }
            {
                // import
                string s = "{\"xmin\":0.0,\"ymin\":1.0,\"xmax\":2.0,\"ymax\":3.0,\"zmin\":5.0,\"zmax\":7.0,\"mmin\":11.0,\"mmax\":13.0,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}";
                com.fasterxml.jackson.core.JsonParser parser  = factory.CreateParser(s);
                com.epl.geometry.MapGeometry          map_env = com.epl.geometry.GeometryEngine.JsonToGeometry(parser);
                com.epl.geometry.Envelope             env     = (com.epl.geometry.Envelope)map_env.GetGeometry();
                com.epl.geometry.Envelope1D           z       = env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0);
                com.epl.geometry.Envelope1D           m       = env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0);
                NUnit.Framework.Assert.IsTrue(z.vmin == 5.0);
                NUnit.Framework.Assert.IsTrue(z.vmax == 7.0);
                NUnit.Framework.Assert.IsTrue(m.vmin == 11.0);
                NUnit.Framework.Assert.IsTrue(m.vmax == 13.0);
            }
            {
                string s = "{ \"zmin\" : 33, \"xmin\" : -109.55, \"zmax\" : 53, \"ymin\" : 25.76, \"xmax\" : -86.39, \"ymax\" : 49.94, \"mmax\" : 13}";
                com.fasterxml.jackson.core.JsonParser parser  = factory.CreateParser(s);
                com.epl.geometry.MapGeometry          map_env = com.epl.geometry.GeometryEngine.JsonToGeometry(parser);
                com.epl.geometry.Envelope             env     = (com.epl.geometry.Envelope)map_env.GetGeometry();
                com.epl.geometry.Envelope2D           e       = new com.epl.geometry.Envelope2D();
                env.QueryEnvelope2D(e);
                NUnit.Framework.Assert.IsTrue(e.xmin == -109.55 && e.ymin == 25.76 && e.xmax == -86.39 && e.ymax == 49.94);
                com.epl.geometry.Envelope1D e1D;
                NUnit.Framework.Assert.IsTrue(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z));
                e1D = env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0);
                NUnit.Framework.Assert.IsTrue(e1D.vmin == 33 && e1D.vmax == 53);
                NUnit.Framework.Assert.IsTrue(!env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
            }
            return(bAnswer);
        }