Exemple #1
0
        public static Field FromWkt(IRequest context, Field source)
        {
            var input  = (SqlString)source.Value;
            var result = FromWkt(input);

            return(new Field(SpatialType.Geometry(), result));
        }
Exemple #2
0
        public static Field Boundary(Field geometry)
        {
            var input  = (SqlGeometry)geometry.Value;
            var result = input.Boundary;

            return(new Field(SpatialType.Geometry(), result));
        }
Exemple #3
0
        public static Field FromWkb(Field source)
        {
            var input  = (SqlBinary)source.Value;
            var result = FromWkb(input);

            return(new Field(SpatialType.Geometry(), result));
        }
Exemple #4
0
        public static Field Envelope(Field geometry)
        {
            var input    = (SqlGeometry)geometry.Value;
            var envelope = Envelope(input);

            return(new Field(SpatialType.Geometry(), envelope));
        }
Exemple #5
0
        public static DataObject FromWkt(IRequest context, DataObject source)
        {
            var input  = (SqlString)source.Value;
            var result = FromWkt(input);

            return(new DataObject(SpatialType.Geometry(), result));
        }
Exemple #6
0
        public static DataObject FromWkb(DataObject source)
        {
            var input  = (SqlBinary)source.Value;
            var result = FromWkb(input);

            return(new DataObject(SpatialType.Geometry(), result));
        }
Exemple #7
0
        public static DataObject Boundary(DataObject geometry)
        {
            var input  = (SqlGeometry)geometry.Value;
            var result = input.Boundary;

            return(new DataObject(SpatialType.Geometry(), result));
        }
Exemple #8
0
        public static DataObject Envelope(DataObject geometry)
        {
            var input    = (SqlGeometry)geometry.Value;
            var envelope = Envelope(input);

            return(new DataObject(SpatialType.Geometry(), envelope));
        }
Exemple #9
0
        protected override void OnInit()
        {
            Register(config => config.Named("from_wkb")
                     .WithParameter(p => p.Named("source").OfType(PrimitiveTypes.Binary()))
                     .WhenExecute(context => Simple(context, args => SpatialSystemFunctions.FromWkb(args[0])))
                     .ReturnsType(SpatialType.Geometry()));

            Register(config => config.Named("from_wkt")
                     .WithParameter(p => p.Named("source").OfType(PrimitiveTypes.String()))
                     .WhenExecute(context => Simple(context, args => SpatialSystemFunctions.FromWkt(context.Request, args[0])))
                     .ReturnsType(SpatialType.Geometry()));

            Register(config => config.Named("to_wkt")
                     .WithParameter(p => p.Named("g").OfType(SpatialType.Geometry()))
                     .WhenExecute(context => Simple(context, args => SpatialSystemFunctions.ToWkt(args[0])))
                     .ReturnsString());

            Register(config => config.Named("to_wkb")
                     .WithParameter(p => p.Named("g").OfType(SpatialType.Geometry()))
                     .WhenExecute(context => Simple(context, args => SpatialSystemFunctions.ToWkb(args[0])))
                     .ReturnsBinary());

            Register(config => config.Named("envelope")
                     .WithParameter(p => p.Named("g").OfType(SpatialType.Geometry()))
                     .WhenExecute(context => Simple(context, args => SpatialSystemFunctions.Envelope(args[0])))
                     .ReturnsType(SpatialType.Geometry()));

            Register(config => config.Named("distance")
                     .WithParameter(p => p.Named("g1").OfType(SpatialType.Geometry()))
                     .WithParameter(p => p.Named("g2").OfType(SpatialType.Geometry()))
                     .WhenExecute(context => Simple(context, args => SpatialSystemFunctions.Distance(args[0], args[1])))
                     .ReturnsNumeric());

            Register(config => config.Named("contains")
                     .WithSpatialParameter("g1")
                     .WithSpatialParameter("g2")
                     .WhenExecute(context => Simple(context, args => SpatialSystemFunctions.Contains(args[0], args[1])))
                     .ReturnsBoolean());

            Register(config => config.Named("area")
                     .WithSpatialParameter("g")
                     .WhenExecute(context => Simple(context, args => SpatialSystemFunctions.Area(args[0])))
                     .ReturnsSpatialType());

            Register(config => config.Named("boundary")
                     .WithSpatialParameter("g")
                     .WhenExecute(context => Simple(context, args => SpatialSystemFunctions.Boundary(args[0])))
                     .ReturnsSpatialType());


            // TODO: Implement the functions
        }
 public static IFunctionConfiguration ReturnsSpatialType(this IFunctionConfiguration configuration)
 {
     return(configuration.ReturnsType(SpatialType.Geometry()));
 }
 public static IFunctionConfiguration WithSpatialParameter(this IFunctionConfiguration configuration, string name)
 {
     return(configuration.WithParameter(name, SpatialType.Geometry()));
 }