Пример #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);
        }
Пример #3
0
        internal static DotSpatial.Topology.LinearRing ToDotSpatialLinearRing(GeoAPI.Geometries.ILinearRing geom)
        {
            Collection <DotSpatial.Topology.Point> vertices = new Collection <DotSpatial.Topology.Point>();

            foreach (Coordinate coordinate in geom.Coordinates)
            {
                DotSpatial.Topology.Point p = ToDotSpatialPoint(coordinate);

                vertices.Add(p);
            }
            return(new DotSpatial.Topology.LinearRing(vertices));
        }
Пример #4
0
        private void addFeature(double lat, double lon)
        {
            MapPointLayer mpl = (MapPointLayer)Layer;

            double[] xy = { lon, lat };
            double[] z  = { 0 };
            DotSpatial.Projections.Reproject.ReprojectPoints(xy, z, DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984, mpl.Projection, 0, 1);
            DotSpatial.Topology.Point newPost = new DotSpatial.Topology.Point(xy[0], xy[1]);
            IFeature np = mpl.DataSet.AddFeature(newPost);

            maxTAMSID++;
            string[] cols = { "FID", ModuleName + "_f_TAMSID", "TAMSICON" };
            PrepareDatatable(np.DataRow.Table, cols);
            np.DataRow["FID"] = maxTAMSID;
            np.DataRow[Project.settings.GetValue(ModuleName + "_f_TAMSID")] = maxTAMSID;
            np.DataRow["TAMSICON"] = "feature";
            Dictionary <string, string> values = new Dictionary <string, string>()
            {
                { "TAMSID", maxTAMSID.ToString() },
                { "icon", "feature" }
            };

            Database.ReplaceRow(Project.conn, values, "miscellaneous");
            mpl.DataSet.Save();
            mpl.ClearSelection();
            setSymbolizer();
            Project.map.Invalidate();
            Project.map.Refresh();
            Project.map.ResetBuffer();
            Project.map.Update();
            if (mpl.DataSet.NumRows() == 1)
            {
                mpl.Extent.SetValues(xy[0] - 100, xy[1] - 100, xy[0] + 100, xy[1] + 100);
                Project.map.ViewExtents = mpl.Extent;
            }
        }
Пример #5
0
        private void MonitorRollbackSettings2_Load(object sender, EventArgs e)
        {
            try
            {
                if (CommonClass.GBenMAPGrid == null)
                {
                    return;
                }
                mainMap.ProjectionModeReproject = ActionMode.Never;
                mainMap.ProjectionModeDefine    = ActionMode.Never;
                if (_monitorRollbackLine.RollbackGrid is ShapefileGrid)
                {
                    if (File.Exists(CommonClass.DataFilePath + @"\Data\Shapefiles\" + CommonClass.MainSetup.SetupName + "\\" + (_monitorRollbackLine.RollbackGrid as ShapefileGrid).ShapefileName + ".shp"))
                    {
                        mainMap.Layers.Add(CommonClass.DataFilePath + @"\Data\Shapefiles\" + CommonClass.MainSetup.SetupName + "\\" + (_monitorRollbackLine.RollbackGrid as ShapefileGrid).ShapefileName + ".shp");
                    }
                }
                else if (_monitorRollbackLine.RollbackGrid is RegularGrid)
                {
                    if (File.Exists(CommonClass.DataFilePath + @"\Data\Shapefiles\" + CommonClass.MainSetup.SetupName + "\\" + (_monitorRollbackLine.RollbackGrid as RegularGrid).ShapefileName + ".shp"))
                    {
                        mainMap.Layers.Add(CommonClass.DataFilePath + @"\Data\Shapefiles\" + CommonClass.MainSetup.SetupName + "\\" + (_monitorRollbackLine.RollbackGrid as RegularGrid).ShapefileName + ".shp");
                    }
                }
                PolygonLayer playerRegion = mainMap.Layers[mainMap.Layers.Count - 1] as PolygonLayer;
                playerRegion.DataSet.DataTable.Columns.Add("MyColorIndex", typeof(int));
                for (int i = 0; i < playerRegion.DataSet.DataTable.Rows.Count; i++)
                {
                    playerRegion.DataSet.DataTable.Rows[i]["MyColorIndex"] = i;
                    dicMyColorIndex.Add(Convert.ToInt32(playerRegion.DataSet.DataTable.Rows[i]["COL"]).ToString() + "," + Convert.ToInt32(playerRegion.DataSet.DataTable.Rows[i]["ROW"]).ToString(), i);
                }
                Color             cRegion           = Color.Transparent;
                PolygonSymbolizer TransparentRegion = new PolygonSymbolizer(cRegion);

                TransparentRegion.OutlineSymbolizer = new LineSymbolizer(Color.Black, 1); playerRegion.Symbolizer = TransparentRegion;

                lstMonitorValues = DataSourceCommonClass.GetMonitorData(_monitorRollbackLine.GridType, _monitorRollbackLine.Pollutant, _monitorRollbackLine);
                IFeatureSet  fsPoints = new FeatureSet();
                MonitorValue mv       = null;
                Feature      feature  = null;
                List <DotSpatial.Topology.Coordinate> lstCoordinate = new List <DotSpatial.Topology.Coordinate>();
                List <double> fsInter = new List <double>();
                if (lstMonitorValues != null && lstMonitorValues.Count > 0)
                {
                    PolygonScheme   myScheme = new PolygonScheme();
                    PolygonCategory pcin     = new PolygonCategory();
                    pcin.Symbolizer.SetFillColor(Color.Red);
                    myScheme.Categories.Add(pcin);
                    DotSpatial.Topology.Point point;
                    for (int i = 0; i < lstMonitorValues.Count; i++)
                    {
                        mv      = lstMonitorValues[i];
                        point   = new DotSpatial.Topology.Point(mv.Longitude, mv.Latitude);
                        feature = new Feature(point);
                        fsPoints.AddFeature(feature);
                    }
                    mainMap.Layers.Add(fsPoints);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
            }
        }