Example #1
0
 public static CoordSys CreateCoordSys(
     CoordSysType type,
     Datum datum,
     /*double originLongitude,
     double originLatitude,
     double standardParallelOne,
     double standardParallelTwo,
     double azimuth,
     double scaleFactor,
     double falseEasting,
     double falseNorthing,
     double range,*/
     AffineTransform affineTransform)
 {
     CoordSys oCS = new CoordSys(type, datum, affineTransform);
     return oCS;
 }
Example #2
0
 internal CoordSys(CoordSysType type, Datum datum, AffineTransform affineTransform)
 {
     this.type = type;
     this.datum = datum;
     this.affineTransform = affineTransform;
 }
Example #3
0
        /// <summary>
        /// Load up items from map data file
        /// </summary>
        public bool Load(string mapFile)
        {
            try
            {
                Log.WriteLine($"LOAD: {mapFile}");

                MapFilePath = mapFile;
                Name        = Path.GetFileNameWithoutExtension(mapFile);
                MapCoordSys = CoordSysType.XZ_NorthWest;
                _items      = new List <MapItem>();
                MinLoc      = null;
                MaxLoc      = null;

                var lines = File.ReadLines(mapFile);

                const int maxNumItemsToLog = 3;

                foreach (var line in lines)
                {
                    var toks = line.Split(',');

                    float x = 0, y = 0, z = 0;

                    if ((toks.Length >= 2) &&
                        (string.Compare(toks[0].Trim(), "MapCoordSys", true) == 0))
                    {
                        CoordSysType tmp;
                        if (CoordSysType.TryParse(toks[1].Trim(), true, out tmp))
                        {
                            MapCoordSys = tmp;
                            Log.WriteLine("coord sys specified: " + MapCoordSys);
                        }
                    }
                    else if ((toks.Length >= 4) &&
                             (toks[0].Trim().Length > 0) &&
                             float.TryParse(toks[1].Trim(), out x) &&
                             float.TryParse(toks[2].Trim(), out y) &&
                             float.TryParse(toks[3].Trim(), out z))
                    {
                        var itemName = toks[0].Trim();

                        var mapItem = new MapItem(itemName, new MapCoord(x, y, z));
                        _items.Add(mapItem);

                        if (_items.Count <= maxNumItemsToLog)
                        {
                            Log.WriteLine($"loaded map item: {mapItem}");
                        }

                        if (_items.Count == (maxNumItemsToLog + 1))
                        {
                            Log.WriteLine("... remaining items not logged");
                        }
                    }
                }

                Log.WriteLine($"loaded {_items.Count} map items");

                ComputeMinMaxValues();
            }
            catch (Exception ex)
            {
                Log.WriteLine($"EXCEPTION: {ex.Message}");
                return(false);
            }

            return(true);
        }