Pages

Tuesday, 20 May 2014

Set Map Window Projection from Layer - Alter Layer Control Right Click Menu

Hi All,
This is quick post to demonstrate a useful tool for changing map projections based on a layer. By default MapInfo will assign a map projection based on the dominant raster layer. If you change raster layers the map projection may, but not always change. This tool will allow you to select a layer in the layer control, right click and set projection from layer.


Include "Mapbasic.def"
Include "Menu.def"

Declare Sub Main
Declare Sub
SetMapWinProjection

'----------------------------------------------------------------
Sub Main
OnError Goto
CatchEx


   Alter Menu ID M_SHORTCUT_LC_LAYERS Add
   "(-",
   "Set Map Projection From Layer"
   Calling SetMapWinProjection

Done:
   Exit Sub
CatchEx:
   Note Error$()
   Resume Done
End Sub
'----------------------------------------------------------------
Sub SetMapWinProjectionOnError Goto CatchEx

   If LayerControlInfo(LC_INFO_SEL_COUNT) = 0 then
      Note "Please select a layer!"
      Goto Done
   End If

   If LayerControlInfo(LC_INFO_SEL_COUNT) > 1 then
      Note "Please select one layer you want to set the map projection from"
      Goto Done
   End If

   Dim strLayerAlias as String
   strLayerAlias = LayerControlSelectionInfo(1,LC_SEL_INFO_NAME)
   Print("Layer Name: " & strLayerAlias)

   Print("Layer Type: "  LayerControlSelectionInfo(1,LC_SEL_INFO_TYPE))

   Dim iMapWinID as integer
   iMapWinID = LayerControlSelectionInfo(1,LC_SEL_INFO_MAPWIN_ID)
   Print("Layer's Map Window ID: " & iMapWinID)

   Dim strCmd as String
   strCmd = "Set Map " TableInfo(strLayerAlias,TAB_INFO_COORDSYS_CLAUSE)
   Print "strCmd = " & strCmd
   Run Command strCmd

Done:
   Exit Sub
CatchEx:
   Note Error$()

   Resume Done 
End Sub

3 comments:

  1. Nice post,i found lot of information regarding gis. I updated my knowledge with this blog.it can help me to crack GIS jobs in Hyderabad.

    ReplyDelete
  2. The effectiveness of IEEE Project Domains depends very much on the situation in which they are applied. In order to further improve IEEE Final Year Project Domains practices we need to explicitly describe and utilise our knowledge about software domains of software engineering Final Year Project Domains for CSE technologies. This paper suggests a modelling formalism for supporting systematic reuse of software engineering technologies during planning of software projects and improvement programmes in Final Year Projects for CSE.

    Software management seeks for decision support to identify technologies like JavaScript that meet best the goals and characteristics of a software project or improvement programme. JavaScript Training in Chennai Accessible experiences and repositories that effectively guide that technology selection are still lacking.

    Aim of technology domain analysis is to describe the class of context situations (e.g., kinds of JavaScript software projects) in which a software engineering technology JavaScript Training in Chennai can be applied successfully

    The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

    ReplyDelete
  3. Top 10 best slots casinos for 2021 - SOL.EU
    Best Slots Casino: Best Real Money Slots communitykhabar Sites 2021 · Red Dog Casino: Best Overall Slots Casino sol.edu.kg For jancasino.com USA Players · Ignition Casino: casino-roll.com Best Casino For febcasino.com Roulette

    ReplyDelete