/// <summary>
        /// Gets the spatial analysis string.
        /// </summary>
        /// <param name="geometry">The geometry.</param>
        /// <param name="analysis">The analysis.</param>
        /// <param name="extraArgument">The extra argument.</param>
        /// <returns></returns>
        public virtual SqlString GetSpatialAnalysisString(object geometry, SpatialAnalysis analysis, object extraArgument)
        {
            switch (analysis)
            {
            case SpatialAnalysis.ConvexHull:
                return(new SqlStringBuilder()
                       .AddObject(geometry)
                       .Add(".STConvexHull()")
                       .ToSqlString());

            case SpatialAnalysis.Distance:
            case SpatialAnalysis.Buffer:
            case SpatialAnalysis.Difference:
            case SpatialAnalysis.Intersection:
            case SpatialAnalysis.SymDifference:
            case SpatialAnalysis.Union:
                if (analysis == SpatialAnalysis.Buffer && !(extraArgument is Parameter || new SqlString(Parameter.Placeholder).Equals(extraArgument)))
                {
                    extraArgument = Convert.ToString(extraArgument, NumberFormatInfo.InvariantInfo);
                }
                return(new SqlStringBuilder()
                       .AddObject(geometry)
                       .Add(".ST")
                       .Add(analysis.ToString())
                       .Add("(")
                       .AddObject(extraArgument)
                       .Add(")")
                       .ToSqlString());

            default:
                throw new ArgumentException("Invalid spatial analysis argument");
            }
        }
예제 #2
0
        private void btn_Buffer_Click(object sender, EventArgs e)
        {
            FrmBuffer frm = new FrmBuffer();

            frm.m_axMapControl = axMapControl1;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                SpatialAnalysis sa = new SpatialAnalysis();
                sa.BufferOfFeatures(axMapControl1, (IFeatureLayer)frm.m_pLayer, frm.m_dRadius);
            }
        }
        /// <summary>
        /// Gets the spatial analysis string.
        /// </summary>
        /// <param name="geometry">The geometry.</param>
        /// <param name="analysis">The analysis.</param>
        /// <param name="extraArgument">The extra argument.</param>
        /// <returns></returns>
        public SqlString GetSpatialAnalysisString(object geometry, SpatialAnalysis analysis, object extraArgument)
        {
            switch (analysis)
            {
            case SpatialAnalysis.Buffer:
                if (!(extraArgument is Parameter || SqlString.Parameter.Equals(extraArgument)))
                {
                    extraArgument = Convert.ToString(extraArgument, System.Globalization.NumberFormatInfo.InvariantInfo);
                }
                return(new SqlStringBuilder()
                       .Add(DialectPrefix)
                       .Add("Buffer(")
                       .AddObject(geometry)
                       .Add(", ")
                       .AddObject(extraArgument)
                       .Add(")")
                       .ToSqlString());

            case SpatialAnalysis.ConvexHull:
                return(new SqlStringBuilder()
                       .Add(DialectPrefix)
                       .Add("ConvexHull(")
                       .AddObject(geometry)
                       .Add(")")
                       .ToSqlString());

            case SpatialAnalysis.Difference:
            case SpatialAnalysis.Distance:
            case SpatialAnalysis.Intersection:
            case SpatialAnalysis.SymDifference:
                return(new SqlStringBuilder()
                       .Add(DialectPrefix)
                       .Add(analysis.ToString())
                       .Add("(")
                       .AddObject(geometry)
                       .Add(",")
                       .AddObject(extraArgument)
                       .Add(")")
                       .ToSqlString());

            case SpatialAnalysis.Union:
                return(new SqlStringBuilder()
                       .Add(DialectPrefix)
                       .Add("GeomUnion(")
                       .AddObject(geometry)
                       .Add(",")
                       .AddObject(extraArgument)
                       .Add(")")
                       .ToSqlString());

            default:
                throw new ArgumentException("Invalid spatial analysis argument");
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SpatialAnalysisFunction"/> class.
        /// </summary>
        /// <param name="spatialDialect">The spatial dialect.</param>
        /// <param name="analysis">The analysis.</param>
        public SpatialAnalysisFunction(ISpatialDialect spatialDialect, SpatialAnalysis analysis)
            : base(analysis.ToString(),
			  (analysis == SpatialAnalysis.Distance ?
					NHibernateUtil.Double :
					spatialDialect.GeometryType))
        {
            this.spatialDialect = spatialDialect;
            this.analysis = analysis;
            if (this.analysis == SpatialAnalysis.ConvexHull)
            {
                this.allowedArgsCount = 1;
            }
            else
            {
                this.allowedArgsCount = 2;
            }
        }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialAnalysisFunction"/> class.
 /// </summary>
 /// <param name="spatialDialect">The spatial dialect.</param>
 /// <param name="analysis">The analysis.</param>
 public SpatialAnalysisFunction(ISpatialDialect spatialDialect, SpatialAnalysis analysis)
     : base(analysis.ToString(),
            (analysis == SpatialAnalysis.Distance ?
             NHibernateUtil.Double :
             spatialDialect.GeometryType)
            )
 {
     this.spatialDialect = spatialDialect;
     this.analysis       = analysis;
     if (this.analysis == SpatialAnalysis.ConvexHull)
     {
         this.allowedArgsCount = 1;
     }
     else
     {
         this.allowedArgsCount = 2;
     }
 }
 public void RegisterSpatialFunction(SpatialAnalysis analysis)
 {
     adaptor.RegisterFunction(SpatialDialect.HqlPrefix + analysis.ToString(), new SpatialAnalysisFunction(this, analysis));
 }
        /// <summary>
        /// Gets the spatial analysis string.
        /// </summary>
        /// <param name="geometry">The geometry.</param>
        /// <param name="analysis">The analysis.</param>
        /// <param name="extraArgument">The extra argument.</param>
        /// <returns></returns>
        public SqlString GetSpatialAnalysisString(object geometry, SpatialAnalysis analysis, object extraArgument)
        {
            switch (analysis)
            {
                case SpatialAnalysis.ConvexHull:
                    return new SqlStringBuilder()
                        .AddObject(geometry)
                        .Add(".STConvexHull()")
                        .ToSqlString();

                case SpatialAnalysis.Buffer:
                case SpatialAnalysis.Difference:
                case SpatialAnalysis.Distance:
                case SpatialAnalysis.Intersection:
                case SpatialAnalysis.SymDifference:
                case SpatialAnalysis.Union:
                    if (analysis == SpatialAnalysis.Buffer &&
                        !(extraArgument is Parameter || new SqlString(Parameter.Placeholder).Equals(extraArgument)))
                    {
                        extraArgument = Convert.ToString(extraArgument, NumberFormatInfo.InvariantInfo);
                    }
                    return new SqlStringBuilder()
                        .AddObject(geometry)
                        .Add(".ST")
                        .Add(analysis.ToString())
                        .Add("(")
                        .AddObject(extraArgument)
                        .Add(")")
                        .ToSqlString();

                default:
                    throw new ArgumentException("Invalid spatial analysis argument");
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialAnalysisProjection"/> class.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="analysis">The analysis.</param>
 /// <param name="arguments">The arguments.</param>
 public SpatialAnalysisProjection(string propertyName, SpatialAnalysis analysis, params object[] arguments)
     : base(propertyName)
 {
     this.analysis = analysis;
     this.arguments = arguments;
 }
		protected void RegisterSpatialFunction(SpatialAnalysis analysis)
		{
			RegisterFunction(SpatialDialect.HqlPrefix + analysis, new SpatialAnalysisFunction(this, analysis));
		}
 /// <summary>
 /// Gets the spatial analysis string.
 /// </summary>
 /// <param name="geometry">The geometry.</param>
 /// <param name="analysis">The analysis.</param>
 /// <param name="extraArgument">The extra argument.</param>
 /// <returns></returns>
 public SqlString GetSpatialAnalysisString(object geometry, SpatialAnalysis analysis, object extraArgument)
 {
     switch (analysis)
     {
         case SpatialAnalysis.Buffer:
             if (!(extraArgument is Parameter || SqlString.Parameter.Equals(extraArgument)))
             {
                 extraArgument = Convert.ToString(extraArgument, System.Globalization.NumberFormatInfo.InvariantInfo);
             }
             return new SqlStringBuilder()
                 .Add(DialectPrefix)
                 .Add("Buffer(")
                 .AddObject(geometry)
                 .Add(", ")
                 .AddObject(extraArgument)
                 .Add(")")
                 .ToSqlString();
         case SpatialAnalysis.ConvexHull:
             return new SqlStringBuilder()
                 .Add(DialectPrefix)
                 .Add("ConvexHull(")
                 .AddObject(geometry)
                 .Add(")")
                 .ToSqlString();
         case SpatialAnalysis.Difference:
         case SpatialAnalysis.Distance:
         case SpatialAnalysis.Intersection:
         case SpatialAnalysis.SymDifference:
             return new SqlStringBuilder()
                 .Add(DialectPrefix)
                 .Add(analysis.ToString())
                 .Add("(")
                 .AddObject(geometry)
                 .Add(",")
                 .AddObject(extraArgument)
                 .Add(")")
                 .ToSqlString();
         case SpatialAnalysis.Union:
             return new SqlStringBuilder()
                 .Add(DialectPrefix)
                 .Add("GeomUnion(")
                 .AddObject(geometry)
                 .Add(",")
                 .AddObject(extraArgument)
                 .Add(")")
                 .ToSqlString();
         default:
             throw new ArgumentException("Invalid spatial analysis argument");
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialAnalysisProjection"/> class.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="analysis">The analysis.</param>
 /// <param name="anotherPropertyName">Name of another property.</param>
 public SpatialAnalysisProjection(string propertyName, SpatialAnalysis analysis, string anotherPropertyName)
     : base(propertyName)
 {
     this.analysis            = analysis;
     this.anotherPropertyName = anotherPropertyName;
 }
예제 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialAnalysisProjection"/> class.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="analysis">The analysis.</param>
 /// <param name="geometry">The arguments.</param>
 public SpatialAnalysisProjection(string propertyName, SpatialAnalysis analysis, IGeometry geometry)
     : base(propertyName)
 {
     this.analysis = analysis;
     this.geometry = geometry;
 }
예제 #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SpatialAnalysisProjection"/> class.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="analysis">The analysis.</param>
        /// <param name="arguments">The arguments.</param>
        //public SpatialAnalysisProjection(string propertyName, SpatialAnalysis analysis, params object[] arguments)
        //    : base(propertyName)
        //{
        //    this.analysis = analysis;
        //    this.arguments = arguments;
        //}

        /// <summary>
        /// Initializes a new instance of the <see cref="SpatialAnalysisProjection"/> class.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="analysis">The analysis.</param>
        public SpatialAnalysisProjection(string propertyName, SpatialAnalysis analysis)
            : base(propertyName)
        {
            this.analysis = analysis;
        }
 protected void RegisterSpatialFunction(SpatialAnalysis analysis)
 {
     RegisterFunction(SpatialDialect.HqlPrefix + analysis, new SpatialAnalysisFunction(this, analysis));
 }
예제 #15
0
 private void RegisterSpatialFunction(SpatialAnalysis analysis)
 {
     adaptor.RegisterFunction(SpatialDialect.HqlPrefix + analysis, new SpatialAnalysisFunction(this, analysis));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialAnalysisProjection"/> class.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="analysis">The analysis.</param>
 /// <param name="geometry">The arguments.</param>
 public SpatialAnalysisProjection(string propertyName, SpatialAnalysis analysis, IGeometry geometry)
     : base(propertyName)
 {
     this.analysis = analysis;
     this.geometry = geometry;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialAnalysisProjection"/> class.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="analysis">The analysis.</param>
 /// <param name="value"></param>
 public SpatialAnalysisProjection(string propertyName, SpatialAnalysis analysis, double value)
     : base(propertyName)
 {
     this.analysis = analysis;
     this.value = value;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SpatialAnalysisProjection"/> class.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="analysis">The analysis.</param>
        /// <param name="arguments">The arguments.</param>
        //public SpatialAnalysisProjection(string propertyName, SpatialAnalysis analysis, params object[] arguments)
        //    : base(propertyName)
        //{
        //    this.analysis = analysis;
        //    this.arguments = arguments;
        //}

        /// <summary>
        /// Initializes a new instance of the <see cref="SpatialAnalysisProjection"/> class.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="analysis">The analysis.</param>
        public SpatialAnalysisProjection(string propertyName, SpatialAnalysis analysis)
            : base(propertyName)
        {
            this.analysis = analysis;
        }
예제 #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialAnalysisProjection"/> class.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="analysis">The analysis.</param>
 /// <param name="value"></param>
 public SpatialAnalysisProjection(string propertyName, SpatialAnalysis analysis, double value)
     : base(propertyName)
 {
     this.analysis = analysis;
     this.value    = value;
 }
예제 #20
0
        /// <summary>
        /// Gets the spatial analysis string.
        /// </summary>
        /// <param name="geometry">The geometry.</param>
        /// <param name="analysis">The analysis.</param>
        /// <param name="extraArgument">The extra argument.</param>
        /// <returns></returns>
        public SqlString GetSpatialAnalysisString(object geometry, SpatialAnalysis analysis, object extraArgument)
        {
            bool[]           geomArgs;
            SqlStringBuilder sql = new SqlStringBuilder();

            sql.Add("MDSYS.");
            bool isGeomReturn = true;

            switch (analysis)
            {
            case SpatialAnalysis.Buffer:
                sql.Add("OGC_BUFFER");
                geomArgs = new bool[] { true, false };
                break;

            case SpatialAnalysis.ConvexHull:
                sql.Add("OGC_CONVEXHULL");
                geomArgs = new bool[] { true };
                break;

            case SpatialAnalysis.Difference:
                sql.Add("OGC_DIFFERENCE");
                geomArgs = new bool[] { true, true };
                break;

            case SpatialAnalysis.Distance:
                sql.Add("OGC_DISTANCE");
                geomArgs     = new bool[] { true, true };
                isGeomReturn = false;
                break;

            case SpatialAnalysis.Intersection:
                sql.Add("OGC_INTERSECTION");
                geomArgs = new bool[] { true, true };
                break;

            case SpatialAnalysis.SymDifference:
                sql.Add("OGC_SYMMETRICDIFFERENCE");
                geomArgs = new bool[] { true, true };
                break;

            case SpatialAnalysis.Union:
                sql.Add("OGC_UNION");
                geomArgs = new bool[] { true, true };
                break;

            default:
                throw new ArgumentException(
                          "Unknown SpatialAnalysisFunction ("
                          + Enum.GetName(typeof(SpatialAnalysis), analysis) + ").");
            }



            sql.Add("(");
            if (geomArgs.Length > 0)
            {
                WrapInSTGeometry(geometry, sql);
            }
            if (geomArgs.Length > 1)
            {
                sql.Add(",");
                if (geomArgs[1])
                {
                    WrapInSTGeometry(extraArgument, sql);
                }
                else
                {
                    sql.AddObject(extraArgument);
                }
            }

            sql.Add(")");
            if (isGeomReturn)
            {
                sql.Add(".geom");
            }
            return(sql.ToSqlString());
        }
예제 #21
0
 private void RegisterSpatialFunction(SpatialAnalysis analysis)
 {
     RegisterFunction(SpatialDialect.HqlPrefix + analysis.ToString(), new SpatialAnalysisFunction(this, analysis));
 }
 public void RegisterSpatialFunction(SpatialAnalysis analysis)
 {
     adaptor.RegisterFunction(SpatialDialect.HqlPrefix + analysis.ToString(), new SpatialAnalysisFunction(this, analysis));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialAnalysisProjection"/> class.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="analysis">The analysis.</param>
 /// <param name="arguments">The arguments.</param>
 public SpatialAnalysisProjection(string propertyName, SpatialAnalysis analysis, params object[] arguments)
     : base(propertyName)
 {
     this.analysis  = analysis;
     this.arguments = arguments;
 }
예제 #24
0
 public SqlString GetSpatialAnalysisString(object geometry, SpatialAnalysis analysis, object extraArgument)
 {
     return(worker.GetSpatialAnalysisString(geometry, analysis, extraArgument));
 }
		public SqlString GetSpatialAnalysisString(object geometry, SpatialAnalysis analysis, object extraArgument)
		{
			return worker.GetSpatialAnalysisString(geometry, analysis, extraArgument);
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialAnalysisProjection"/> class.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="analysis">The analysis.</param>
 /// <param name="anotherPropertyName">Name of another property.</param>
 public SpatialAnalysisProjection(string propertyName, SpatialAnalysis analysis, string anotherPropertyName)
     : base(propertyName)
 {
     this.analysis = analysis;
     this.anotherPropertyName = anotherPropertyName;
 }
 private void RegisterSpatialFunction(SpatialAnalysis analysis)
 {
     RegisterFunction(SpatialDialect.HqlPrefix + analysis.ToString(), new SpatialAnalysisFunction(this, analysis));
 }
        /// <summary>
        /// Gets the spatial analysis string.
        /// </summary>
        /// <param name="geometry">The geometry.</param>
        /// <param name="analysis">The analysis.</param>
        /// <param name="extraArgument">The extra argument.</param>
        /// <returns></returns>
        public SqlString GetSpatialAnalysisString(object geometry, SpatialAnalysis analysis, object extraArgument)
        {
            bool[] geomArgs;
            SqlStringBuilder sql = new SqlStringBuilder();
            sql.Add("MDSYS.");
            bool isGeomReturn = true;
            switch (analysis)
            {
                case SpatialAnalysis.Buffer:
                    sql.Add("OGC_BUFFER");
                    geomArgs = new bool[] { true, false };
                    break;
                case SpatialAnalysis.ConvexHull:
                    sql.Add("OGC_CONVEXHULL");
                    geomArgs = new bool[] { true};
                    break;
                case SpatialAnalysis.Difference:
                    sql.Add("OGC_DIFFERENCE");
                    geomArgs = new bool[] { true, true };
                    break;
                case SpatialAnalysis.Distance:
                    sql.Add("OGC_DISTANCE");
                    geomArgs = new bool[] { true, true };
                    isGeomReturn = false;
                    break;
                case SpatialAnalysis.Intersection:
                    sql.Add("OGC_INTERSECTION");
                    geomArgs = new bool[] { true, true };
                    break;
                case SpatialAnalysis.SymDifference:
                    sql.Add("OGC_SYMMETRICDIFFERENCE");
                    geomArgs = new bool[] { true, true };
                    break;
                case SpatialAnalysis.Union:
                    sql.Add("OGC_UNION");
                    geomArgs = new bool[] { true, true };
                    break;
                default:
                    throw new ArgumentException(
                            "Unknown SpatialAnalysisFunction ("
                                    + Enum.GetName(typeof(SpatialAnalysis), analysis) + ").");
            }



            sql.Add("(");
            if (geomArgs.Length > 0)
            {
                
                WrapInSTGeometry(geometry, sql);
            }
            if (geomArgs.Length > 1)
            {
                sql.Add(",");
                if (geomArgs[1])
                    WrapInSTGeometry(extraArgument, sql);
                else
                    sql.AddObject(extraArgument);
            }

            sql.Add(")");
            if (isGeomReturn)
                sql.Add(".geom");
            return sql.ToSqlString();
        }