public UndoableMapModel CreateFromHpi(string hpipath, string mappath, bool readOnly)
        {
            MapModel m;

            using (var hpi = new HpiArchive(hpipath))
            {
                var otaPath = HpiPath.ChangeExtension(mappath, ".ota");

                TdfNode n;

                var otaFileInfo   = hpi.FindFile(otaPath);
                var otaFileBuffer = new byte[otaFileInfo.Size];
                hpi.Extract(otaFileInfo, otaFileBuffer);
                using (var ota = new MemoryStream(otaFileBuffer))
                {
                    n = TdfNode.LoadTdf(ota);
                }

                var tntFileInfo   = hpi.FindFile(mappath);
                var tntFileBuffer = new byte[tntFileInfo.Size];
                hpi.Extract(tntFileInfo, tntFileBuffer);
                using (var s = new TntReader(new MemoryStream(tntFileBuffer)))
                {
                    m = this.mapModelFactory.FromTntAndOta(s, n);
                }
            }

            return(new UndoableMapModel(m, hpipath, readOnly));
        }
        public UndoableMapModel CreateFromTnt(string filename)
        {
            MapModel m;

            var otaFileName = filename.Substring(0, filename.Length - 4) + ".ota";

            if (File.Exists(otaFileName))
            {
                TdfNode attrs;
                using (var ota = File.OpenRead(otaFileName))
                {
                    attrs = TdfNode.LoadTdf(ota);
                }

                using (var s = new TntReader(filename))
                {
                    m = this.mapModelFactory.FromTntAndOta(s, attrs);
                }
            }
            else
            {
                using (var s = new TntReader(filename))
                {
                    m = this.mapModelFactory.FromTnt(s);
                }
            }

            return(new UndoableMapModel(m, filename, false));
        }