Ejemplo n.º 1
0
        public override double[] Interpolate(double x, double y, double z, bool include)
        {
            List<Kpoint> cpointsF;

            this.Search.ListPointAvailables(out cpointsF, x, y,z, include);

            if (cpointsF.Count == 1)
            {
                return new double[2] { cpointsF[0].W, double.NaN };
            }

            if (cpointsF.Count == 0)
            {
                return new double[2] { double.NaN, double.NaN };
            }

            double sum = 0;
            double totalSum = 0;
            
            Kpoint pointSearch= new Kpoint(x,y,z,0);

            foreach (Kpoint point in cpointsF)
            { 
                if (pointSearch==point)
                    return new double[2]{point.W, 0};

                double dist=Utils.GetDistance(x,y,z,point);
                double value = Math.Pow(dist, this.weigth);
                sum += (1 / value) * point.W;
                totalSum += (1 / value);
            }

            return new double[2] { sum/totalSum, 0 };

        }
Ejemplo n.º 2
0
        public static IGeometry DrawEllipse(Kpoint center, double majorRadius, double minorRadius, double azimuth)
        {
            int numVertex = 180;
            Coordinate[] coorPol = new Coordinate[numVertex+1];

            if (majorRadius == minorRadius)
            {
                int j = 0;
                for (int i = 0; i < 360; i += (360/numVertex))
                {
                    Kpoint v = Utils.AzimuthDist(center, i * Math.PI / 180.0, majorRadius);
                    coorPol[j] = new Coordinate(v.X, v.Y);
                    j++;
                }


                coorPol[numVertex] = coorPol[0];
            }
            else
            {
                int j = 0;
                for (int i = 0; i < 360; i += (360 / numVertex))
                {
                    double r = majorRadius * minorRadius / Math.Sqrt(
                        Math.Pow(minorRadius * Math.Cos(-1*azimuth + (i * Math.PI / 180.0)), 2) +
                         Math.Pow(majorRadius * Math.Sin(-1*azimuth + (i * Math.PI / 180.0)), 2)
                        );

                    Kpoint v = Utils.AzimuthDist(center, i * Math.PI / 180.0, r);
                    coorPol[j] = new Coordinate(v.X, v.Y);
                    j++;

                }
                coorPol[numVertex] = coorPol[0];

            }

            LinearRing pol = new LinearRing(coorPol);
            Polygon poly = new Polygon(pol);
            return poly;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Searching the points around of a position
        /// </summary>
        /// <param name="cpointsF">Point founds</param>
        /// <param name="nPn">Number of point searched</param>
        /// <param name="x">Coordinate X of the point to calculate</param>
        /// <param name="y">Coordinate Y of the point to calculate</param>
        public void ListPointAvailables(
            out List<Kpoint> cpointsF, double x, double y, double z, bool includePoint)
        {
             Kpoint center = new Kpoint(x, y, z, 0);
            if (kpoints.Count <= type * minPointsPerSector )
            {
                if (includePoint)
                    cpointsF = kpoints;
                else
                {
                    cpointsF = new List<Kpoint>();
                    foreach (Kpoint k in kpoints)
                    { 
                        if (!(k==center))
                            cpointsF.Add( k);
                    }
                    return;
                }

            }


           

           // double searchDistance = (this.extent[2] - this.extent[0]) * 0.05;
            double[] v = zone(center);
            double xsize=v[0]/2;
            double ysize = v[1]/2;
            double zsize = v[2]/2;
            double xmin=double.NaN;
            double ymin=double.NaN;
            double zmin=double.NaN;
            double xmax=double.NaN;
            double ymax = double.NaN;
            double zmax=double.NaN;
         

            int jj = 0;
            double dmult=0.1;
            do
            {
                ListToCheck = new List<KDistance>[type];
                for (int i = 0; i < type; i++)
                {
                    ListToCheck[i] = new List<KDistance>();
                }

                mult = jj * dmult;
                this.quadTreeValues.Clean();
                xmin = x - (xsize * (1 + mult ));
                ymin = y - (xsize * (1 + mult));
                zmin = y - (zsize * (1 + mult));
                xmax = x + (ysize * (1 + mult));
                ymax = y + (ysize * (1 + mult));
                zmax = y + (zsize * (1 + mult));

                Interval intX = new Interval(xmin, xmax);
                Interval intY = new Interval(ymin, ymax);
                Interval intZ = new Interval(zmin, zmax);
                Interval2D rect = new Interval2D(intX, intY,intZ);
                this.quadTreeValues.Query(rect);
                dmult++;
                jj++;
                if (jj>1)
                     v[1]=0;
                ConfigEllipse(center);
            }
            while (Conditions(center,this.quadTreeValues.GetData(),includePoint) && (v[0]*5) > Math.Abs(xmax-xmin) );

            cpointsF = new List<Kpoint>();
            for (int i = 0; i < type; i++)
            {  int val=evaluteNumPoints(jj,ListToCheck[i].Count);
                for (int j = 0; j < ListToCheck[i].Count && j < val ; j++)
                    cpointsF.Add(ListToCheck[i][j].point);
            }
            selectedPoints = cpointsF;

        }
Ejemplo n.º 4
0
        private bool Conditions(Kpoint center,List<Kpoint> points,bool include)
        {
            List<Kpoint> def= new List<Kpoint>();
            foreach(Kpoint value in points)
               CheckSector(center,value,include);

            int num = 0;
            for( int i=0; i<type; i++)
            {
                num += ListToCheck[i].Count;
                ListToCheck[i].Sort();
            }

            if (minPointsPerSector == 0)
                return false;

            if (points.Count < minPointsPerSector * type)
                return true;




            if (num >= minPointsPerSector * type)
                return false;
            else
                return true;
              
        
        }
Ejemplo n.º 5
0
        public static List<IGeometry> DrawAxisEllipse(Kpoint center, double majorRadius, double minorRadius, double azimuth)
        {
            List<IGeometry> list = new List<IGeometry>();

            
            Coordinate[] east = new Coordinate[2];
            Coordinate[] north = new Coordinate[2];
            Coordinate centerP = new Coordinate(center.X,center.Y);


                east[0] = AzimuthDist(centerP, azimuth + Math.PI / 2, minorRadius);
                east[1] = AzimuthDist(centerP, azimuth - Math.PI / 2, minorRadius);
                north[0] = AzimuthDist(centerP, azimuth, majorRadius);
                north[1] = AzimuthDist(centerP, azimuth + Math.PI , majorRadius);


                list.Add(new LineString(east));
                list.Add(new LineString(north));
                return list;

        }
Ejemplo n.º 6
0
 /// <summary>
 /// Insert a new node in the index
 /// </summary>
 /// <param name="x">X position of the node</param>
 /// <param name="y">Y position of the node</param>
 /// <param name="value">value associated with the node</param>
 public void Insert(
     double x, double y, Kpoint value) 
 {
     this.root = this.Insert(this.root, x, y, value);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Insert a new Node return it
        /// </summary>
        /// <param name="h">Root Node index</param>
        /// <param name="x">X position of the node</param>
        /// <param name="y">Y position of the node</param>
        /// <param name="value">value associated with the node</param>
        /// <returns>Returns the node in the rigth position </returns>
        private Node Insert(
            Node h, double x, double y, Kpoint value)
        {
            if (h == null)
            {
                return new Node(x, y, value);
            }
            else if (this.Less(x, h.X) && this.Less(y, h.Y))
            {
                h.SW = this.Insert(h.SW, x, y, value);
            }
            else if (this.Less(x, h.X) && !this.Less(y, h.Y))
            {
                h.NW = this.Insert(h.NW, x, y, value);
            }
            else if (!this.Less(x, h.X) && this.Less(y, h.Y))
            {
                h.SE = this.Insert(h.SE, x, y, value);
            }
            else if (!this.Less(x, h.X) && !this.Less(y, h.Y))
            {
                h.NE = this.Insert(h.NE, x, y, value);
            }

            return h;
        }
Ejemplo n.º 8
0
        private void CheckSector(Kpoint center, Kpoint target,bool include)
        {
            if (center == target && !include)
                return;
            double majorRadio = this.majorRadio * (1 + mult);
            double minorRadio = this.minorRadio * (1 + mult);
            double dist = Utils.GetDistance(target, center);
            double distE = Utils.GetDistance(focu2, target) + Utils.GetDistance(focu1, target);
            double az = Utils.GetAzimuth(center, target);
            if (type == 1)
            {
                if (minorRadio==majorRadio && dist > majorRadio)
                    return;
                if (minorRadio != majorRadio && distE > distConst)
                    return;
  
                ListToCheck[0].Add(new KDistance(dist,az,target));
                    return;

           }else
            {
                if (minorRadio == majorRadio && dist > majorRadio)
                    return;

                if (minorRadio != majorRadio && distE > distConst)
                    return;

                int subtype = 0;
                double cycle = 2.0 * Math.PI;
                for (double i = 0; i < 2 * Math.PI; i += (cycle / type))
                {
                    //if ((azimuth + i) < az && az <= (azimuth + (i + (cycle / type)))
                    //    ||
                    //    ((azimuth + i) < (az+ cycle) && (az+ cycle) <= ((azimuth + (i + (cycle / type))) + cycle))
                    //    )
                    if (VerifyRegion((azimuth + i),(azimuth + (i + (cycle / type))),az))
                    {
                        ListToCheck[subtype].Add(new KDistance(dist, az, target));
                    }
                    subtype++;
                }
            }
       
        }
Ejemplo n.º 9
0
        public static double[] GetAzimuth3D(double x, double y, double z, Kpoint pi)
        {

            double azXY = GetAzimuth(x, y, pi);
            double dx = GetDistanceXY(x, y, pi);
            double dy = pi.Z - z;
            double az = double.NaN;
            if (dx == 0 && dy > 0) az = 0;
            if (dx == 0 && dy < 0) az = (Math.PI);
            if (dx > 0 && dy == 0) az = (Math.PI / 2);
            if (dx < 0 && dy == 0) az = (3 * Math.PI / 2);
            if (dx > 0 && dy > 0) az = (Math.Atan(dx / dy));
            if (dx > 0 && dy < 0) az = (Math.PI + Math.Atan(dx / dy));
            if (dx < 0 && dy < 0) az = ((Math.PI) + Math.Atan(dx / dy));
            if (dx < 0 && dy > 0) az = ((2 * Math.PI) + Math.Atan(dx / dy));

            if (az > (Math.PI * 2))
            {
                double val = (az) / (Math.PI * 2);
                az= (val - Math.Floor(val)) * (Math.PI * 2);
            }

            return new double[2]{azXY, az};
            
        }
Ejemplo n.º 10
0
        public static double GetAzimuth(double x, double y, Kpoint pi)
        {
            //double dx = (this.cpoints[j, 0] - this.cpoints[i, 0]);
            //double dy = (this.cpoints[j, 1] - this.cpoints[i, 1]);
            double dx = pi.X - x;
            double dy = pi.Y - y;
            double az = double.NaN;
            if (dx == 0 && dy > 0) az= 0;
            if (dx == 0 && dy < 0) az= (Math.PI);
            if (dx > 0 && dy == 0) az= (Math.PI / 2);
            if (dx < 0 && dy == 0) az= (3 * Math.PI / 2);
            if (dx > 0 && dy > 0) az= (Math.Atan(dx / dy));
            if (dx > 0 && dy < 0) az= (Math.PI + Math.Atan(dx / dy));
            if (dx < 0 && dy < 0) az= ((Math.PI) + Math.Atan(dx / dy));
            if (dx < 0 && dy > 0) az= ((2 * Math.PI) + Math.Atan(dx / dy));

            if (az > (Math.PI * 2))
            {
                double val = (az) / (Math.PI * 2);
                return (val - Math.Floor(val)) * (Math.PI * 2);
            }

            return az;
        }
Ejemplo n.º 11
0
 public static double[] GetAzimuth3D(Kpoint center, Kpoint target)
 {
     return GetAzimuth3D(center.X, center.Y, center.Z, target);
 }
Ejemplo n.º 12
0
 public static double GetAzimuth(Kpoint center, Kpoint target)
 {
     return GetAzimuth(center.X, center.Y, target);
 }
Ejemplo n.º 13
0
 public static double GetSemivariance(Kpoint pointi, Kpoint point)
 {
     return 0.5 * (pointi.W - point.W) * (pointi.W - point.W);
 }
Ejemplo n.º 14
0
        public static double GetDistance(Kpoint pointi, Kpoint point)
        {

            return Math.Sqrt(((point.X - pointi.X) * (point.X - pointi.X)) +
                                 ((point.Y - pointi.Y) * (point.Y - pointi.Y)) + ((point.Z - pointi.Z) * (point.Z - pointi.Z)));
        }
Ejemplo n.º 15
0
        public static double GetDistanceXY(double x, double y,  Kpoint point)
        {

            return Math.Sqrt(((point.X - x) * (point.X - x)) +
                                 ((point.Y - y) * (point.Y - y)) );
        }
Ejemplo n.º 16
0
        private double[] zone(Kpoint center)
        {
            #region zone

            Kpoint p1 = Utils.AzimuthDist(center, new double[]{this.azimuth,azimut2}, this.majorRadio);

            Kpoint p1R = Utils.AzimuthDist(p1, new double[]{this.azimuth+ Math.PI / 2,azimut2}, this.minorRadio);
            Kpoint p1L = Utils.AzimuthDist(p1, new double[]{this.azimuth - Math.PI / 2,azimut2}, this.minorRadio);

            Kpoint p2 = Utils.AzimuthDist(center,new double[]{ this.azimuth,azimut2}, this.majorRadio * -1);
            Kpoint p2R = Utils.AzimuthDist(p2,new double[]{ this.azimuth + Math.PI / 2,azimut2}, this.minorRadio);
            Kpoint p2L = Utils.AzimuthDist(p2, new double[] { this.azimuth - Math.PI / 2, azimut2 }, this.minorRadio);

            Kpoint p1R1 = Utils.AzimuthDist(p1R, new double[] { this.azimuth + Math.PI / 2, azimut2 + Math.PI }, this.zRadio);
            Kpoint p1R2 = Utils.AzimuthDist(p1R, new double[] { this.azimuth + Math.PI / 2, azimut2 - Math.PI }, this.zRadio);

            Kpoint p1L1 = Utils.AzimuthDist(p1L, new double[] { this.azimuth - Math.PI / 2, azimut2 + Math.PI }, this.zRadio);
            Kpoint p1L2 = Utils.AzimuthDist(p1L, new double[] { this.azimuth - Math.PI / 2, azimut2 - Math.PI }, this.zRadio);

            Kpoint p2R1 = Utils.AzimuthDist(p2R, new double[] { this.azimuth + Math.PI / 2, azimut2 + Math.PI }, this.zRadio);
            Kpoint p2R2 = Utils.AzimuthDist(p2R, new double[] { this.azimuth + Math.PI / 2, azimut2 - Math.PI }, this.zRadio);
            Kpoint p2L1 = Utils.AzimuthDist(p2L, new double[] { this.azimuth - Math.PI / 2, azimut2 + Math.PI }, this.zRadio);
            Kpoint p2L2 = Utils.AzimuthDist(p2L, new double[] { this.azimuth - Math.PI / 2, azimut2 - Math.PI }, this.zRadio);

           // Kpoint p3 = Utils.AzimuthDist(center, this.azimuth + Math.PI / 2, this.minorRadio);
          //  Kpoint p4 = Utils.AzimuthDist(center, this.azimuth + Math.PI / 2, this.minorRadio * -1);


            Stat elv = new Stat(false);
            elv += new Stat(p1R.Z);
            elv += new Stat(p1L.Z);
            elv += new Stat(p2R.Z);
            elv += new Stat(p2L.Z);
            elv += new Stat(p1R1.Z);
            elv += new Stat(p1R2.Z);
            elv += new Stat(p1L1.Z);
            elv += new Stat(p1L2.Z);
            elv += new Stat(p2R1.Z);
            elv += new Stat(p2R2.Z);
            elv += new Stat(p2L1.Z);
            elv += new Stat(p2L2.Z);

            Stat east = new Stat(false);
            east += new Stat(p1R.X);
            east += new Stat(p1L.X);
            east += new Stat(p2R.X);
            east += new Stat(p2L.X);
            east += new Stat(p1R1.X);
            east += new Stat(p1R2.X);
            east += new Stat(p1L1.X);
            east += new Stat(p1L2.X);
            east += new Stat(p2R1.X);
            east += new Stat(p2R2.X);
            east += new Stat(p2L1.X);
            east += new Stat(p2L2.X);

            Stat north = new Stat(false);
            north += new Stat(p1R.Y);
            north += new Stat(p1L.Y);
            north += new Stat(p2R.Y);
            north += new Stat(p2L.Y);
            north += new Stat(p1R1.Y);
            north += new Stat(p1R2.Y);
            north += new Stat(p1L1.Y);
            north += new Stat(p1L2.Y);
            north += new Stat(p2R1.Y);
            north += new Stat(p2R2.Y);
            north += new Stat(p2L1.Y);
            north += new Stat(p2L2.Y);
            #endregion
            return new double[3] { east.Max - east.Min, north.Max - north.Min, elv.Max-elv.Min };
        }
Ejemplo n.º 17
0
        private void  ConfigEllipse(Kpoint center)
        {
            double majorRadio = this.majorRadio * (1 + mult);
            double minorRadio = this.minorRadio * (1 + mult);
             double f = Math.Sqrt((majorRadio * majorRadio) - (minorRadio * minorRadio));
            focu1 = Utils.AzimuthDist(center, azimuth, f);
           // Kpoint pointRadioMajor = AzimuthDist(center, azimuth, majorRadio);
            focu2 = Utils.AzimuthDist(center, azimuth, -1 * f);
            distConst = 2 * majorRadio; //GetDistance(focu2,pointRadioMajor) + GetDistance(focu1,pointRadioMajor);

        }
Ejemplo n.º 18
0
 public static Kpoint AzimuthDist(Kpoint ptoI, double azi, double dist)
 {
     return new Kpoint(ptoI.X + Math.Sin(azi) * dist, ptoI.Y + Math.Cos(azi) * dist, 0, 0);
 }
Ejemplo n.º 19
0
        public static Kpoint AzimuthDist(Kpoint ptoI, double[] azi, double dist)
        {
            double r = Math.Sin(azi[1]) * dist;

            return new Kpoint(ptoI.X + Math.Sin(azi[0]) * r, ptoI.Y + Math.Cos(azi[0]) * r, Math.Cos(azi[1]) * dist, 0);
        }
Ejemplo n.º 20
0
 public object Clone()
 {
     Kpoint v= new Kpoint(this.X,this.Y,this.Z,this.W,this.id);
     v.Zinte = this.Zinte;
     v.Error = this.Error;
     v.SdtError = this.SdtError;
     return v;
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Initializes a new instance of the Node class
 /// </summary>
 /// <param name="x">X position of the node</param>
 /// <param name="y">Y position of the node</param>
 /// <param name="value">value associated with the node</param>
 public Node(
     double x, double y, Kpoint value)
 {
     this.x = x;
     this.y = y;
     this.value = value;
 }
Ejemplo n.º 22
0
 public KDistance(double distance, double azimuth, Kpoint p)
 {
     this.distance = distance;
     this.azimuth = azimuth;
     this.point = p;
 }
Ejemplo n.º 23
0
 public void Insert(
   Kpoint value)
 {
     this.root = this.Insert(this.root, value.X,value.Y, value);
 }
Ejemplo n.º 24
0
        private void CreatePointsK(
          IFeatureSet shapeLayer, int idField)
        {
            this.data = shapeLayer;
            this.npoints1 = shapeLayer.NumRows();
           // this.kpoints = new Kpoint[this.npoints1];//x,y,z,z-inter,error,stderr
            this.quadTree1 = new QuadTree();
            Stat NorthSouth = new Stat(false);
            Stat EastWest = new Stat(false); 
            Stat TopBott = new Stat(false);
            Stat Zvalue = new Stat(false);
            List<int> l = SelectRandom(shapeLayer.NumRows());
            this.npoints1 = l.Count();

            for (int shp1 = 0; shp1 < l.Count; shp1++)
            {
                int shp = l[shp1];
                Coordinate pt = shapeLayer.Features[shp].Coordinates[0];
                Kpoint point = new Kpoint(pt.X, pt.Y, double.IsNaN(pt.Z) ? 0 : pt.Z, Convert.ToDouble(shapeLayer.Features[shp].DataRow[idField]), shp);
                this.kpoints.Add(point );
                //this.cpoints1[shp, 0] = pt.X;
                //this.cpoints1[shp, 1] = pt.Y;
                //this.cpoints1[shp, 2] = Convert.ToDouble(shapeLayer.Features[shp].DataRow[idField]);
                this.quadTree1.Insert(pt.X, pt.Y, point);
                NorthSouth += new Stat(pt.Y);
                EastWest += new Stat(pt.X);
                TopBott += new Stat(pt.Z);
                Zvalue +=  new Stat(point.W);
            }
                this.extentZ1= new  double[2] {Zvalue.Min,Zvalue.Max};
                this.extent1= new  double[6]{EastWest.Min,NorthSouth.Min,TopBott.Min,EastWest.Max,NorthSouth.Max, TopBott.Max};
                this.idExtremPoints= new long[6]{EastWest.PosMin,NorthSouth.PosMin,TopBott.PosMin,EastWest.PosMax,NorthSouth.PosMax, TopBott.PosMax};
                this.idExtremeZPoints= new long[2]{Zvalue.PosMin,Zvalue.PosMax};
        }