A coordinate system based on latitude and longitude.
Some geographic coordinate systems are Lat/Lon, and some are Lon/Lat. You can find out which this is by examining the axes. You should also check the angular units, since not all geographic coordinate systems use degrees.
Inheritance: HorizontalCoordinateSystem, IGeographicCoordinateSystem
示例#1
0
        public IGeographicCoordinateSystem CreateGeographicCoordinateSystem(int gcsType)
        {
            IGeographicCoordinateSystem gcs = null;

            switch (gcsType)
            {
            case (int)RgSRGeoCSType.RgSRGeoCS_WGS1984:    // WGS 1984.
                List <AxisInfo> axes = new List <AxisInfo>(2);
                axes.Add(new AxisInfo("Lon", AxisOrientationEnum.East));
                axes.Add(new AxisInfo("Lat", AxisOrientationEnum.North));
                IHorizontalDatum datum = this.CreateDatum((int)RgSRDatumType.RgSRDatum_WGS1984);
                gcs = new GeographicCoordinateSystem(CoordinateSystems.AngularUnit.Degrees,
                                                     datum, CoordinateSystems.PrimeMeridian.Greenwich, axes,
                                                     "WGS1984", "EPSG", 4326, String.Empty, string.Empty, string.Empty);
                break;

            case (int)RgSRGeoCSType.RgSRGeoCS_Beijing1954:
                List <AxisInfo> axes2 = new List <AxisInfo>(2);
                axes2.Add(new AxisInfo("Lon", AxisOrientationEnum.East));
                axes2.Add(new AxisInfo("Lat", AxisOrientationEnum.North));
                IHorizontalDatum datum2 = this.CreateDatum((int)RgSRDatumType.RgSRDatum_Beijing1954);
                gcs = new GeographicCoordinateSystem(CoordinateSystems.AngularUnit.Degrees,
                                                     datum2, CoordinateSystems.PrimeMeridian.Greenwich, axes2,
                                                     "Beijing1954", "EPSG", 4214, String.Empty, string.Empty, string.Empty);
                break;

            case (int)RgSRGeoCS3Type.RgSRGeoCS_Xian1980:    //Xian80.
                List <AxisInfo> axes3 = new List <AxisInfo>(2);
                axes3.Add(new AxisInfo("Lon", AxisOrientationEnum.East));
                axes3.Add(new AxisInfo("Lat", AxisOrientationEnum.North));
                IHorizontalDatum datum3 = this.CreateDatum((int)RgSRDatumType.RgSRDatum_Xian1980);
                gcs = new GeographicCoordinateSystem(CoordinateSystems.AngularUnit.Degrees,
                                                     datum3, CoordinateSystems.PrimeMeridian.Greenwich, axes3,
                                                     "Xian1980", "EPSG", 4610, String.Empty, string.Empty, string.Empty);
                break;
            }
            return(gcs);
        }
示例#2
0
        /// <summary>
        /// Creates a <see cref="ProjectedCoordinateSystem"/> using a projection object.
        /// </summary>
        /// <param name="name">Name of projected coordinate system</param>
        /// <param name="gcs">Geographic coordinate system</param>
        /// <param name="projection">Projection</param>
        /// <param name="linearUnit">Linear unit</param>
        /// <param name="axis0">Primary axis</param>
        /// <param name="axis1">Secondary axis</param>
        /// <returns>Projected coordinate system</returns>
        public ProjectedCoordinateSystem CreateProjectedCoordinateSystem(string name, GeographicCoordinateSystem gcs, IProjection projection, LinearUnit linearUnit, AxisInfo axis0, AxisInfo axis1)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException("Invalid name", nameof(name));
            }
            if (gcs == null)
            {
                throw new ArgumentException("Geographic coordinate system was null", nameof(gcs));
            }
            if (projection == null)
            {
                throw new ArgumentException("Projection was null", nameof(projection));
            }
            if (linearUnit == null)
            {
                throw new ArgumentException("Linear unit was null");
            }

            var info = new List <AxisInfo>(2);

            info.Add(axis0);
            info.Add(axis1);
            return(new ProjectedCoordinateSystem(null, gcs, linearUnit, projection, info, name, string.Empty, -1, string.Empty, string.Empty, string.Empty));
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="tokenizer"></param>
		/// <returns></returns>
		private static IGeographicCoordinateSystem ReadGeographicCoordinateSystem(WktStreamTokenizer tokenizer)
		{
			/*
			GEOGCS["OSGB 1936",
			DATUM["OSGB 1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6277"]]
			PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]]
			AXIS["Geodetic latitude","NORTH"]
			AXIS["Geodetic longitude","EAST"]
			AUTHORITY["EPSG","4277"]
			]
			*/
			tokenizer.ReadToken("[");
			string name = tokenizer.ReadDoubleQuotedWord();
			tokenizer.ReadToken(",");
			tokenizer.ReadToken("DATUM");
			IHorizontalDatum horizontalDatum = ReadHorizontalDatum(tokenizer);
			tokenizer.ReadToken(",");
			tokenizer.ReadToken("PRIMEM");
			IPrimeMeridian primeMeridian = ReadPrimeMeridian(tokenizer);
			tokenizer.ReadToken(",");
			tokenizer.ReadToken("UNIT");
			IAngularUnit angularUnit = ReadAngularUnit(tokenizer);

			string authority = String.Empty;
			long authorityCode = -1;
			tokenizer.NextToken();
			List<AxisInfo> info = new List<AxisInfo>(2);
			if (tokenizer.GetStringValue() == ",")
			{
				tokenizer.NextToken();
				while (tokenizer.GetStringValue() == "AXIS")
				{
					info.Add(ReadAxis(tokenizer));
					tokenizer.NextToken();
					if (tokenizer.GetStringValue() == ",") tokenizer.NextToken();
				}
				if (tokenizer.GetStringValue() == ",") tokenizer.NextToken();
				if (tokenizer.GetStringValue() == "AUTHORITY")
				{
					tokenizer.ReadAuthority(ref authority, ref authorityCode);
					tokenizer.ReadToken("]");
				}
			}
			//This is default axis values if not specified.
			if (info.Count == 0)
			{
				info.Add(new AxisInfo("Lon", AxisOrientationEnum.East));
				info.Add(new AxisInfo("Lat", AxisOrientationEnum.North));
			}
			IGeographicCoordinateSystem geographicCS = new GeographicCoordinateSystem(angularUnit, horizontalDatum,
					primeMeridian, info, name, authority, authorityCode, String.Empty, String.Empty, String.Empty);
			return geographicCS;
		}
示例#4
0
        public void DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                info.InfoText = "Calculating";
                info.OnPropertyChanged("InfoText");
                info.CanImport = false;
                info.OnPropertyChanged("CanImport");

                IQueryable <Data.Node> nodeQuery = (from n in DataContext.Nodes
                                                    select n);


                #region Limit query
                if (info.EastingsMin.HasValue)
                {
                    nodeQuery = (from n in nodeQuery
                                 where n.Easting > info.EastingsMin
                                 select n);
                }

                if (info.EastingsMax.HasValue)
                {
                    nodeQuery = (from n in nodeQuery
                                 where n.Easting < info.EastingsMax
                                 select n);
                }

                if (info.NorthingsMin.HasValue)
                {
                    nodeQuery = (from n in nodeQuery
                                 where n.Northing > info.NorthingsMin
                                 select n);
                }

                if (info.NorthingsMax.HasValue)
                {
                    nodeQuery = (from n in nodeQuery
                                 where n.Northing < info.NorthingsMax
                                 select n);
                }
                #endregion

                IQueryable <Data.Link> linkQuery = (from l in DataContext.Links
                                                    from n in nodeQuery
                                                    where l.ANode == n.ID || l.BNode == n.ID
                                                    select l).Distinct();

                int nodeNo = nodeQuery.Count();
                int linkNo = linkQuery.Count();
                info.MaxRecords = nodeNo + linkNo;
                info.InfoText   = "Nodes: " + nodeNo + ", Links: " + linkNo + Environment.NewLine;
                info.OnPropertyChanged("MaxRecords");
                info.OnPropertyChanged("InfoText");

                Model = new TransportModel.Model.Model();

                info.InfoText += "Loading nodes" + Environment.NewLine;
                info.OnPropertyChanged("InfoText");

                foreach (Data.Node n in nodeQuery)
                {
                    if (CheckForCancellation(this.worker, e))
                    {
                        return;
                    }
                    Mem.Node memNode = new TransportModel.Model.Node(n.ID, n.Easting, n.Northing);
                    Model.AllNodes.Add(n.ID, memNode);

                    info.RecordNumber++;
                    info.OnPropertyChanged("RecordNumber");
                }

                info.InfoText += "Loading links" + Environment.NewLine;
                info.OnPropertyChanged("InfoText");

                foreach (Data.Link l in linkQuery)
                {
                    if (CheckForCancellation(this.worker, e))
                    {
                        return;
                    }
                    Mem.Link link = new TransportModel.Model.Link(l.ID, l.Length, l.Attributes, l.Polyline);

                    if (l.ANode.HasValue && Model.AllNodes.ContainsKey(l.ANode.Value))
                    {
                        link.StartNode = Model.AllNodes[l.ANode.Value];
                        if (link.StartNode != null)
                        {
                            link.StartNode.Links.Add(link);
                        }
                    }

                    if (l.BNode.HasValue && Model.AllNodes.ContainsKey(l.BNode.Value))
                    {
                        link.EndNode = Model.AllNodes[l.BNode.Value];
                        if (link.EndNode != null)
                        {
                            link.EndNode.Links.Add(link);
                        }
                    }

                    if (!Model.AllLinks.ContainsKey(l.ID))
                    {
                        Model.AllLinks.Add(l.ID, link);
                    }
                    else
                    {
                        info.InfoText += "Link id " + l.ID + " already used" + Environment.NewLine;
                        info.OnPropertyChanged("InfoText");
                    }

                    info.RecordNumber++;
                    info.OnPropertyChanged("RecordNumber");
                }

                info.InfoText += "Linking links" + Environment.NewLine;
                info.OnPropertyChanged("InfoText");

                ProjNet.CoordinateSystems.GeographicCoordinateSystem a = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84;

                foreach (Mem.Link lnk in Model.AllLinks.Values)
                {
                    LinkNodeLinks(lnk, lnk.StartNode);
                    LinkNodeLinks(lnk, lnk.EndNode);
                }

                info.InfoText += "Getting attributes" + Environment.NewLine;
                info.OnPropertyChanged("InfoText");

                List <Mem.Attribute> allAttributes = (from attr in DataContext.AttributeLists
                                                      select new Mem.Attribute(attr.name, attr.value, attr.node, attr.arrayindex, attr.ATOB_mask, attr.BTOA_mask)).ToList();

                Model.Attributes = allAttributes;

                info.InfoText += "Done" + Environment.NewLine;
                info.OnPropertyChanged("InfoText");
            }
            catch (Exception ex)
            {
                info.InfoText += "Problem!!!!!!!" + Environment.NewLine + ex.ToString() + Environment.NewLine + ex.StackTrace;
                info.OnPropertyChanged("InfoText");
            }
        }