Esempio n. 1
0
 public void UnionWith(MBR mbr)
 {
     this.min[LAT_IDX] = Math.Min(mbr.min[LAT_IDX], this.min[LAT_IDX]);
     this.max[LAT_IDX] = Math.Max(mbr.max[LAT_IDX], this.max[LAT_IDX]);
     this.min[LNG_IDX] = Math.Min(mbr.min[LNG_IDX], this.min[LNG_IDX]);
     this.max[LNG_IDX] = Math.Max(mbr.max[LNG_IDX], this.max[LNG_IDX]);
 }
Esempio n. 2
0
        bool contain(MBR mbr)
        {
            //return ((m.minx >= minx) && (m.maxx <= maxx) && (m.miny >= miny) && (m.maxy <= maxy));
            bool result = (this.min[LAT_IDX] <= mbr.min[LAT_IDX]) &&
                          (this.min[LNG_IDX] <= mbr.min[LNG_IDX]) &&
                          (this.max[LAT_IDX] >= mbr.max[LAT_IDX]) &&
                          (this.max[LNG_IDX] >= mbr.max[LAT_IDX]);

            return(result);
        }
Esempio n. 3
0
        public override bool Equals(object obj)
        {
            bool result = false;

            if (obj is MBR)
            {
                MBR tmp = (obj as MBR?).Value;
                result = (tmp.MaxLat == MaxLat && tmp.MaxLng == MaxLng &&
                          tmp.MinLat == MinLat && tmp.MinLng == MinLng);
            }
            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// Get the vertex with a mbr
        /// </summary>
        /// <param name="p"></param>
        /// <param name="radius"></param>
        /// <returns></returns>
        public HashSet <Vertex> VertexRangeQuery(GeoPoint p, double radius)
        {
            double minLat, minLng, maxLat, maxLng;
            double d_radius = radius * Constants.D_PER_M;       //radius in degree

            minLng = p.Lng - d_radius;
            maxLng = p.Lng + d_radius;
            minLat = p.Lat - d_radius;
            maxLat = p.Lat + d_radius;
            MBR rect = new MBR(minLng, minLat, maxLng, maxLat);

            return(this.vertexIndex.RangeQuery(rect));
        }
Esempio n. 5
0
        private MBR getMBR()
        {
            double minLat = double.PositiveInfinity, minLng = double.PositiveInfinity;
            double maxLat = double.NegativeInfinity, maxLng = double.NegativeInfinity;
            int    pointCount = points.Count;

            for (int i = 0; i < pointCount; i++)
            {
                minLat = Math.Min(minLat, points[i].Lat);
                minLng = Math.Min(minLng, points[i].Lng);
                maxLat = Math.Max(maxLat, points[i].Lat);
                maxLng = Math.Max(maxLng, points[i].Lng);
            }
            MBR mbr = new MBR(minLng, minLat, maxLng, maxLat);

            return(mbr);
        }
Esempio n. 6
0
 private void loadVertices(String fileName)
 {
     this.mbr = MBR.EMPTY;
     //id,lng,lat
     vertices = new Dictionary <long, Vertex>();
     using (StreamReader sr = new StreamReader(fileName))
     {
         while (!sr.EndOfStream)
         {
             String   line   = sr.ReadLine();
             String[] fields = line.Split('\t');
             Debug.Assert(fields.Length == 3);
             long   id  = long.Parse(fields[0]);
             double lat = double.Parse(fields[1]);
             double lng = double.Parse(fields[2]);
             Vertex v   = new Vertex(id, lat, lng);
             vertices.Add(id, v);
             this.mbr.Include(new GeoPoint(lat, lng));
         }
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Get the vertex with a mbr
 /// </summary>
 /// <param name="p"></param>
 /// <param name="radius"></param>
 /// <returns></returns>
 public HashSet <Vertex> VertexRangeQuery(MBR rect)
 {
     return(this.vertexIndex.RangeQuery(rect));
 }