/// <summary>
        /// Gets the spatial aggregate string.
        /// </summary>
        /// <param name="geometry">The geometry.</param>
        /// <param name="aggregate">The aggregate.</param>
        /// <returns></returns>
        public SqlString GetSpatialAggregateString(object geometry, SpatialAggregate aggregate)
        {
            string aggregateFunction;

            switch (aggregate)
            {
            case SpatialAggregate.Collect:
                aggregateFunction = DialectPrefix + "Collect";
                break;

            case SpatialAggregate.Envelope:
                aggregateFunction = DialectPrefix + "EnvelopeAggregate";
                break;

            case SpatialAggregate.Intersection:
                aggregateFunction = DialectPrefix + "IntersectionAggregate";
                break;

            case SpatialAggregate.Union:
                aggregateFunction = DialectPrefix + "UnionAggregate";
                break;

            default:
                throw new ArgumentException("Invalid spatial aggregate argument");
            }
            return(new SqlStringBuilder()
                   .Add(aggregateFunction)
                   .Add("(")
                   .AddObject(geometry)
                   .Add(")")
                   .ToSqlString());
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the spatial aggregate string.
        /// </summary>
        /// <param name="geometry">The geometry.</param>
        /// <param name="aggregate">The aggregate.</param>
        /// <returns></returns>
        public virtual SqlString GetSpatialAggregateString(object geometry, SpatialAggregate aggregate)
        {
            // PostGIS aggregate functions do not need prefix
            string aggregateFunction;

            switch (aggregate)
            {
            case SpatialAggregate.Collect:
                aggregateFunction = "Collect";
                break;

            case SpatialAggregate.Envelope:
                aggregateFunction = "Extent";
                break;

            case SpatialAggregate.Intersection:
                aggregateFunction = IntersectionAggregateName;
                break;

            case SpatialAggregate.Union:
                aggregateFunction = SpatialDialect.IsoPrefix + "Union";
                break;

            default:
                throw new ArgumentException("Invalid spatial aggregate argument");
            }
            return(new SqlStringBuilder()
                   .Add(aggregateFunction)
                   .Add("(")
                   .AddObject(geometry)
                   .Add(")")
                   .ToSqlString());
        }
        /// <summary>
        /// Gets the spatial aggregate string.
        /// </summary>
        /// <param name="geometry">The geometry.</param>
        /// <param name="aggregate">The aggregate.</param>
        /// <returns></returns>
        public virtual SqlString GetSpatialAggregateString(object geometry, SpatialAggregate aggregate)
        {
            string aggregateFunction;

            switch (aggregate)
            {
            case SpatialAggregate.Collect:
                aggregateFunction = "CollectionAggregate";
                break;

            case SpatialAggregate.Envelope:
                aggregateFunction = "EnvelopeAggregate";
                break;

            case SpatialAggregate.ConvexHull:
                aggregateFunction = "ConvexHullAggregate";
                break;

            case SpatialAggregate.Union:
                aggregateFunction = "UnionAggregate";
                break;

            default:
                throw new ArgumentException("Invalid spatial aggregate argument");
            }

            aggregateFunction = sqlTypeName + "::" + aggregateFunction;
            return(new SqlStringBuilder()
                   .Add(aggregateFunction)
                   .Add("(")
                   .AddObject(geometry)
                   .Add(")")
                   .ToSqlString());
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the spatial aggregate string.
        /// </summary>
        /// <param name="geometry">The geometry.</param>
        /// <param name="aggregate">The aggregate.</param>
        /// <returns></returns>
        public SqlString GetSpatialAggregateString(object geometry, SpatialAggregate aggregate)
        {
            string aggregateFunction;

            switch (aggregate)
            {
            case SpatialAggregate.Collect:
                throw new System.NotImplementedException("Collect");

            case SpatialAggregate.Envelope:
                aggregateFunction = "SDO_AGGR_MBR";
                break;

            case SpatialAggregate.Intersection:
                throw new System.NotImplementedException("Intersection");

            case SpatialAggregate.Union:
                throw new System.NotImplementedException("Union");

            default:
                throw new ArgumentException("Invalid spatial aggregate argument");
            }
            return(new SqlStringBuilder()
                   .Add(aggregateFunction)
                   .Add("(")
                   .AddObject(geometry)
                   .Add(")")
                   .ToSqlString());
        }
 /// <summary>
 /// Gets the spatial aggregate string.
 /// </summary>
 /// <param name="geometry">The geometry.</param>
 /// <param name="aggregate">The aggregate.</param>
 /// <returns></returns>
 public override SqlString GetSpatialAggregateString(object geometry, SpatialAggregate aggregate)
 {
     string aggregateFunction;
     switch (aggregate)
     {
         case SpatialAggregate.Collect:
             aggregateFunction = SpatialDialect.IsoPrefix + "Collect";
             break;
         case SpatialAggregate.ConvexHull:
             aggregateFunction = SpatialDialect.IsoPrefix + "ConvexHull";
             break;
         case SpatialAggregate.Envelope:
             aggregateFunction = SpatialDialect.IsoPrefix + "Extent";
             break;
         case SpatialAggregate.Intersection:
             aggregateFunction = IntersectionAggregateName;
             break;
         case SpatialAggregate.Union:
             aggregateFunction = SpatialDialect.IsoPrefix + "Union";
             break;
         default:
             throw new ArgumentException("Invalid spatial aggregate argument");
     }
     return new SqlStringBuilder()
         .Add(aggregateFunction)
         .Add("(")
         .AddObject(geometry)
         .Add(")")
         .ToSqlString();
 }
		/// <summary>
		/// Gets the spatial aggregate string.
		/// </summary>
		/// <param name="geometry">The geometry.</param>
		/// <param name="aggregate">The aggregate.</param>
		/// <returns></returns>
		public override SqlString GetSpatialAggregateString(object geometry, SpatialAggregate aggregate)
		{
			string aggregateFunction;
			switch (aggregate)
			{
				case SpatialAggregate.Collect:
					aggregateFunction = "CollectionAggregate";
					break;

				case SpatialAggregate.Envelope:
					aggregateFunction = "EnvelopeAggregate";
					break;

				case SpatialAggregate.ConvexHull:
					aggregateFunction = "ConvexHullAggregate";
					break;

				case SpatialAggregate.Union:
					aggregateFunction = "UnionAggregate";
					break;

				default:
					throw new ArgumentException("Invalid spatial aggregate argument");
			}

			aggregateFunction = sqlTypeName + "::" + aggregateFunction;
			return new SqlStringBuilder()
				.Add(aggregateFunction)
				.Add("(")
				.AddObject(geometry)
				.Add(")")
				.ToSqlString();
		}
        /// <summary>
        /// Gets the spatial aggregate string.
        /// </summary>
        /// <param name="geometry">The geometry.</param>
        /// <param name="aggregate">The aggregate.</param>
        /// <returns></returns>
        public override SqlString GetSpatialAggregateString(object geometry, SpatialAggregate aggregate)
        {
            string aggregateFunction;

            switch (aggregate)
            {
            // MySQL doesn't support spatial aggregate functions directly, therefore
            // we replicate it by grouping the geometry from each row into a geometry
            // collection and then performing the function on the geometry collection
            // See: https://forums.mysql.com/read.php?23,249284,249284#msg-249284
            case SpatialAggregate.Collect:
                return(new SqlStringBuilder()
                       .Add(DialectPrefix)
                       .Add("GeometryCollectionFromText(CONCAT(\"GEOMETRYCOLLECTION(\", GROUP_CONCAT(")
                       .Add(DialectPrefix)
                       .Add("AsText(")
                       .AddObject(geometry)
                       .Add(")), \")\"))")
                       .ToSqlString());

            case SpatialAggregate.ConvexHull:
            case SpatialAggregate.Envelope:
                aggregateFunction = aggregate.ToString();
                break;

            case SpatialAggregate.Intersection:
            case SpatialAggregate.Union:
                throw new NotSupportedException($"MySQL does not support {aggregate} spatial aggregate function");

            default:
                throw new ArgumentException("Invalid spatial aggregate argument");
            }

            SqlString collectAggregate = GetSpatialAggregateString(geometry, SpatialAggregate.Collect);

            return(new SqlStringBuilder()
                   .Add(DialectPrefix)
                   .Add(aggregateFunction)
                   .Add("(")
                   .Add(collectAggregate)
                   .Add(")")
                   .ToSqlString());
        }
Esempio n. 8
0
        /// <summary>
        /// Gets the spatial aggregate string.
        /// </summary>
        /// <param name="geometry">The geometry.</param>
        /// <param name="aggregate">The aggregate.</param>
        /// <returns></returns>
        public override SqlString GetSpatialAggregateString(object geometry, SpatialAggregate aggregate)
        {
            string aggregateFunction;

            switch (aggregate)
            {
            case SpatialAggregate.Collect:
                aggregateFunction = SpatialDialect.IsoPrefix + "Collect";
                break;

            case SpatialAggregate.ConvexHull:
                aggregateFunction = SpatialDialect.IsoPrefix + "ConvexHull";
                break;

            case SpatialAggregate.Envelope:
                aggregateFunction = SpatialDialect.IsoPrefix + "Extent";
                break;

            case SpatialAggregate.Intersection:
                aggregateFunction = IntersectionAggregateName;
                break;

            case SpatialAggregate.Union:
                aggregateFunction = SpatialDialect.IsoPrefix + "Union";
                break;

            default:
                throw new ArgumentException("Invalid spatial aggregate argument");
            }
            var builder = new SqlStringBuilder();

            builder.Add(aggregateFunction)
            .Add("(")
            .AddObject(geometry)
            .Add(")");
            // Convert to geometry as there is no binary output function available for type box2d type
            if (aggregate == SpatialAggregate.Envelope)
            {
                builder.Add("::geometry");
            }
            return(builder.ToSqlString());
        }
		public SqlString GetSpatialAggregateString(object geometry, SpatialAggregate aggregate)
		{
			return worker.GetSpatialAggregateString(geometry, aggregate);
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialAggregateProjection"/> class.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="aggregate">The aggregate.</param>
 public SpatialAggregateProjection(string propertyName, SpatialAggregate aggregate)
     : base(propertyName)
 {
     this.aggregate = aggregate;
 }
Esempio n. 11
0
		/// <summary>
		/// Gets the spatial aggregate string.
		/// </summary>
		/// <param name="geometry">The geometry.</param>
		/// <param name="aggregate">The aggregate.</param>
		/// <returns></returns>
		public SqlString GetSpatialAggregateString(object geometry, SpatialAggregate aggregate)
		{
			// PostGIS aggregate functions do not need prefix
			string aggregateFunction;
			switch (aggregate)
			{
				case SpatialAggregate.Collect:
					aggregateFunction = "Collect";
					break;
				case SpatialAggregate.Envelope:
					aggregateFunction = "Extent";
					break;
				case SpatialAggregate.Intersection:
					aggregateFunction = IntersectionAggregateName;
					break;
				case SpatialAggregate.Union:
					aggregateFunction = "GeomUnion";
					break;
				default:
					throw new ArgumentException("Invalid spatial aggregate argument");
			}
			return new SqlStringBuilder()
				.Add(aggregateFunction)
				.Add("(")
				.AddObject(geometry)
				.Add(")")
				.ToSqlString();
		}
Esempio n. 12
0
 /// <summary>
 /// Gets the spatial aggregate string.
 /// </summary>
 /// <param name="geometry">The geometry.</param>
 /// <param name="aggregate">The aggregate.</param>
 /// <returns></returns>
 public SqlString GetSpatialAggregateString(object geometry, SpatialAggregate aggregate)
 {
     throw new NotImplementedException();
 }
Esempio n. 13
0
 public SqlString GetSpatialAggregateString(object geometry, SpatialAggregate aggregate)
 {
     return(worker.GetSpatialAggregateString(geometry, aggregate));
 }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialAggregateProjection"/> class.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="aggregate">The aggregate.</param>
 public SpatialAggregateProjection(string propertyName, SpatialAggregate aggregate)
     : base(propertyName)
 {
     this.aggregate = aggregate;
 }
Esempio n. 15
0
 /// <summary>
 /// Gets the spatial aggregate string.
 /// </summary>
 /// <param name="geometry">The geometry.</param>
 /// <param name="aggregate">The aggregate.</param>
 /// <returns></returns>
 public SqlString GetSpatialAggregateString(object geometry, SpatialAggregate aggregate)
 {
     throw new NotImplementedException();
 }
Esempio n. 16
0
 /// <summary>
 /// Gets the spatial aggregate string.
 /// </summary>
 /// <param name="geometry">The geometry.</param>
 /// <param name="aggregate">The aggregate.</param>
 /// <returns></returns>
 public virtual SqlString GetSpatialAggregateString(object geometry, SpatialAggregate aggregate)
 {
     throw new NotSupportedException("Spatial aggregate functions are not supported in MsSql2008");
 }