예제 #1
0
 public void Close()
 {
     doc.Close(false);
     app.Quit();
     doc = null;
     drw = null;
     app = null;
 }
예제 #2
0
 public void Close()
 {
     doc.Close(false);
     app.Quit();
     doc = null;
     drw = null;
     app = null;
 }
예제 #3
0
        public void ImportKmlImageTest()
        {
            Generator g             = new Generator();
            Int32     counterBefore = g.Document.ComponentSet.Count;

            Manifold.Interop.Document doc = g.Document;
            kml.Import(doc);
            Int32 counterAfter = g.Document.ComponentSet.Count;

            Assert.AreEqual(counterBefore + 1, counterAfter);
        }
예제 #4
0
        public void ImportKmlImageTestSoWeCanFindIt()
        {
            Generator g             = new Generator(@"C:\temp\TestMap.map");
            Int32     counterBefore = g.Document.ComponentSet.Count;

            Manifold.Interop.Document doc = g.Document;
            kml.Import(doc);
            Int32 counterAfter = g.Document.ComponentSet.Count;

            Assert.AreEqual(counterBefore + 1, counterAfter);
            doc.Save();
        }
예제 #5
0
 public Generator(String MapFile)
 {
     app = new m.Application();
     doc = app.NewDocument(MapFile, false);
 }
예제 #6
0
 public Generator(String MapFile, String Drawing)
 {
     app = new m.Application();
     doc = app.NewDocument(MapFile, false);
     drw = (m.Drawing)doc.ComponentSet[Drawing];
 }
예제 #7
0
 public Generator()
 {
     app = new m.Application();
     doc = app.NewDocument(null, false);
     drw = doc.NewDrawing(Guid.NewGuid().ToString(), app.DefaultCoordinateSystem, false);
 }
예제 #8
0
 public Generator(String MapFile)
 {
     app = new m.Application();
     doc = app.NewDocument(MapFile, false);
 }
예제 #9
0
 public Generator(String MapFile, String Drawing)
 {
     app = new m.Application();
     doc = app.NewDocument(MapFile, false);
     drw = (m.Drawing)doc.ComponentSet[Drawing];
 }
예제 #10
0
 public Generator()
 {
     app = new m.Application();
     doc = app.NewDocument(null, false);
     drw = doc.NewDrawing(Guid.NewGuid().ToString(), app.DefaultCoordinateSystem, false);
 }
예제 #11
0
 void ev_AddinLoaded(object sender, DocumentEventArgs Args)
 {
     app   = Args.Document.Application;
     doc   = Args.Document;
     comps = doc.ComponentSet;
 }
예제 #12
0
        public void Import(M.Document document)
        {
            List <Int32> beforeIds = new List <Int32>();
            List <Int32> afterIds  = new List <Int32>();



            foreach (M.Component comp in document.ComponentSet)
            {
                beforeIds.Add(comp.ID);
            }


            if (this.ImageFileType() == ".jpg")
            {
                M.ImportJpeg importer = (M.ImportJpeg)document.NewImport("JPEG");
                importer.Import(ImageFileFullName(), M.ConvertPrompt.PromptNone, false);

                Int32 Id = 0;
                if (document.ComponentSet.Count == 1)
                {
                    Id = document.ComponentSet[0].ID;
                }
                else
                {
                    foreach (M.Component comp in document.ComponentSet)
                    {
                        afterIds.Add(comp.ID);
                    }



                    beforeIds.Sort();
                    afterIds.Sort();

                    Int32 i         = 0;
                    Int32 j         = 0;
                    bool  isnew     = false;
                    bool  matched   = false;
                    Int32 LastNewID = -1;
                    i     = document.ComponentSet.Count - 1;
                    isnew = false;
                    do
                    {
                        j       = beforeIds.Count - 1;
                        matched = false;
                        do
                        {
                            if (afterIds[i] == beforeIds[j])
                            {
                                matched = true;
                            }
                            else
                            {
                                j = j - 1;
                            }
                        }while (matched == false && j > 0);
                        if (matched == false)
                        {
                            isnew = true;
                        }
                        else
                        {
                            i = i - 1;
                        }
                    }while (isnew == false && i != -1);

                    if (isnew)
                    {
                        LastNewID = afterIds[i];
                    }

                    Id = LastNewID;
                }
                M.Image            img = (M.Image)document.ComponentSet[document.ComponentSet.ItemByID(Id)];
                M.CoordinateSystem coordinateSystem = document.Application.NewCoordinateSystem("Latitude / Longitude");
                M.Datum            datum            = document.Application.NewDatum("World Geodetic 1984 (WGS84) Auto");
                coordinateSystem.Datum = datum;

                coordinateSystem.Parameters["localOffsetX"].Value = BoundingBox().SouthWest.Lon;
                coordinateSystem.Parameters["localOffsetY"].Value = BoundingBox().SouthWest.Lat;
                coordinateSystem.Parameters["localScaleX"].Value  = Math.Abs((BoundingBox().SouthWest.Lon - BoundingBox().NorthEast.Lon) / img.Width);
                coordinateSystem.Parameters["localScaleY"].Value  = Math.Abs((BoundingBox().SouthWest.Lat - BoundingBox().NorthEast.Lat) / img.Height);
                img.CoordinateSystem = coordinateSystem;
                Console.WriteLine("Width " + img.Width.ToString());
                Console.WriteLine("Height " + img.Height.ToString());
                Console.WriteLine("X diff" + (this.BoundingBox().SouthWest.Lon - this.BoundingBox().NorthEast.Lon).ToString());
                Console.WriteLine("Y diff" + (this.BoundingBox().SouthWest.Lat - this.BoundingBox().NorthEast.Lat).ToString());

                //img.CoordinateSystem.Preset = "Latitude / Longitude";
            }
            else
            {
                throw new NotImplementedException("kml import only imports jpg image files at present");
            }
        }