コード例 #1
0
        public PointClassification ClassifyPoint(double latitude, double longitude)
        {
            FeatureSet pFeatureSet = new FeatureSet();

            pFeatureSet.Projection = KnownCoordinateSystems.Geographic.World.WGS1984;

            DotSpatial.Topology.Point pPoint = new DotSpatial.Topology.Point(longitude, latitude);
            FeatureSet pPointFeatureSet      = new FeatureSet(DotSpatial.Topology.FeatureType.Point);

            pPointFeatureSet.Projection = KnownCoordinateSystems.Geographic.World.WGS1984;
            pPointFeatureSet.AddFeature(pPoint);

            Extent pAffectedExtent = null;
            var    result          = fsWorldCountries.Select(pPointFeatureSet.Extent, out pAffectedExtent);

            foreach (IFeature feature in result)
            {
                PointClassification classification = new PointClassification();
                classification.CountryCode = feature.DataRow["ADM0_A3"].ToString();
                if (classification.CountryCode.Length == 3)
                {
                    classification.CountryCode = ConvertISOCountryCode(classification.CountryCode);
                }
                classification.CountrySubdivision = feature.DataRow["NAME"].ToString();
                classification.CountryName        = feature.DataRow["ADMIN"].ToString();
                return(classification);
            }

            return(null);
            // System.Diagnostics.Debug.WriteLine(featureL);
        }
コード例 #2
0
        public PointClassification ClassifyPoint(double latitude, double longitude)
        {
            FeatureSet pFeatureSet = new FeatureSet();
            pFeatureSet.Projection = KnownCoordinateSystems.Geographic.World.WGS1984;

            DotSpatial.Topology.Point pPoint = new DotSpatial.Topology.Point(longitude, latitude);
            FeatureSet pPointFeatureSet = new FeatureSet(DotSpatial.Topology.FeatureType.Point);
            pPointFeatureSet.Projection = KnownCoordinateSystems.Geographic.World.WGS1984;
            pPointFeatureSet.AddFeature(pPoint);

            Extent pAffectedExtent = null;
            var result = fsWorldCountries.Select(pPointFeatureSet.Extent, out pAffectedExtent);

            foreach (IFeature feature in result)
            {
                PointClassification classification = new PointClassification();
                classification.CountryCode = feature.DataRow["ADM0_A3"].ToString();
                if (classification.CountryCode.Length == 3) classification.CountryCode = ConvertISOCountryCode(classification.CountryCode);
                classification.CountrySubdivision = feature.DataRow["NAME"].ToString();
                classification.CountryName = feature.DataRow["ADMIN"].ToString();
                return classification;
            }

            return null;
            // System.Diagnostics.Debug.WriteLine(featureL);
        }