Exemple #1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string espgCode;
            string filePath = "";

            if (!DA.GetData(0, ref filePath))
            {
                return;
            }
            string prjString = File.ReadAllText(@filePath);
            var    soursePrj = new DotSpatial.Projections.ProjectionInfo();

            soursePrj = DotSpatial.Projections.ProjectionInfo.FromEsriString(prjString);

            //var sourseDatum = new DotSpatial.Positioning.Datum();
            //sourseDatum.ParseEsriString(prjString);

            espgCode = soursePrj.EpsgCode.ToString();
            //espgCode = soursePrj.AuthorityCode.ToString;
            //DotSpatial.Projections.AuthorityCodes.AuthorityCodeHandler.

            //var sourseDatum = DotSpatial.Positioning.Datum.FromName(soursePrj.ToString());
            //espgCode = sourseDatum.EpsgNumber.ToString();


            DA.SetData(0, espgCode);
            DA.SetData(1, prjString);
            DA.SetData(2, soursePrj);
        }
Exemple #2
0
        /// <summary>
        /// DotSpatial to Ogr at projection level
        /// </summary>
        /// <param name="projectionInfo">DotSpatial ProjectionInfo</param>
        /// <returns>Ogr SpatialReference</returns>
        public static OSGeo.OSR.SpatialReference DS2OgrProjection(DotSpatial.Projections.ProjectionInfo projectionInfo)
        {
            string proj4 = projectionInfo.ToProj4String();

            OSGeo.OSR.SpatialReference spatialReference = new OSGeo.OSR.SpatialReference("");
            spatialReference.ImportFromProj4(proj4);
            return(spatialReference);
        }
Exemple #3
0
        /// <summary>
        /// Ogr to DotSpatial at projection level
        /// </summary>
        /// <param name="spatialReference">Ogr SpatialReference</param>
        /// <returns>DotSpatial ProjectionInfo</returns>
        public static DotSpatial.Projections.ProjectionInfo Ogr2DSProjection(OSGeo.OSR.SpatialReference spatialReference)
        {
            string proj4 = string.Empty;
            int    i     = spatialReference.ExportToProj4(out proj4);

            DotSpatial.Projections.ProjectionInfo projectionInfo = DotSpatial.Projections.ProjectionInfo.FromProj4String(proj4);
            return(projectionInfo);
        }
        private static ICoordinateSystem GetCoordinateSystemForSrid(int srid)
        {
            if (srid <= 0)
            {
                return(null);
            }

            ICoordinateSystem res = null;

#if !DotSpatialProjections
            if (_sridCoordinateSystem.TryGetValue(srid, out res))
            {
                return(res);
            }

            var wkt = Converters.WellKnownText.SpatialReference.SridToWkt(srid);
            if (string.IsNullOrEmpty(wkt))
            {
                Logger.Error(fmh => fmh("No definition for SRID {0}!", srid));
                return(null);
            }

            var csFactory = new CoordinateSystemFactory();
            try
            {
                res = csFactory.CreateFromWkt(wkt);
            }
            catch (Exception)
            {
                Logger.Error(fmh => fmh("Could not parse definition for SRID {0}:\n{1}", srid, wkt));
                return(null);
            }
            _sridCoordinateSystem.Add(srid, res);
#else
            try
            {
                if (_sridDefinition != null)
                {
                    string proj4;
                    if (_sridDefinition.TryGetValue(srid, out proj4))
                    {
                        res = ICoordinateSystem.FromProj4String(proj4);
                    }
                }

                if (res == null)
                {
                    res = DotSpatial.Projections.ProjectionInfo.FromEpsgCode(srid);
                }
            }
            catch (Exception)
            {
                Logger.Error(fmh => fmh("Could not get coordinate system for SRID {0}!", srid));
                return(null);
            }
#endif
            return(res);
        }
 public NewPointLayer(DotSpatial.Controls.IMap map, DotSpatial.Projections.ProjectionInfo projection, string filePath, ISnapSettings snapSettings)
     : base(map)
 {
     this.map          = map;
     this.projection   = projection;
     this.filePath     = filePath;
     this.snapSettings = snapSettings;
     DoSnapping        = this.snapSettings.Snap;
 }
Exemple #6
0
        /// <summary>
        /// converts the map's/datasource's bbox to geographic bbox
        /// </summary>
        /// <param name="bb"></param>
        /// <returns></returns>
        protected EX_GeographicBoundingBox ConvertToGeographicBoundingBox(BoundingBox bb)
        {
            //output object
            EX_GeographicBoundingBox bbox = new EX_GeographicBoundingBox();


            //coordinate projection transformation
            DotSpatial.Projections.ProjectionInfo pTo   = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
            DotSpatial.Projections.ProjectionInfo pFrom = null;

            pFrom = DotSpatial.Projections.ProjectionInfo.FromEpsgCode(this.SRID);

            double minx, miny, maxx, maxy;

            if (pFrom == null)
            {
                //from projection not known so just assume world coords
                minx = -180;
                miny = -90;
                maxx = 180;
                maxy = 90;
            }
            else
            {
                //projecton seems to be ok, so reproject
                //coordinate pairs
                double[] points = new double[4];

                points[0] = bb.minx;
                points[1] = bb.miny;

                points[2] = bb.maxx;
                points[3] = bb.maxy;

                double[] z = { 1 };

                DotSpatial.Projections.Reproject.ReprojectPoints(points, z, pFrom, pTo, 0, 2);

                minx = points[0];
                miny = points[1];
                maxx = points[2];
                maxy = points[3];
            }


            //transfer values
            bbox.westBoundLongitude = minx;
            bbox.southBoundLatitude = miny;
            bbox.eastBoundLongitude = maxx;
            bbox.northBoundLatitude = maxy;

            //and return the object
            return(bbox);
        }
        public void TestConversionDSProjection()
        {
            var pi1 = new DotSpatial.Projections.ProjectionInfo();
            pi1.ReadEsriString(Osgb36);
            var pi2 = new DotSpatial.Projections.ProjectionInfo();
            pi2.ReadEsriString(WGS84);

            var ct = new DotSpatial.Projections.CoordinateTransformation();
            ct.Source = pi1;
            ct.Target = pi2;


        }
Exemple #8
0
        public void TestConversionDSProjection()
        {
            var pi1 = new DotSpatial.Projections.ProjectionInfo();

            pi1.ReadEsriString(Osgb36);
            var pi2 = new DotSpatial.Projections.ProjectionInfo();

            pi2.ReadEsriString(WGS84);

            var ct = new DotSpatial.Projections.CoordinateTransformation();

            ct.Source = pi1;
            ct.Target = pi2;
        }
Exemple #9
0
        /// <summary>
        /// 坐標系統轉換
        /// 參考資料 https://www.nuget.org/packages/Proj4Net
        /// https://www.codeproject.com/Tips/1072197/Coordinate-Transformation-Using-Proj-in-NET
        /// http://spatialreference.org/ref/epsg/
        /// </summary>
        /// <returns></returns>
        public static double[] CoordinateSystemsTransformations(double[] x, double[] y, double[] z)
        {
            double[] latlng = { 0.0, 0.0, 0.0 };

            //    double[] x = {5.85000007,4.61923914,3.3873273,2.5413302,
            //2.74920293,3.38005007,5.10171662,6.03675746,6.83078962,6.77138124};
            //    double[] y = {50.84999997,51.51226471,51.43806765,
            //51.89076392,54.36940251,55.77197661,54.81463907,54.1912587,53.29330013,51.9500853};
            //    double[] z = new double[x.Length];

            for (int i = 0; i <= z.Length - 1; i++)
            {
                Console.WriteLine("input geographic ED50 p{0} = {1} {2}", i + 1, x[i], y[i]);
            }

            //rewrite xy array for input into Proj4
            double[] xy  = new double[2 * x.Length];
            int      ixy = 0;

            for (int i = 0; i <= x.Length - 1; i++)
            {
                xy[ixy]     = x[i];
                xy[ixy + 1] = y[i];
                z[i]        = 0;
                ixy        += 2;
            }

            string proj4_26985 = @"+proj=lcc +lat_1=39.45 +lat_2=38.3 +lat_0=37.66666666666666 +lon_0=-77 +x_0=400000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs";
            string proj4_4326  = @"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";

            DotSpatial.Projections.ProjectionInfo src =
                DotSpatial.Projections.ProjectionInfo.FromProj4String(proj4_26985);
            DotSpatial.Projections.ProjectionInfo trg =
                DotSpatial.Projections.ProjectionInfo.FromProj4String(proj4_4326);

            DotSpatial.Projections.Reproject.ReprojectPoints(xy, z, src, trg, 0, x.Length);

            ixy = 0;
            for (int i = 0; i <= x.Length - 1; i++)
            {
                Console.WriteLine("output RD New p{0} = {1} {2}", i + 1, xy[ixy], xy[ixy + 1]);
                latlng[0] = xy[ixy];
                latlng[1] = xy[ixy + 1];
                ixy      += 2;
            }


            return(latlng);
        }
        public void TestCoordinateSystemForGeometry(int srid)
        {
            var map = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(srid);
            var g   = map.CreatePoint(new Coordinate(10, 10));
            ICoordinateSystem cs = null;

            Assert.DoesNotThrow(() => cs = g.GetCoordinateSystem());
            Assert.NotNull(cs);
            Assert.AreEqual("EPSG", cs.Authority);
#if DotSpatialProjections
            Assert.AreEqual((long)srid, cs.Authority);
#else
            Assert.AreEqual((long)srid, cs.AuthorityCode);
#endif
        }
        public void TestCoordinateSystemForMap(int srid)
        {
            var map = new Map(new Size(200, 150))
            {
                SRID = srid
            };
            ICoordinateSystem cs = null;

            Assert.DoesNotThrow(() => cs = map.GetCoordinateSystem());
            Assert.NotNull(cs);
            Assert.AreEqual("EPSG", cs.Authority);
#if DotSpatialProjections
            Assert.AreEqual((long)srid, cs.Authority);
#else
            Assert.AreEqual((long)srid, cs.AuthorityCode);
#endif
        }
        public void TestCoordinateSystemForProvider(int srid)
        {
            var map = new GeometryFeatureProvider(new FeatureDataTable())
            {
                SRID = srid
            };
            ICoordinateSystem cs = null;

            Assert.DoesNotThrow(() => cs = map.GetCoordinateSystem());
            Assert.NotNull(cs);
            Assert.AreEqual("EPSG", cs.Authority);
#if DotSpatialProjections
            Assert.AreEqual((long)srid, cs.Authority);
#else
            Assert.AreEqual((long)srid, cs.AuthorityCode);
#endif
        }
Exemple #13
0
        private static void CoodinateTransformation(ref String gml_posList_st)
        {
            //gml_posList = @"392561.2249145508 137676.09832763672 40.66950000000361 392561.2249145508 137676.09832763672 30.95879999999306 392561.79510498047 137675.83709716797 30.95879999999306 392561.79510498047 137675.83709716797 40.658599999995204 392561.2249145508 137676.09832763672 40.66950000000361"


            String[] arr = gml_posList_st.Split(' ');

            //參考資料 https://www.codeproject.com/Tips/1072197/Coordinate-Transformation-Using-Proj-in-NET
            //Console.WriteLine("C#: Test coordinate conversion from ED50 to RD New");

            double[] x = new double[arr.Length / 3];
            double[] y = new double[arr.Length / 3];
            double[] z = new double[arr.Length / 3];

            for (int i = 0; i < arr.Length / 3; i++)
            {
                x[i] = double.Parse(arr[(i * 3)]);
                y[i] = double.Parse(arr[(i * 3) + 1]);
                z[i] = double.Parse(arr[(i * 3) + 2]);
            }

            //for (int i = 0; i <= z.Length - 1; i++)
            //{
            //    Console.WriteLine("input geographic ED50 p{0} = {1} {2} {3}", i + 1, x[i], y[i], z[i]);
            //}

            //rewrite xy array for input into Proj4
            double[] xy  = new double[2 * x.Length];
            int      ixy = 0;

            for (int i = 0; i <= x.Length - 1; i++)
            {
                xy[ixy]     = x[i];
                xy[ixy + 1] = y[i];
                //z[i] = z[i];
                ixy += 2;
            }

            string proj4_ed50  = @"+proj=lcc +lat_1=39.45 +lat_2=38.3 +lat_0=37.66666666666666 +lon_0=-77 +x_0=400000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs";
            string proj4_rdnew = @"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";

            DotSpatial.Projections.ProjectionInfo src =
                DotSpatial.Projections.ProjectionInfo.FromProj4String(proj4_ed50);
            DotSpatial.Projections.ProjectionInfo trg =
                DotSpatial.Projections.ProjectionInfo.FromProj4String(proj4_rdnew);

            DotSpatial.Projections.Reproject.ReprojectPoints(xy, z, src, trg, 0, x.Length);

            string tramsfer = "";

            ixy = 0;
            for (int i = 0; i <= x.Length - 1; i++)
            {
                // Console.WriteLine("output RD New p{0} = {1} {2} {3}", i + 1, xy[ixy], xy[ixy + 1], z[i]);
                if (!tramsfer.Equals(""))
                {
                    tramsfer += " ";
                }
                tramsfer += "" + xy[ixy + 1] + " " + xy[ixy] + " " + z[i];
                ixy      += 2;
            }

            gml_posList_st = tramsfer;
        }
Exemple #14
0
        } // End Function PolygonArea

        public static double CalculateArea(Wgs84Coordinates[] mycoordinates)
        {
            double[] latLonPoints = new double[mycoordinates.Length * 2];
            double[] z            = new double[mycoordinates.Length];

            // dotspatial takes the x,y in a single array, and z in a separate array.  I'm sure there's a
            // reason for this, but I don't know what it is.
            for (int i = 0; i < mycoordinates.Length; i++)
            {
                latLonPoints[i * 2]     = (double)mycoordinates[i].Longitude;
                latLonPoints[i * 2 + 1] = (double)mycoordinates[i].Latitude;
                z[i] = 0;
            } // Next i


            // source projection is WGS1984
            // https://productforums.google.com/forum/#!msg/gec-data-discussions/FxwUP7bd59g/02tvMDD3vtEJ
            // https://epsg.io/3857
            DotSpatial.Projections.ProjectionInfo projFrom = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;

            // most complicated problem - you have to find most suitable projection
            DotSpatial.Projections.ProjectionInfo projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.UtmWgs1984.WGS1984UTMZone37N;
            projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.Europe.EuropeAlbersEqualAreaConic; // 6350.9772005155683
            // projTo= DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984; // 5.215560750019806E-07
            // projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.WorldSpheroid.EckertIVsphere; // 6377.26664171461
            // projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.World.EckertIVworld; // 6391.5626849671826
            projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.World.CylindricalEqualAreaworld; // 6350.6506013739854

            /*
             * projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.WorldSpheroid.CylindricalEqualAreasphere; // 6377.2695087222382
             * projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.WorldSpheroid.EquidistantCylindricalsphere; // 6448.6818862780929
             * projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.World.Polyconicworld; // 8483.7701716953889
             * projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.World.EquidistantCylindricalworld; // 6463.1380225215107
             * projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.World.EquidistantConicworld; // 8197.4427198320627
             * projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.World.VanderGrintenIworld; // 6537.3942984174937
             * projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.World.WebMercator; // 6535.5119516421109
             * projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.World.Mercatorworld; // 6492.7180733950809
             * projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.SpheroidBased.Lambert2; // 9422.0631835013628
             * projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.SpheroidBased.Lambert2Wide; // 9422.0614012926817
             * projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.TransverseMercator.WGS1984lo33; // 6760.01638841012
             * projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.Europe.EuropeAlbersEqualAreaConic; // 6350.9772005155683
             * projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.UtmOther.EuropeanDatum1950UTMZone37N; // 6480.7883094931021
             */


            // ST_Area(g, false)     6379.25032051953
            // ST_Area(g, true)      6350.65051177517
            // ST_Area(g)            5.21556075001092E-07


            // prepare for ReprojectPoints (it's mutate array)
            DotSpatial.Projections.Reproject.ReprojectPoints(
                latLonPoints, z, projFrom, projTo
                , 0, latLonPoints.Length / 2
                );

            // assemblying new points array to create polygon
            GeoAPI.Geometries.Coordinate[] polyPoints = new GeoAPI.Geometries.Coordinate[latLonPoints.Length / 2];

            for (int i = 0; i < latLonPoints.Length / 2; ++i)
            {
                polyPoints[i] = new GeoAPI.Geometries.Coordinate(latLonPoints[i * 2], latLonPoints[i * 2 + 1]);
            } // Next i

            // Assembling linear ring to create polygon
            NetTopologySuite.Geometries.LinearRing lr =
                new NetTopologySuite.Geometries.LinearRing(polyPoints);

            if (!lr.IsValid)
            {
                throw new System.IO.InvalidDataException("Coordinates are invalid.");
            }

            GeoAPI.Geometries.IPolygon poly = new NetTopologySuite.Geometries.Polygon(lr);
            if (!poly.IsValid)
            {
                throw new System.IO.InvalidDataException("Polygon is invalid.");
            }



            return(poly.Area);
        } // End Function CalculateArea
Exemple #15
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     DotSpatial.Projections.ProjectionInfo          projectionInfo1 = new DotSpatial.Projections.ProjectionInfo();
     DotSpatial.Projections.GeographicInfo          geographicInfo1 = new DotSpatial.Projections.GeographicInfo();
     DotSpatial.Projections.Datum                   datum1          = new DotSpatial.Projections.Datum();
     DotSpatial.Projections.Spheroid                spheroid1       = new DotSpatial.Projections.Spheroid();
     DotSpatial.Projections.Meridian                meridian1       = new DotSpatial.Projections.Meridian();
     DotSpatial.Projections.AngularUnit             angularUnit1    = new DotSpatial.Projections.AngularUnit();
     System.ComponentModel.ComponentResourceManager resources       = new System.ComponentModel.ComponentResourceManager(typeof(CustomizeMapForm));
     DotSpatial.Projections.LinearUnit              linearUnit1     = new DotSpatial.Projections.LinearUnit();
     this.mapControl = new eidss.gis.Forms.EidssMapControl();
     this.SuspendLayout();
     //
     // mapControl
     //
     this.mapControl.CoordinateBarStyle   = GIS_V4.Tools.CoordBar.CoordBarStyleEnum.CbsDecDegres;
     this.mapControl.CoordinateBarVisible = true;
     this.mapControl.Dock                = System.Windows.Forms.DockStyle.Fill;
     this.mapControl.LegendTitle         = null;
     this.mapControl.Location            = new System.Drawing.Point(0, 0);
     projectionInfo1.Authority           = null;
     projectionInfo1.AuxiliarySphereType = DotSpatial.Projections.AuxiliarySphereType.NotSpecified;
     projectionInfo1.CentralMeridian     = null;
     projectionInfo1.EpsgCode            = 0;
     projectionInfo1.FalseEasting        = null;
     projectionInfo1.FalseNorthing       = null;
     projectionInfo1.Geoc                = false;
     datum1.DatumType           = DotSpatial.Projections.DatumType.WGS84;
     datum1.Description         = "WGS 1984";
     datum1.NadGrids            = null;
     datum1.Name                = "D_WGS_1984";
     spheroid1.Code             = "WE";
     spheroid1.EquatorialRadius = 6378137D;
     spheroid1.KnownEllipsoid   = DotSpatial.Projections.Proj4Ellipsoid.WGS_1984;
     spheroid1.Name             = "WGS_1984";
     spheroid1.PolarRadius      = 6356752.3142451793D;
     datum1.Spheroid            = spheroid1;
     datum1.ToWGS84             = new double[] {
         0D,
         0D,
         0D
     };
     geographicInfo1.Datum            = datum1;
     meridian1.Code                   = 0;
     meridian1.Longitude              = 0D;
     meridian1.Name                   = "Greenwich";
     geographicInfo1.Meridian         = meridian1;
     geographicInfo1.Name             = "GCS_WGS_1984";
     angularUnit1.Name                = "Degree";
     angularUnit1.Radians             = 0.017453292519943295D;
     geographicInfo1.Unit             = angularUnit1;
     projectionInfo1.GeographicInfo   = geographicInfo1;
     projectionInfo1.IsGeocentric     = false;
     projectionInfo1.IsLatLon         = true;
     projectionInfo1.IsSouth          = false;
     projectionInfo1.LatitudeOfOrigin = null;
     projectionInfo1.Name             = null;
     projectionInfo1.NoDefs           = true;
     projectionInfo1.Over             = false;
     //projectionInfo1.Parameters = ((System.Collections.Generic.Dictionary<string, string>)(resources.GetObject("projectionInfo1.Parameters")));
     projectionInfo1.ScaleFactor       = 1D;
     projectionInfo1.StandardParallel1 = null;
     projectionInfo1.StandardParallel2 = null;
     //projectionInfo1.Transform = longLat1;
     linearUnit1.Meters              = 1D;
     linearUnit1.Name                = "Meter";
     projectionInfo1.Unit            = linearUnit1;
     projectionInfo1.Zone            = null;
     this.HelpTopicId                = "Maps_Configuration";
     this.mapControl.MapSpatRef      = projectionInfo1;
     this.mapControl.MapTitle        = null;
     this.mapControl.MinimumSize     = new System.Drawing.Size(300, 200);
     this.mapControl.Name            = "mapControl";
     this.mapControl.ScaleBarVisible = true;
     this.mapControl.Size            = new System.Drawing.Size(665, 430);
     this.mapControl.TabIndex        = 0;
     //
     // CustomizeMapForm
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.Size = new System.Drawing.Size(1024, 768);
     //this.WindowState = FormWindowState.Maximized;
     this.Controls.Add(this.mapControl);
     this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.Name = "CustomizeMapForm";
     this.Text = Resources.gis_CustomizeMapForm_Caption;
     this.ResumeLayout(false);
     this.StartPosition = FormStartPosition.CenterScreen;
     this.mapControl.RefreshMap();
     this.WindowState = FormWindowState.Maximized;
 }
Exemple #16
0
 public void Reproject(DotSpatial.Projections.ProjectionInfo targetProjection)
 {
     //throw new NotImplementedException();
 }
Exemple #17
0
        public static double ProjectedDistanceBetweenPlaces(Wgs84Coordinates a, Wgs84Coordinates b)
        {
            Wgs84Coordinates[] mycoordinates = new Wgs84Coordinates[] { a, b };

            DotSpatial.Projections.ProjectionInfo projFrom = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
            DotSpatial.Projections.ProjectionInfo projTo   = DotSpatial.Projections.KnownCoordinateSystems.Projected.World.CylindricalEqualAreaworld;
            projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.World.EquidistantConicworld;
            // projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.World.EquidistantCylindricalworld;

            // projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.World.WebMercator;
            projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.WorldSpheroid.Mercatorsphere;
            projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.WorldSpheroid.EckertVsphere; // Exception
            projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.WorldSpheroid.MillerCylindricalsphere;
            projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.WorldSpheroid.EquidistantCylindricalsphere;
            // projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.WorldSpheroid.EquidistantConicsphere;
            projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.SpheroidBased.Lambert2;
            // projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.SpheroidBased.Lambert2Wide;
            // projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.WorldSpheroid.EckertIVsphere;
            // projTo = DotSpatial.Projections.KnownCoordinateSystems.Projected.Europe.EuropeEquidistantConic;

            double[] latLonPoints = new double[mycoordinates.Length * 2];
            double[] z            = new double[mycoordinates.Length];

            // dotspatial takes the x,y in a single array, and z in a separate array.  I'm sure there's a
            // reason for this, but I don't know what it is.
            for (int i = 0; i < mycoordinates.Length; i++)
            {
                latLonPoints[i * 2]     = (double)mycoordinates[i].Longitude;
                latLonPoints[i * 2 + 1] = (double)mycoordinates[i].Latitude;
                z[i] = 0;
            } // Next i

            // prepare for ReprojectPoints (it's mutate array)
            DotSpatial.Projections.Reproject.ReprojectPoints(
                latLonPoints, z, projFrom, projTo
                , 0, latLonPoints.Length / 2
                );

            // assemblying new points array to create polygon
            GeoAPI.Geometries.Coordinate[] polyPoints = new GeoAPI.Geometries.Coordinate[latLonPoints.Length / 2];

            for (int i = 0; i < latLonPoints.Length / 2; ++i)
            {
                polyPoints[i] = new GeoAPI.Geometries.Coordinate(latLonPoints[i * 2], latLonPoints[i * 2 + 1]);
            } // Next i

            // Assembling linear ring to create polygon
            // NetTopologySuite.Geometries.LinearRing lr = new NetTopologySuite.Geometries.LinearRing(polyPoints);

            var line = new NetTopologySuite.Geometries.LineString(polyPoints);

            // var line = new NetTopologySuite.Geometries.LineSegment(polyPoints[0], polyPoints[1]);
            line.SRID = 4326;


            GeoAPI.Geometries.Coordinate[] unprojPoints = new GeoAPI.Geometries.Coordinate[]
            {
                new GeoAPI.Geometries.Coordinate((double)a.Latitude, (double)a.Longitude, 0),
                new GeoAPI.Geometries.Coordinate((double)b.Latitude, (double)b.Longitude, 0)
            };
            var unprojline = new NetTopologySuite.Geometries.LineString(unprojPoints);

            unprojline.SRID = 4326;

            System.Console.WriteLine(unprojline.Length);

            double dist = polyPoints[0].Distance(polyPoints[1]);

            System.Console.WriteLine(dist);

            // SELECT geography::Point(47.552063, 9.226081, 4326).STDistance(geography::Point(47.374487, 9.556946, 4326))
            // 31813.1626618977

            return(line.Length);
        }