GEOMAP Customization

GEOMAP Customization

Anonymous
Not applicable
843 Views
3 Replies
Message 1 of 4

GEOMAP Customization

Anonymous
Not applicable

Hello,

 

What I'm trying to do is this:

 

I'm using this code: GeolocationCode to place a Geomap into my drawing. I've changed some settings like the data.coordintasystem to "Belge72.Lambert72A" and the coördinates to my location.

 

Everythings works fine, but I want to be able to change the insertion point. When you manually insert a geomap you can choose the insertion point (x,y) at the end of the command. But I don't know how to do this in the Code the map is always placed at 0,0,0?

 

Any suggestions?

 

thanks in advance

0 Likes
844 Views
3 Replies
Replies (3)
Message 2 of 4

moogalm
Autodesk Support
Autodesk Support

Hi,

 

Sorry I'm not able to figure out about your question, Geomap displays a map from an online maps service, in the current viewport. I don't there is a insertion point, I believe you already have created geoposition marker based on lat-long coordinate system, accordingly map gets displayed.

 

Can you please share me screencast  recording of AutoCAD interactively of what you are looking for ?, may be I can get an idea.

0 Likes
Message 3 of 4

Anonymous
Not applicable

I hope the screencast makes it more clear.

 

What I'm trying to do is after I set my location, coordinate system and the drawing units and you click on next.

 

AutoCAD asks = Select a point for the location <0,0,0> :

Default its 0,0,0. But I want this point to be on <147500,218590,0>

 

I want to be able to to that in the code.

In the code Kean sets the geolocation first geoPt (so thats the geoposition), and I thought that the wcsPt was the insertion point of that Geopoint.

But when I look at the result of the code and the result when I do it manually its not the samen. See screenshot.

 

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;

namespace GeoLocationAPI

{
  public class Commands
  {
    [CommandMethod("IGR")]
    public void InsertGeoRef()
    {
      var doc = Application.DocumentManager.MdiActiveDocument;
      if (doc == null)
        return;
      var ed = doc.Editor;
      var db = doc.Database;
      var msId = SymbolUtilityServices.GetBlockModelSpaceId(db);

      // Check whether the drawing already has geolocation data

       bool hasGeoData = false;
      try
      {

        var gdId = db.GeoDataObject;
        hasGeoData = true;
      }

      catch { }

      if (hasGeoData)
      {
        ed.WriteMessage("\nDrawing already has geo-location data!");
        return;
      }

      var data = new GeoLocationData();
      data.BlockTableRecordId = msId;
      data.PostToDb();

      data.CoordinateSystem = "Belge72.Lambert72a";
      data.TypeOfCoordinates = TypeOfCoordinates.CoordinateTypeGrid

      var geoPt = new Point3d(51.277178, 4.332933, 0);
      var wcsPt = new Point3d(147500,218590,0); //data.TransformFromLonLatAlt(geoPt);
      data.DesignPoint = wcsPt;
      data.ReferencePoint = geoPt;

      ed.Command("_.GEOMAP", "_AERIAL");

      using (var tr = db.TransactionManager.StartTransaction())
      {
        var ms =
          tr.GetObject(msId, OpenMode.ForWrite) as BlockTableRecord;
        if (ms != null)
        {
          var circle = new Circle(wcsPt, Vector3d.ZAxis, 7000);
          circle.ColorIndex = 1;
          ms.AppendEntity(circle);
          tr.AddNewlyCreatedDBObject(circle, true);
        }
        tr.Commit();
      }
      ed.Command("_.ZOOM", "_OBJECT", "_L", "");
    }
  }
}

 

 

 

0 Likes
Message 4 of 4

moogalm
Autodesk Support
Autodesk Support

Sorry, I might have overlooked forum notification, please find in-line comments in corrected code

 

 

var data = new GeoLocationData();
            data.BlockTableRecordId = msId;
            data.PostToDb();

            data.CoordinateSystem = "Belge72.Lambert72a";
            data.TypeOfCoordinates = TypeOfCoordinates.CoordinateTypeGrid;
            /*geoPt should (long,lat,alt)
            Longitude ordinates are carried in the x member of AcGePoint objects,
            latitude ordinates are carried in the y member of the AcGePoint object,
            and elevation (altitude) is carried in the z member of the AcGePoint object. 
            */
            //var geoPt = new Point3d(51.277178, 4.332933, 0);

            var geoPt = new Point3d(4.332933, 51.277178, 0);
            var wcsPt = /*new Point3d(147500, 218590, 0);*/ data.TransformFromLonLatAlt(geoPt);
            data.DesignPoint = wcsPt;
            //In the case of design coordinates of the coordTypGrid or coordTypGeodetic types, this specification is not required
            // data.ReferencePoint = geoPt; 

            ed.Command("_.GEOMAP", "_AERIAL");
0 Likes