Ejemplo n.º 1
0
        //입력한 위도 경도에서 사용 가능한 인증서 표시하는 함수
        private void addListViewEnabledRegion(double lat, double lon)
        {
            double distance;
            double bearing;
            double relative_angle;
            double x;
            double y;
            double a;

            Dot2CertificateInfo certInfoForRegion = new Dot2CertificateInfo();

            //현재 리스트 순서대로 유효지역 확인
            for (int i = 0; i < this.listView.Items.Count; i++)
            {
                this.listView.Items[i].SubItems[5].Text = "";                                                 //기존의 enabled region 표시 제거

                byte[] certValue = File.ReadAllBytes(fileForePath + this.listView.Items[i].SubItems[1].Text); //현재 리스트의 인증서 파일 내용 읽어오기
                DecodeDot2Certificate(certValue, certValue.Length, ref certInfoForRegion);                    //인증서 파일 분석
                Dot2CircularRegion circle = certInfoForRegion.valid_region.circular;

                distance       = gn_GetDistanceBetweenPoints(lat, lon, (double)circle.center.lat / 10000000, (double)circle.center.lon / 10000000);
                bearing        = gn_GetBearingBetweenPoints(lat, lon, (double)circle.center.lat / 10000000, (double)circle.center.lon / 10000000);
                relative_angle = bearing - 360;
                x = distance * Math.Cos(relative_angle * Math.PI / 180);
                y = distance * Math.Sin(relative_angle * Math.PI / 180);
                a = circle.radius;

                //비교하며 표기
                if ((1 - Math.Pow(x / a, 2) - Math.Pow(y / a, 2)) > 0)
                {
                    this.listView.Items[i].SubItems[5].ForeColor = Color.Blue;
                    this.listView.Items[i].SubItems[5].Text      = "●";
                }
            }
        }
Ejemplo n.º 2
0
        private void PrintDot2CertValidRegion(Dot2CertValidRegion region)
        {
            this.gridView[0, 3].Value = "유효 지역";
            this.gridView[1, 3].Value = "";

            if (region.present == false)
            {
                return;
            }

            switch (region.region_type)
            {
            case Dot2GeogarphicRegionType.kDot2GeogarphicRegionType_Circular:
            {
                Dot2CircularRegion c = region.circular;
                this.gridView[0, 3].Value += "(circular)";
                this.gridView[1, 3].Value  = "-center lat: " + c.center.lat
                                             + Environment.NewLine + "-center lon: " + c.center.lon
                                             + Environment.NewLine + "-radius: " + c.radius + "m";
            }
            break;

            case Dot2GeogarphicRegionType.kDot2GeogarphicRegionType_RectangularSet:
            {
                Dot2RectangularRegionSet set = region.rectangular;

                this.gridView[0, 3].Value += "(rectangular)";
                this.gridView[1, 3].Value  = "-region num: " + set.region_num + Environment.NewLine;

                for (int i = 0; i < set.region_num; i++)
                {
                    this.gridView[1, 3].Value += "Region[" + i + "] notrh/west lat: " + set.north_west_lat[i] + ", lon: " + set.north_west_lon[i]
                                                 + ", south/east lat: " + set.south_east_lat + ", lon: " + set.south_east_lon;
                    if (i != set.region_num - 1)
                    {
                        this.gridView[1, 3].Value += Environment.NewLine;
                    }
                }
            }
            break;

            case Dot2GeogarphicRegionType.kDot2GeogarphicRegionType_Polygonal:
            {
                Dot2PolygoanlRegion p = region.polygonal;

                this.gridView[0, 3].Value += "(polygonal)";
                this.gridView[1, 3].Value  = "-point num: " + p.point_num + Environment.NewLine;

                for (int i = 0; i < p.point_num; i++)
                {
                    this.gridView[1, 3].Value += "Point[" + i + "] lat: " + p.point_lat[i] + ", lon: " + p.point_lon[i];
                    if (i != p.point_num - 1)
                    {
                        this.gridView[1, 3].Value += Environment.NewLine;
                    }
                }
            }
            break;

            case Dot2GeogarphicRegionType.kDot2GeogarphicRegionType_Identified:
            {
                Dot2IdentifiedRegionSet set = region.identified;

                this.gridView[0, 3].Value += "(identified)";
                this.gridView[1, 3].Value  = "-num :" + set.num + Environment.NewLine;

                for (int i = 0; i < set.num; i++)
                {
                    this.gridView[1, 3].Value += "Region[" + i + "] - Type: " + set.type[i].ToString().Substring(26, set.type[i].ToString().Length - 26)
                                                 + ", Country: " + set.country[i];
                    if (i != set.num - 1)
                    {
                        this.gridView[1, 3].Value += Environment.NewLine;
                    }
                }
            }
            break;

            case Dot2GeogarphicRegionType.kDot2GeogarphicRegionType_Unknown:
                this.gridView[0, 3].Value += "(unknown)";
                break;

            default: break;
            }
        }