コード例 #1
1
ファイル: RectangleImpl.cs プロジェクト: ccurrens/Spatial4n
 public RectangleImpl(Point lowerLeft, Point upperRight)
 {
     this.minX = lowerLeft.GetX();
     this.maxX = upperRight.GetX();
     this.minY = lowerLeft.GetY();
     this.maxY = upperRight.GetY();
 }
コード例 #2
0
ファイル: PointImpl.cs プロジェクト: ccurrens/Spatial4n
        /// <summary>
        /// All {@link Point} implementations should use this definition of {@link Object#hashCode()}.
        /// </summary>
        /// <param name="thiz"></param>
        /// <returns></returns>
        public static int GetHashCode(Point thiz)
        {
            if (thiz == null)
                throw new ArgumentNullException("thiz");

            long temp = thiz.GetX() != +0.0d ? BitConverter.DoubleToInt64Bits(thiz.GetX()) : 0L;
            int result = (int)(temp ^ ((uint)temp >> 32));
            temp = thiz.GetY() != +0.0d ? BitConverter.DoubleToInt64Bits(thiz.GetY()) : 0L;
            result = 31 * result + (int)(temp ^ ((uint)temp >> 32));
            return result;
        }
コード例 #3
0
 public override Rectangle CalcBoxByDistFromPt(Point from, double distDEG, SpatialContext ctx, Rectangle reuse)
 {
     double minX = from.GetX() - distDEG;
     double maxX = from.GetX() + distDEG;
     double minY = from.GetY() - distDEG;
     double maxY = from.GetY() + distDEG;
     if (reuse == null)
     {
         return ctx.MakeRectangle(minX, maxX, minY, maxY);
     }
     else
     {
         reuse.Reset(minX, maxX, minY, maxY);
         return reuse;
     }
 }
コード例 #4
0
ファイル: TestPoint.cs プロジェクト: GeospatialDaryl/libLAS
      static public void Test_A2(Point point)
      {
         double x = point.GetX();
         double y = point.GetY();
         double z = point.GetZ();
         Debug.Assert(Program.IsApprox(x, 636784.74, 0.01));
         Debug.Assert(Program.IsApprox(y, 849106.66, 0.01));
         Debug.Assert(Program.IsApprox(z, 426.71, 0.01));

         double time = point.GetTime();
         Debug.Assert(Program.IsApprox(time, 245382.13595, 0.00001));

         Debug.Assert(point.GetIntensity() == 118);
         Debug.Assert(point.GetReturnNumber() == 1);
         Debug.Assert(point.GetNumberOfReturns() == 1);

         Classification classif = point.GetClassification();
         Debug.Assert(classif.GetClassName() == "Unclassified");
         Debug.Assert(!classif.IsKeyPoint());
         Debug.Assert(!classif.IsSynthetic());
         Debug.Assert(!classif.IsWithheld());

         Color color = point.GetColor();
         Debug.Assert(color.GetRed() == 112);
         Debug.Assert(color.GetGreen() == 97);
         Debug.Assert(color.GetBlue() == 114);
      }
コード例 #5
0
ファイル: PointImpl.cs プロジェクト: h0st1le/Spatial4n
        /// <summary>
        /// All {@link Point} implementations should use this definition of {@link Object#equals(Object)}.
        /// </summary>
        /// <param name="thiz"></param>
        /// <param name="o"></param>
        /// <returns></returns>
        public static bool Equals(Point thiz, Object o)
        {
            if (thiz == null)
                throw new ArgumentNullException("thiz");

            if (thiz == o) return true;

            var point = o as Point;
            if (point == null) return false;

            return thiz.GetX().Equals(point.GetX()) && thiz.GetY().Equals(point.GetY());
        }
コード例 #6
0
 public Field[] CreateIndexableFields(Point point)
 {
     FieldType doubleFieldType = new FieldType(DoubleField.TYPE_NOT_STORED)
                                     {
                                         NumericPrecisionStep = precisionStep
                                     };
     var f = new Field[]
                 {
                     new DoubleField(fieldNameX, point.GetX(), doubleFieldType),
                     new DoubleField(fieldNameY, point.GetY(), doubleFieldType)
                 };
     return f;
 }
コード例 #7
0
        public override double Distance(Point from, double toX, double toY)
        {
            double result = 0;

            double v = from.GetX() - toX;
            result += (v * v);

            v = from.GetY() - toY;
            result += (v * v);

            if (squared)
                return result;

            return Math.Sqrt(result);
        }
コード例 #8
0
        public AbstractField[] CreateIndexableFields(Point point)
        {
                var f = new AbstractField[2];

                var f0 = new NumericField(fieldNameX, precisionStep, Field.Store.NO, true)
                             {OmitNorms = true, OmitTermFreqAndPositions = true};
                f0.SetDoubleValue(point.GetX());
                f[0] = f0;

                var f1 = new NumericField(fieldNameY, precisionStep, Field.Store.NO, true)
                             {OmitNorms = true, OmitTermFreqAndPositions = true};
                f1.SetDoubleValue(point.GetY());
                f[1] = f1;

                return f;
        }
コード例 #9
0
ファイル: CircleImpl.cs プロジェクト: ccurrens/Spatial4n
 public SpatialRelation Relate(Point point, SpatialContext ctx)
 {
     return Contains(point.GetX(), point.GetY()) ? SpatialRelation.CONTAINS : SpatialRelation.DISJOINT;
 }
コード例 #10
0
 public override double CalcBoxByDistFromPt_yHorizAxisDEG(Point from, double distDEG, SpatialContext ctx)
 {
     return from.GetY();
 }
コード例 #11
0
ファイル: RectangleImpl.cs プロジェクト: h0st1le/Spatial4n
 public RectangleImpl(Point lowerLeft, Point upperRight, SpatialContext ctx)
     : this(lowerLeft.GetX(), upperRight.GetX(), lowerLeft.GetY(), upperRight.GetY(), ctx)
 {
 }
コード例 #12
0
 public override Point PointOnBearing(Point from, double distDEG, double bearingDEG, SpatialContext ctx, Point reuse)
 {
     if (distDEG == 0)
     {
         if (reuse == null)
             return from;
         reuse.Reset(from.GetX(), from.GetY());
         return reuse;
     }
     double bearingRAD = DistanceUtils.ToRadians(bearingDEG);
     double x = from.GetX() + Math.Sin(bearingRAD)*distDEG;
     double y = from.GetY() + Math.Cos(bearingRAD)*distDEG;
     if (reuse == null)
     {
         return ctx.MakePoint(x, y);
     }
     else
     {
         reuse.Reset(x, y);
         return reuse;
     }
 }
コード例 #13
0
ファイル: RectangleImpl.cs プロジェクト: ccurrens/Spatial4n
 public SpatialRelation Relate(Point point, SpatialContext ctx)
 {
     if (point.GetY() > GetMaxY() || point.GetY() < GetMinY())
         return SpatialRelation.DISJOINT;
     //  all the below logic is rather unfortunate but some dateline cases demand it
     double minX = this.minX;
     double maxX = this.maxX;
     double pX = point.GetX();
     if (ctx.IsGeo())
     {
         //unwrap dateline and normalize +180 to become -180
         double rawWidth = maxX - minX;
         if (rawWidth < 0)
         {
             maxX = minX + (rawWidth + 360);
         }
         //shift to potentially overlap
         if (pX < minX)
         {
             pX += 360;
         }
         else if (pX > maxX)
         {
             pX -= 360;
         } else {
             return SpatialRelation.CONTAINS; //short-circuit
         }
     }
     if (pX < minX || pX > maxX)
         return SpatialRelation.DISJOINT;
     return SpatialRelation.CONTAINS;
 }
コード例 #14
0
        /* NGeohash round-trip for given precision. */

        private Point alignGeohash(Point p)
        {
            return GeohashUtils.Decode(GeohashUtils.EncodeLatLon(p.GetY(), p.GetX(), maxLength), ctx);
        }
コード例 #15
0
ファイル: SpatialContext.cs プロジェクト: h0st1le/Spatial4n
 /// <summary>
 /// Construct a rectangle. The parameters will be normalized.
 /// </summary>
 /// <param name="lowerLeft"></param>
 /// <param name="upperRight"></param>
 /// <returns></returns>
 public Rectangle MakeRectangle(Point lowerLeft, Point upperRight)
 {
     return MakeRectangle(lowerLeft.GetX(), upperRight.GetX(),
                     lowerLeft.GetY(), upperRight.GetY());
 }
コード例 #16
0
 protected internal override Cell GetCell(Point p, int level)
 {
     return new GhCell(this, GeohashUtils.EncodeLatLon(p.GetY(), p.GetX
                                                                     (), level));
 }
コード例 #17
0
 protected override Node GetNode(Point p, int level)
 {
     return new GhCell(GeohashUtils.EncodeLatLon(p.GetY(), p.GetX(), level), this);//args are lat,lon (y,x)
 }
コード例 #18
0
ファイル: QuadPrefixTree.cs プロジェクト: Cefa68000/lucenenet
 protected internal override Cell GetCell(Point p, int level)
 {
     IList<Cell> cells = new List<Cell>(1);
     Build(xmid, ymid, 0, cells, new StringBuilder(), ctx.MakePoint(p.GetX(), p.GetY()), level);
     return cells[0];
 }
コード例 #19
0
 public override double CalcBoxByDistFromPt_yHorizAxisDEG(Point from, double distance, SpatialContext ctx)
 {
     return DistanceUtils.CalcBoxByDistFromPt_latHorizAxisDEG(from.GetY(), from.GetX(), distance, radius);
 }
コード例 #20
0
 protected override Node GetNode(Point p, int level)
 {
     var cells = new List<Node>(1);
     Build(xmid, ymid, 0, cells, new StringBuilder(), ctx.MakePoint(p.GetX(), p.GetY()), level);
     return cells[0];//note cells could be longer if p on edge
 }
コード例 #21
0
 public override Rectangle CalcBoxByDistFromPt(Point from, double distDEG, SpatialContext ctx, Rectangle reuse)
 {
     return DistanceUtils.CalcBoxByDistFromPtDEG(from.GetY(), from.GetX(), distDEG, ctx, reuse);
 }