예제 #1
0
        public static void OCPfromAPI()
        {
            DataContainer.model.infrastructure.operationControlPoints.Clear();
            CoordinateSystemFactory c      = new CoordinateSystemFactory();
            StreamReader            stream = new StreamReader("C:/Users/Edwin/OneDrive/Afstuderen/Irish Grid Conversion/Irish Grid WTK.txt");
            string            wtk          = stream.ReadLine();
            ICoordinateSystem target       = c.CreateFromWkt(wtk);
            //ICoordinateSystem target = c.CreateFromWkt("PROJCS[\"TM65 / Irish Grid\", GEOGCS[\"TM65\", DATUM[\"TM65\", SPHEROID[\"Airy Modified 1849\",6377340.189,299.3249646, AUTHORITY[\"EPSG\",\"7002\"]],AUTHORITY[\"EPSG\",\"6299\"]], PRIMEM[\"Greenwich\",0,  AUTHORITY[\"EPSG\",\"8901\"]], UNIT[\"degree\",0.01745329251994328, AUTHORITY[\"EPSG\",\"9122\"]],  AUTHORITY[\"EPSG\",\"4299\"]], PROJECTION[\"Transverse_Mercator\"], PARAMETER[\"latitude_of_origin\",53.5], PARAMETER[\"central_meridian\",-8], PARAMETER[\"scale_factor\",1.000035],PARAMETER[\"false_easting\",200000], PARAMETER[\"false_northing\",250000], UNIT[\"metre\",1,  AUTHORITY[\"EPSG\",\"9001\"]], AUTHORITY[\"EPSG\",\"29902\"],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]");
            //ICoordinateSystem source = c.CreateFromWkt("GEOGCS[\"GCS_WGS_1984\", DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]], PRIMEM[\"Greenwich\",0], UNIT[\"Degree\",0.0174532925199433]]");
            ICoordinateSystem source = c.CreateFromWkt(stream.ReadLine());

            CoordinateTransformationFactory trf = new CoordinateTransformationFactory();
            ICoordinateTransformation       tr  = trf.CreateFromCoordinateSystems(source, target);
            //XDocument stationdoc = XDocument.Load("http://api.irishrail.ie/realtime/realtime.asmx/getAllStationsXML");
            XDocument  stationdoc = XDocument.Load("C:/Users/Edwin/OneDrive/Afstuderen/IrishRail Data/getAllStationsXML.xml");
            XNamespace ns         = stationdoc.Root.GetDefaultNamespace();

            foreach (XElement station in stationdoc.Root.Elements(ns + "objStation"))
            {
                eOcp tempocp = new eOcp();
                tempocp.id   = station.Element(ns + "StationId").Value.Trim();
                tempocp.name = station.Element(ns + "StationDesc").Value.Trim();
                tempocp.code = station.Element(ns + "StationCode").Value.Trim();
                tempocp.propOperational.operationalType = "station";
                double[] coord          = new double[] { double.Parse(station.Element(ns + "StationLongitude").Value, CultureInfo.InvariantCulture), double.Parse(station.Element(ns + "StationLatitude").Value, CultureInfo.InvariantCulture) };
                double[] irishgridcoord = tr.MathTransform.Transform(coord);
                tempocp.geoCoord.coord.Add(irishgridcoord[0]); tempocp.geoCoord.coord.Add(irishgridcoord[1]);

                AddOCPToTracks(tempocp);
                Data.DataContainer.model.infrastructure.operationControlPoints.Add(tempocp);
            }
        }
        private ICoordinateSystem CreateCoordinateSystem(string definition)
        {
            ICoordinateSystem cs = null;

            switch (definition)
            {
            case "EPSG:4326":
                cs = GeographicCoordinateSystem.WGS84;
                break;

            case "EPSG:3857":
                cs = ProjectedCoordinateSystem.WebMercator;
                break;
            }

            if (cs == null && definition.Contains(":"))
            {
                var parts = definition.Split(new[] { ':' }, 2);
                var wkt   = GetWellKnownText(parts[0], parts[1]);
                if (!string.IsNullOrEmpty(wkt))
                {
                    cs = _factory.CreateFromWkt(definition);
                }
            }

            if (cs == null)
            {
                cs = _factory.CreateFromWkt(definition);
            }

            return(cs);
        }
예제 #3
0
 override public FeatureList process(FeatureList input, FilterEnv env)
 {
     foreach (Feature feature in input)
     {
         CoordinateSystemFactory csf      = new CoordinateSystemFactory();
         ICoordinateSystem       cssource = csf.CreateFromWkt(((SharpMapSpatialReference)feature.getGeometry().SpatialReference).CoordinateSystem.WKT);
         ICoordinateSystem       cstarget;
         if (translateScript != null)
         {
             //Console.WriteLine(Registry.instance().GetEngine("Python").run(TranslateScript).asString());
             cstarget = csf.CreateFromWkt(Registry.instance().GetEngine("Python").run(TranslateScript).asString());
         }
         else
         {
             cstarget = csf.CreateFromWkt(env.getInputSRS().WKT);
         }
         CoordinateTransformationFactory ctf = new CoordinateTransformationFactory();
         ICoordinateTransformation       ct  = ctf.CreateFromCoordinateSystems(cssource, cstarget);
         //if (feature.getGeometry().GeometryType == GeometryType2.Point)
         //{
         //    Point p = (Point)feature.getGeometry();
         //GeometryTransform.TransformPoint(feature, ct.MathTransform);
         Geometry geom    = feature.getGeometry();
         Geometry geomRst = GeometryTransform.TransformGeometry(geom, ct.MathTransform);
         feature.setGeometry(geomRst);
         //}
     }
     return(input);
 }
예제 #4
0
        public static Coordinate[] Transform(Coordinate[] points, string sourceCoordinateSystemString, string targetCoordinateSystemString = "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.0174532925199433]]")
        {
            CoordinateSystemFactory   coordinateSystemFactory = new CoordinateSystemFactory();
            ICoordinateSystem         sourceCoordinateSystem  = coordinateSystemFactory.CreateFromWkt(sourceCoordinateSystemString);
            ICoordinateSystem         targetCoordinateSystem  = coordinateSystemFactory.CreateFromWkt(targetCoordinateSystemString);
            ICoordinateTransformation trans = (new CoordinateTransformationFactory()).CreateFromCoordinateSystems(sourceCoordinateSystem, targetCoordinateSystem);

            return(trans.MathTransform.TransformList(points).ToArray());
        }
예제 #5
0
        private static ICoordinateTransformation GetCoordinateTransformation()
        {
            //The SRS for this datasource is EPSG:4326, therefore we need to transfrom it to OSM projection
            CoordinateTransformationFactory ctf = new CoordinateTransformationFactory();
            CoordinateSystemFactory         cf  = new CoordinateSystemFactory();
            ICoordinateSystem epsg4326          = cf.CreateFromWkt("GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]");
            ICoordinateSystem epsg3857          = cf.CreateFromWkt("PROJCS[\"Popular Visualisation CRS / Mercator\", GEOGCS[\"Popular Visualisation CRS\", DATUM[\"Popular Visualisation Datum\", SPHEROID[\"Popular Visualisation Sphere\", 6378137, 0, AUTHORITY[\"EPSG\",\"7059\"]], TOWGS84[0, 0, 0, 0, 0, 0, 0], AUTHORITY[\"EPSG\",\"6055\"]],PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9102\"]], AXIS[\"E\", EAST], AXIS[\"N\", NORTH], AUTHORITY[\"EPSG\",\"4055\"]], PROJECTION[\"Mercator\"], PARAMETER[\"False_Easting\", 0], PARAMETER[\"False_Northing\", 0], PARAMETER[\"Central_Meridian\", 0], PARAMETER[\"Latitude_of_origin\", 0], UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], AXIS[\"East\", EAST], AXIS[\"North\", NORTH], AUTHORITY[\"EPSG\",\"3857\"]]");

            return(ctf.CreateFromCoordinateSystems(epsg4326, epsg3857));
예제 #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Transforma las coordenadas modelo de un archivo .abs.xml de un SRC a otro. No transforma el cálculo, solo las coordenadas modelo.");

            if (args.Length < 4)
            {
                Console.Error.WriteLine("Error: No has proporcionado los parámetros suficientes.");
                Console.Error.WriteLine("[ruta del archivo .prj con la cadena WKT de las coordenadas modelo originales del archivo .abs.xml.]");
                Console.Error.WriteLine("[ruta del archivo .prj con la cadena WKT de las coordenadas modelo destino del archivo .abs.xml.]");
                Console.Error.WriteLine("[ruta del archivo .abs.xml a transformar]");
                Console.Error.WriteLine("[ruta del archivo .abs.xml a generar con las coordenadas transformadas]");
                Console.Error.WriteLine("");
                Console.Error.WriteLine("Ejemplo:");
                Console.Error.WriteLine(@"TransformaCoordenadasModeloOriAbsoluta E:\Tickets\435\wgs84-16n.prj E:\Tickets\435\wgs84.prj E:\Tickets\435\a.abs.xml E:\Tickets\435\b.abs.xml");
                return;
            }
            var fábricaSrc     = new CoordinateSystemFactory();
            var srcOrigen      = fábricaSrc.CreateFromWkt(File.ReadAllText(args[0]));
            var srcDestino     = fábricaSrc.CreateFromWkt(File.ReadAllText(args[1]));
            var transformación = CoordinateTransformationFactory.CreateFromHorizontalCoordinateSystems(srcOrigen, srcDestino, null);

            var abs = new XmlDocument();

            abs.Load(args[2]);

            var nsManager = new XmlNamespaceManager(abs.NameTable);

            nsManager.AddNamespace("abs", "http://schemas.digi21.net/Digi3D/AbsoluteOrientation/v1.0");

            var coordenadasModelo = abs.SelectNodes("/abs:absolute/abs:points/abs:point/abs:model", nsManager);

            foreach (XmlNode coordenadaModelo in coordenadasModelo)
            {
                var nodoX = coordenadaModelo.SelectSingleNode("abs:x", nsManager);
                var nodoY = coordenadaModelo.SelectSingleNode("abs:y", nsManager);

                double[] coordenadasUtm =
                {
                    double.Parse(nodoX.InnerText, CultureInfo.InvariantCulture),
                    double.Parse(nodoY.InnerText, CultureInfo.InvariantCulture),
                };

                var coordenadasGeo = transformación.MathTransform.Transform(coordenadasUtm);

                var clonX = nodoX.Clone();
                clonX.InnerText = coordenadasGeo[0].ToString(CultureInfo.InvariantCulture);
                coordenadaModelo.ReplaceChild(clonX, nodoX);

                var clonY = nodoY.Clone();
                clonY.InnerText = coordenadasGeo[1].ToString(CultureInfo.InvariantCulture);
                coordenadaModelo.ReplaceChild(clonY, nodoY);
            }

            abs.Save(args[3]);
        }
예제 #7
0
        public Projections()
        {
            CoordinateSystemFactory c    = new CoordinateSystemFactory();
            ICoordinateSystem       osgb = c.CreateFromWkt("PROJCS[\"OSGB 1936 / British National Grid\",GEOGCS[\"OSGB 1936\",DATUM[\"OSGB_1936\",SPHEROID[\"Airy 1830\",6377563.396,299.3249646,AUTHORITY[\"EPSG\",\"7001\"]],AUTHORITY[\"EPSG\",\"6277\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4277\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",49],PARAMETER[\"central_meridian\",-2],PARAMETER[\"scale_factor\",0.9996012717],PARAMETER[\"false_easting\",400000],PARAMETER[\"false_northing\",-100000],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"27700\"]]");
            ICoordinateSystem       wgs  = c.CreateFromWkt("GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.0174532925199433]]");

            CoordinateTransformationFactory trf = new CoordinateTransformationFactory();

            this.OsgbToWgs = trf.CreateFromCoordinateSystems(osgb, wgs);
            this.WgsToOsgb = trf.CreateFromCoordinateSystems(wgs, osgb);
        }
예제 #8
0
        /// <summary>
        /// Static constructor to perform 1-time initialisation.
        /// </summary>
        static MapRenderer()
        {
            Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
            GeometryServiceProvider.Instance = new NtsGeometryServices();
            var coordFactory = new CoordinateSystemFactory(System.Text.Encoding.Unicode);
            var css          = new CoordinateSystemServices(coordFactory, new CoordinateTransformationFactory());

            css.AddCoordinateSystem(3857, coordFactory.CreateFromWkt("PROJCS[\"WGS 84 / Pseudo-Mercator\", GEOGCS[\"WGS 84\", DATUM[\"WGS_1984\", SPHEROID[\"WGS 84\", 6378137, 298.257223563, AUTHORITY[\"EPSG\", \"7030\"]], AUTHORITY[\"EPSG\", \"6326\"]], PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9122\"]], AUTHORITY[\"EPSG\", \"4326\"]], UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], PROJECTION[\"Mercator_1SP\"], PARAMETER[\"latitude_of_origin\", 0], PARAMETER[\"central_meridian\", 0], PARAMETER[\"scale_factor\", 1], PARAMETER[\"false_easting\", 0], PARAMETER[\"false_northing\", 0], AUTHORITY[\"EPSG\", \"3857\"]]"));
            css.AddCoordinateSystem(4326, coordFactory.CreateFromWkt("GEOGCS[\"WGS 84\", DATUM[\"WGS_1984\", SPHEROID[\"WGS 84\", 6378137, 298.257223563, AUTHORITY[\"EPSG\", \"7030\"]], AUTHORITY[\"EPSG\", \"6326\"]], PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9122\"]], AUTHORITY[\"EPSG\", \"4326\"]]"));
            Session.Instance.SetGeometryServices(GeoAPI.GeometryServiceProvider.Instance)
            .SetCoordinateSystemServices(css)
            .SetCoordinateSystemRepository(css);
        }
AUTHORITY[""EPSG"",""3785""]]"; //NOXLATE

        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultSimpleTransform"/> class.
        /// </summary>
        /// <param name="sourceCsWkt">The source cs WKT.</param>
        /// <param name="targetCsWkt">The target cs WKT.</param>
        internal DefaultSimpleTransform(string sourceCsWkt, string targetCsWkt)
        {
            //Check for and replace the WGS84.PseudoMercator WKT
            string srcWkt = sourceCsWkt == CSMAP_WGS84_PSEUDO_MERCATOR ? POPULAR_VISUALISATION_CRS : sourceCsWkt;
            string dstWkt = targetCsWkt == CSMAP_WGS84_PSEUDO_MERCATOR ? POPULAR_VISUALISATION_CRS : targetCsWkt;
            var    fact   = new CoordinateSystemFactory();

            _source = fact.CreateFromWkt(srcWkt);
            _target = fact.CreateFromWkt(dstWkt);
            var tfact = new CoordinateTransformationFactory();

            _trans = tfact.CreateFromCoordinateSystems(_source, _target);
        }
예제 #10
0
        public ImportWorker(ref ImportPageViewModel infoRef, BackgroundWorker bgWorker, RoadNetworkDataContext dc)
        {
            info        = infoRef;
            worker      = bgWorker;
            DataContext = dc;

            CoordinateSystemFactory         c      = new CoordinateSystemFactory();
            ICoordinateSystem               source = c.CreateFromWkt("PROJCS[\"OSGB 1936 / British National Grid\",GEOGCS[\"OSGB 1936\",DATUM[\"OSGB_1936\",SPHEROID[\"Airy 1830\",6377563.396,299.3249646,AUTHORITY[\"EPSG\",\"7001\"]],AUTHORITY[\"EPSG\",\"6277\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4277\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",49],PARAMETER[\"central_meridian\",-2],PARAMETER[\"scale_factor\",0.9996012717],PARAMETER[\"false_easting\",400000],PARAMETER[\"false_northing\",-100000],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"27700\"]]");
            ICoordinateSystem               target = c.CreateFromWkt("GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.0174532925199433]]");
            CoordinateTransformationFactory trf    = new CoordinateTransformationFactory();

            OsgbToWgs = trf.CreateFromCoordinateSystems(source, target);
        }
예제 #11
0
        /// <summary>
        /// Obtem as projeções de transformações a partir dos wkid de entra e saida
        /// </summary>
        /// <param name="wkidSource">wkid de entrada</param>
        /// <param name="wkidTarget">wkid de saida</param>
        /// <returns></returns>
        private async Task <ICoordinateTransformation> GetTransformation(int wkidSource, int wkidTarget)
        {
            var source = SRID.GetProjcs(wkidSource);
            var target = SRID.GetProjcs(wkidTarget);

            var csFact = new CoordinateSystemFactory();
            var ctFact = new CoordinateTransformationFactory();

            var utmSource = csFact.CreateFromWkt(await source);
            var utmTarget = csFact.CreateFromWkt(await target);

            return(ctFact.CreateFromCoordinateSystems(utmSource, utmTarget));
        }
예제 #12
0
        //获取shp投影方式
        public ICoordinateTransformation getmapTransform(config.ProjPara proj)
        {
            CoordinateTransformationFactory ctFac     = new CoordinateTransformationFactory();
            CoordinateSystemFactory         cFac      = new CoordinateSystemFactory();
            ICoordinateTransformation       transform = null;

            //等经纬,shp数据原始投影
            var epsg4326 = cFac.CreateFromWkt("GEOGCS[\"GCS_WGS_1984\",DATUM[\"WGS_1984\",SPHEROID[\"WGS_84\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]");
            //目标坐标系
            var epsg3857 = cFac.CreateFromWkt(getSrcCoordinate(proj));

            transform = ctFac.CreateFromCoordinateSystems(epsg4326, epsg3857);

            return(transform);
        }
예제 #13
0
        public void TestTransformListOfDoubleArray()
        {
            var csFact = new CoordinateSystemFactory();
            var ctFact = new CoordinateTransformationFactory();

            var utm35ETRS = csFact.CreateFromWkt(
                "PROJCS[\"ETRS89 / ETRS-TM35\",GEOGCS[\"ETRS89\",DATUM[\"D_ETRS_1989\",SPHEROID[\"GRS_1980\",6378137,298.257222101]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",27],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1]]");

            var utm33 = ProjectedCoordinateSystem.WGS84_UTM(33, true);

            var trans = ctFact.CreateFromCoordinateSystems(utm35ETRS, utm33);

            var points = new List <double[]>
            {
                new[] { 290586.087, 6714000 }, new[] { 90586.392, 6713996.224 },
                new[] { 290590.133, 6713973.772 }, new[] { 290594.111, 6713957.416 },
                new[] { 290596.615, 6713943.567 }, new[] { 290596.701, 6713939.485 }
            };

            var tpoints = trans.MathTransform.TransformList(points).ToArray();

            for (var i = 0; i < points.Count; i++)
            {
                Assert.IsTrue(Equal(tpoints[i], trans.MathTransform.Transform(points[i])));
            }
        }
예제 #14
0
        public ActionResult <IEnumerable <string> > Get()
        {
            try
            {
                CoordinateSystemFactory         csFact = new CoordinateSystemFactory();
                CoordinateTransformationFactory ctFact = new CoordinateTransformationFactory();

                ICoordinateSystem utm35ETRS = csFact.CreateFromWkt(
                    "PROJCS[\"ETRS89 / ETRS-TM35\",GEOGCS[\"ETRS89\",DATUM[\"D_ETRS_1989\",SPHEROID[\"GRS_1980\",6378137,298.257222101]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",27],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1]]");

                IProjectedCoordinateSystem utm33 = ProjectedCoordinateSystem.WGS84_UTM(33, true);

                ICoordinateTransformation trans = ctFact.CreateFromCoordinateSystems(utm35ETRS, utm33);

                Coordinate[] points = new Coordinate[]
                {
                    new Coordinate(290586.087, 6714000), new Coordinate(290586.392, 6713996.224),
                    new Coordinate(290590.133, 6713973.772), new Coordinate(290594.111, 6713957.416),
                    new Coordinate(290596.615, 6713943.567), new Coordinate(290596.701, 6713939.485)
                };

                Coordinate[] tpoints = trans.MathTransform.TransformList(points).ToArray();
            }
            catch (Exception)
            {
                throw;
            }



            return(new string[] { "value1", "value2" });
        }
예제 #15
0
        public void TestTransformSequence()
        {
            var csFact = new CoordinateSystemFactory();
            var ctFact = new CoordinateTransformationFactory();

            var utm35ETRS = csFact.CreateFromWkt(
                "PROJCS[\"ETRS89 / ETRS-TM35\",GEOGCS[\"ETRS89\",DATUM[\"D_ETRS_1989\",SPHEROID[\"GRS_1980\",6378137,298.257222101]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",27],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1]]");

            var utm33 = ProjectedCoordinateSystem.WGS84_UTM(33, true);

            var trans = ctFact.CreateFromCoordinateSystems(utm35ETRS, utm33);

            var points = new NetTopologySuite.Geometries.Implementation.CoordinateArraySequence(
                new []
            {
                new Coordinate(290586.087, 6714000), new Coordinate(290586.392, 6713996.224),
                new Coordinate(290590.133, 6713973.772), new Coordinate(290594.111, 6713957.416),
                new Coordinate(290596.615, 6713943.567), new Coordinate(290596.701, 6713939.485)
            });

            var tpoints = trans.MathTransform.Transform(points);

            for (var i = 0; i < points.Count; i++)
            {
                Assert.AreEqual(trans.MathTransform.Transform(points.GetCoordinate(i)), tpoints.GetCoordinate(i));
            }
        }
예제 #16
0
        public CoordinateConverter(string _projection)
        {
            try
            {
                CoordinateSystemFactory csFactory = new CoordinateSystemFactory();
                CoordinateSystem = csFactory.CreateFromWkt(_projection);

                CoordinateTransformationFactory ctFactory = new CoordinateTransformationFactory();

                XYToLonLatTransform = ctFactory.CreateFromCoordinateSystems(CoordinateSystem, WGS84).MathTransform;
                LonLatToXYTransform = ctFactory.CreateFromCoordinateSystems(WGS84, CoordinateSystem).MathTransform;

                XYToWebTransform = ctFactory.CreateFromCoordinateSystems(CoordinateSystem, WebMercator).MathTransform;
                WebToXYTransform = ctFactory.CreateFromCoordinateSystems(WebMercator, CoordinateSystem).MathTransform;
            } catch (Exception ex)
            {
                if (_projection.ToLowerInvariant().Contains("web_mercator"))
                {
                    CoordinateTransformationFactory ctFactory = new CoordinateTransformationFactory();
                    LonLatToXYTransform = ctFactory.CreateFromCoordinateSystems(WGS84, WebMercator).MathTransform;
                    XYToLonLatTransform = LonLatToXYTransform.Inverse();
                }
                else
                {
                    throw ex;
                }
            }
        }
예제 #17
0
        private void botonConectar_Click(object sender, EventArgs e)
        {
            if (gps.EsConectado)
            {
                gps.Stop();
                botonConectar.Text = "Conectar";
            }
            else
            {
                try
                {
                    var coordinateSystemFactory         = new CoordinateSystemFactory();
                    var coordinateTransformationFactory = new CoordinateTransformationFactory();

                    transformación = coordinateTransformationFactory.CreateFrom3DCoordinateSystems(
                        CoordinateSystemAuthorityFactory.CreateGeographicCoordinateSystem(4979),
                        coordinateSystemFactory.CreateFromWkt(Digi21.DigiNG.DigiNG.Wkt),
                        SelectTransformationHelper.DialogSelectTransformation,
                        CreateVerticalTransformationHelper.DialogCreateVerticalTransformation);
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"Se detectó el error: {ex.Message} al intentar crear una transformación entre el sistema de referencia de coordenadas del GPS y el de la ventana de dibujo");
                    return;
                }

                botonConectar.Enabled = false;
                gps.Start();
            }
        }
예제 #18
0
        public void TestAngularUnitsEqualParamsIssue()
        {
            //string sourceWkt = " UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]";

            string wkt = "PROJCS[\"DHDN / Gauss-Kruger zone 3\",GEOGCS[\"DHDN\",DATUM[\"Deutsches_Hauptdreiecksnetz\",SPHEROID[\"Bessel 1841\",6377397.155,299.1528128,AUTHORITY[\"EPSG\",\"7004\"]],AUTHORITY[\"EPSG\",\"6314\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4314\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",9],PARAMETER[\"scale_factor\",1],PARAMETER[\"false_easting\",3500000],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"31467\"]]";

            var pcs1 = CoordinateSystemFactory.CreateFromWkt(wkt) as ProjectedCoordinateSystem;

            Assert.NotNull(pcs1);
            Assert.NotNull(pcs1.GeographicCoordinateSystem);
            Assert.NotNull(pcs1.GeographicCoordinateSystem.AngularUnit);

            string savedWkt = pcs1.WKT;
            var    pcs2     = CoordinateSystemFactory.CreateFromWkt(savedWkt) as ProjectedCoordinateSystem;

            //test AngularUnit parsing via ProjectedCoordinateSystem
            Assert.NotNull(pcs2);
            Assert.NotNull(pcs2.GeographicCoordinateSystem);
            Assert.NotNull(pcs2.GeographicCoordinateSystem.AngularUnit);

            //check equality of angular units via RadiansPerUnit
            Assert.AreEqual(pcs1.GeographicCoordinateSystem.AngularUnit.RadiansPerUnit, pcs2.GeographicCoordinateSystem.AngularUnit.RadiansPerUnit, 0.0000000000001);
            //check equality of angular units
            Assert.AreEqual(true, pcs1.GeographicCoordinateSystem.AngularUnit.EqualParams(pcs2.GeographicCoordinateSystem.AngularUnit));
        }
예제 #19
0
        public void Test25832To3857()
        {
            const string wkt1 = //"PROJCS[\"ETRS89 / UTM zone 32N\",GEOGCS[\"ETRS89\",DATUM[\"European_Terrestrial_Reference_System_1989\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],AUTHORITY[\"EPSG\",\"6258\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4258\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",9],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"25832\"]]";
                                "PROJCS[\"ETRS89 / UTM zone 32N\",GEOGCS[\"ETRS89\",DATUM[\"European_Terrestrial_Reference_System_1989\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6258\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4258\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",9],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],AUTHORITY[\"EPSG\",\"25832\"],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]";

            CoordinateSystem cs1 = null, cs2 = null;

            Assert.DoesNotThrow(() => cs1 = CoordinateSystemFactory.CreateFromWkt(wkt1));
            Assert.IsNotNull(cs1);
            const string wkt2 = "PROJCS[\"WGS 84 / Pseudo-Mercator\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",                  SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"Mercator_1SP\"],PARAMETER[\"latitude_of_origin\", 0],PARAMETER[\"central_meridian\",0],PARAMETER[\"scale_factor\",1],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],EXTENSION[\"PROJ4\",\"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs\"],AUTHORITY[\"EPSG\",\"3857\"],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";

            Assert.DoesNotThrow(() => cs2 = CoordinateSystemFactory.CreateFromWkt(wkt2));
            Assert.IsNotNull(cs2);

            ICoordinateTransformation ct = null;

            Assert.DoesNotThrow(() => ct = CoordinateTransformationFactory.CreateFromCoordinateSystems(cs1, cs2));
            Assert.IsNotNull(ct);
            Assert.DoesNotThrow(() => ct = CoordinateTransformationFactory.CreateFromCoordinateSystems(cs2, cs1));
            Assert.IsNotNull(ct);
            Assert.DoesNotThrow(() => ct = CoordinateTransformationFactory.CreateFromCoordinateSystems(cs1, ProjectedCoordinateSystem.WebMercator));
            Assert.IsNotNull(ct);
            Assert.DoesNotThrow(() => ct = CoordinateTransformationFactory.CreateFromCoordinateSystems(ProjectedCoordinateSystem.WebMercator, cs1));
            Assert.IsNotNull(ct);
        }
예제 #20
0
파일: FormGISView.cs 프로젝트: jakedw7/iAM
        private IGeometry TransformGeo(IGeometry g)
        {
            Geometry geo = (Geometry)g;

#if DDOT
            string wkt = "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]]";
            CoordinateSystemFactory cFacWGS = new CoordinateSystemFactory();
            ICoordinateSystem       wgs84   = cFacWGS.CreateFromWkt(wkt);

            //
            // Acquire the state plane project from
            // http://spatialreference.org/
            //wkt = "PROJCS[\"NAD_1983_StatePlane_Maryland_FIPS_1900_Meter\",GEOGCS[\"GCS_North_American_1983\",DATUM[\"D_North_American_1983\",SPHEROID[\"GRS_1980\",6378137,298.257222101]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Lambert_Conformal_Conic\"],PARAMETER[\"False_Easting\",1312333.333333333],PARAMETER[\"False_Northing\",0],PARAMETER[\"Central_Meridian\",-77],PARAMETER[\"Standard_Parallel_1\",38.3],PARAMETER[\"Standard_Parallel_2\",39.45],PARAMETER[\"Latitude_Of_Origin\",37.66666666666666],UNIT[\"Foot_US\",0.30480060960121924]]";
            //wkt = "PROJCS["NAD_1983_StatePlane_Florida_West_FIPS_0902_Feet",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",656166.6666666665],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",-82],PARAMETER["Scale_Factor",0.9999411764705882],PARAMETER["Latitude_Of_Origin",24.33333333333333],UNIT["Foot_US",0.30480060960121924]]"
            wkt = "PROJCS[\"NAD_1983_StatePlane_Maryland_FIPS_1900_Meter\",GEOGCS[\"GCS_North_American_1983\",DATUM[\"D_North_American_1983\",SPHEROID[\"GRS_1980\",6378137,298.257222101]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Lambert_Conformal_Conic\"],PARAMETER[\"False_Easting\",399999.2],PARAMETER[\"False_Northing\",0],PARAMETER[\"Central_Meridian\",-77],PARAMETER[\"Standard_Parallel_1\",38.3],PARAMETER[\"Standard_Parallel_2\",39.45],PARAMETER[\"Latitude_Of_Origin\",37.66666666666666],UNIT[\"Meter\",1]]";
            //wkt = "PROJCS[\"GRS_1980_Transverse_Mercator\",GEOGCS[\"GCS_GRS_1980\",DATUM[\"D_GRS_1980\",SPHEROID[\"GRS_1980\",6378137,298.257222101]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"Scale_Factor\",1.00005000],PARAMETER[\"False_Easting\",164041.66666667],PARAMETER[\"False_Northing\",0],PARAMETER[\"Central_Meridian\",-96.68805556],PARAMETER[\"Latitude_Of_Origin\",40.25000000],UNIT[\"Foot_US\",0.30480060960121924]]";
            CoordinateSystemFactory cFac1 = new CoordinateSystemFactory();
            ICoordinateSystem       nad83 = cFac1.CreateFromWkt(wkt);


            CoordinateTransformationFactory ctFac      = new CoordinateTransformationFactory();
            ICoordinateTransformation       transDeg2M = ctFac.CreateFromCoordinateSystems(nad83, wgs84); //Geocentric->Geographic (WGS84)
            geo = GeometryTransform.TransformGeometry((Geometry)g, transDeg2M.MathTransform);
#endif
            return(geo);
        }
예제 #21
0
        public void TestGeocentricCoordinateSystem()
        {
            var fac = new CoordinateSystemFactory();
            GeocentricCoordinateSystem fcs = null;

            const string wkt = "GEOCCS[\"TUREF\", " +
                               "DATUM[\"Turkish_National_Reference_Frame\", " +
                               "SPHEROID[\"GRS 1980\", 6378137, 298.257222101, AUTHORITY[\"EPSG\", \"7019\"]], " +
                               "AUTHORITY[\"EPSG\", \"1057\"]], " +
                               "PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], " +
                               "UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], " +
                               "AXIS[\"Geocentric X\", OTHER], AXIS[\"Geocentric Y\", OTHER], AXIS[\"Geocentric Z\", NORTH], " +
                               "AUTHORITY[\"EPSG\", \"5250\"]]";

            try
            {
                fcs = fac.CreateFromWkt(wkt) as GeocentricCoordinateSystem;
            }
            catch (Exception ex)
            {
                Assert.Fail("Could not create geocentric coordinate system from:\r\n" + wkt + "\r\n" + ex.Message);
            }

            Assert.That(fcs, Is.Not.Null);
            Assert.That(CheckInfo(fcs, "TUREF", "EPSG", 5250L));
            Assert.That(CheckDatum(fcs.HorizontalDatum, "Turkish_National_Reference_Frame", "EPSG", 1057L), Is.True);
            Assert.That(CheckEllipsoid(fcs.HorizontalDatum.Ellipsoid, "GRS 1980", 6378137, 298.257222101, "EPSG", 7019), Is.True);
            Assert.That(CheckPrimem(fcs.PrimeMeridian, "Greenwich", 0, "EPSG", 8901L), Is.True);
            Assert.That(CheckUnit(fcs.PrimeMeridian.AngularUnit, "degree", null, null, null), Is.True);
            Assert.That(CheckUnit(fcs.LinearUnit, "metre", 1, "EPSG", 9001L), Is.True);

            Assert.That(fcs.Authority, Is.EqualTo("EPSG"));
            Assert.That(fcs.AuthorityCode, Is.EqualTo(5250L));
        }
예제 #22
0
        public static string GetProjectionName(string _projection)
        {
            CoordinateSystemFactory csFactory = new CoordinateSystemFactory();
            CoordinateSystem        system    = csFactory.CreateFromWkt(_projection);

            string output = string.Empty;

            if (!string.IsNullOrEmpty(system.Name))
            {
                output = system.Name;
            }
            else if (!string.IsNullOrEmpty(system.Abbreviation))
            {
                output = system.Abbreviation;
            }
            else if (!string.IsNullOrEmpty(system.Alias))
            {
                output = system.Alias;
            }
            else if (!string.IsNullOrEmpty(system.Authority))
            {
                output = string.Format("{0}:{1}", system.Authority, system.AuthorityCode);
            }
            return(output);
        }
예제 #23
0
    public static void Main()
    {
        //////Add this to class constructor
        NtsGeometryServices.Instance = new NtsGeometryServices(
            NetTopologySuite.Geometries.Implementation.CoordinateArraySequenceFactory.Instance,
            new NetTopologySuite.Geometries.PrecisionModel(1000d), 4326,
            // Note the following arguments are only valid for NTS v2.2
            // Geometry overlay operation function set to use (Legacy or NG)
            NetTopologySuite.Geometries.GeometryOverlay.NG,
            // Coordinate equality comparer to use (CoordinateEqualityComparer or PerOrdinateEqualityComparer)
            new NetTopologySuite.Geometries.CoordinateEqualityComparer());

        //Transform Projection
        //*****Add ProjNet to make transform
        //https://docs.microsoft.com/en-us/ef/core/modeling/spatial

        //2nd Way

        //Add WKT projection coordinate system
        const string            outputWKT = @"";
        CoordinateSystemFactory csFact    = new CoordinateSystemFactory();
        var csWgs84Text      = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84.WKT;
        var csWgs84          = csFact.CreateFromWkt(csWgs84Text);
        var outputProjection = csFact.CreateFromWkt(outputWKT);
        CoordinateTransformationFactory ctFact = new CoordinateTransformationFactory();
        ICoordinateTransformation       trans  = ctFact.CreateFromCoordinateSystems(csWgs84, outputProjection);
        var mt = trans.MathTransform;


        // Use the following website to look up the arguement below that should match outputProjection ESRG
        //http://epsg.io
        var gf = NtsGeometryServices.Instance.CreateGeometryFactory(XXXX);
        //////End of Class Constructor

        //IMPORTANT-ALL GEOMETRY POINTS MUST BE WRAPPED WITH mt.Transform()
        // Create a point at Aurich (lat=53.4837, long=7.5404)
        var pntAUR = gf.CreatePoint(mt.Transform(new NetTopologySuite.Geometries.Coordinate(7.5404, 53.4837)));
        // Create a point at Emden (lat=53.3646, long=7.1559)
        var pntLER = gf.CreatePoint(mt.Transform(new NetTopologySuite.Geometries.Coordinate(7.1559, 53.3646)));
        // Create a point at Leer (lat=53.2476, long=7.4550)
        var pntEMD = gf.CreatePoint(mt.Transform(new NetTopologySuite.Geometries.Coordinate(7.4550, 53.2476)));

        var distancepntAURpntLER = pntAUR.Distance(pntLER);

        Console.WriteLine($"{distancepntAURpntLER} miles");
    }
예제 #24
0
        public static ICoordinateSystem GetProjection(string shapeFilePath)
        {
            var projectionFilePath = Path.ChangeExtension(shapeFilePath, "prj");
            var projection         = File.ReadAllText(projectionFilePath);
            var cfac = new CoordinateSystemFactory();

            return(cfac.CreateFromWkt(projection));
        }
예제 #25
0
        public void TestCentralMeridianParse()
        {
            const string strSouthPole = "PROJCS[\"South_Pole_Lambert_Azimuthal_Equal_Area\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Lambert_Azimuthal_Equal_Area\"],PARAMETER[\"False_Easting\",0],PARAMETER[\"False_Northing\",0],PARAMETER[\"Central_Meridian\",-127],PARAMETER[\"Latitude_Of_Origin\",-90],UNIT[\"Meter\",1]]";

            var pCoordSysFactory = new CoordinateSystemFactory();
            var pSouthPole       = pCoordSysFactory.CreateFromWkt(strSouthPole);

            Assert.IsNotNull(pSouthPole);
        }
예제 #26
0
        /// <summary>
        /// Helper function for building a CoordinateSystemFactory using a file
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static ICoordinateSystem GetCoordinateSystemByWKTFile(string filename)
        {
            CoordinateSystemFactory csf = new CoordinateSystemFactory();

            if (File.Exists(filename))
            {
                return(csf.CreateFromWkt(File.ReadAllText(filename)));
            }
            else
            {
                string wkt = GetCoordinateSystemWKTByID(filename);
                if (!string.IsNullOrEmpty(wkt))
                {
                    return(csf.CreateFromWkt(wkt));
                }
            }

            return(null);
        }
예제 #27
0
 public static ICoordinateSystem GetProjection(ZipArchiveEntry projectionEntry)
 {
     using (var projectionStream = projectionEntry.Open())
         using (var stream = new StreamReader(projectionStream))
         {
             var projection = stream.ReadToEnd();
             var cfac       = new CoordinateSystemFactory();
             return(cfac.CreateFromWkt(projection));
         }
 }
예제 #28
0
        private void CreateCoordinateSystemFromWkt(string value)
        {
            if (CoordinateSystemFactory == null || string.IsNullOrEmpty(srsWkt))
            {
                CoordinateSystem = null;
                return;
            }

            CoordinateSystem = CoordinateSystemFactory.CreateFromWkt(value);
        }
        private const string XY_M = "LOCAL_CS[\"Non-Earth (Meter)\",LOCAL_DATUM[\"Local Datum\",0],UNIT[\"Meter\", 1],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]"; //NOXLATE

        internal ActualCoordinateSystem(ICoordinateSystem coordinateSystem)
        {
            if (coordinateSystem == null)
            {
                throw new ArgumentNullException(nameof(coordinateSystem)); //NOXLATE
            }
            CoordinateTransformationFactory f  = new CoordinateTransformationFactory();
            CoordinateSystemFactory         cf = new CoordinateSystemFactory();

            m_transform = f.CreateFromCoordinateSystems(coordinateSystem, cf.CreateFromWkt(XY_M));
        }
예제 #30
0
        public void WebMercatorCanBeTranformed(int srid)
        {
            var wkt = SharpMap.Converters.WellKnownText.SpatialReference.SridToWkt(srid);

            var csf = new CoordinateSystemFactory();
            var cs  = csf.CreateFromWkt(wkt);

            var ctf = new CoordinateTransformationFactory();

            Assert.DoesNotThrow(() => ctf.CreateFromCoordinateSystems(cs, GeographicCoordinateSystem.WGS84),
                                "Could not reproject SRID:" + srid);
        }
예제 #31
0
        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;

        }