Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I found this code

 windowinfo(FrontWindow(), WIN_INFO_CLONEWINDOW)

This function gives information (mapbasic) about the front Map window which can be used to regenerate the map.

Is there any function in mapbasic 10.0 function that gives code that can be used to generate a thematic layer.

share|improve this question
add comment

3 Answers

There is an answer on the MapInfo-L. It appears there is no easy way to do this.

You would have to find the information from either a workspace file or a Clone window statement and then create a new shade statement on the layer you want to apply it to.

The link has some code on how to get the information.

share|improve this answer
    
nice answer +1 but most of the code in mapinfo-L extracts only first shade statement. –  kinkajou Sep 12 '11 at 1:09
add comment

From MapBasic Reference Guide:

The Shade statement creates a thematic map layer and adds the layer to an existing Map window. The Shade statement corresponds to MapInfo Professional's Map > Create Thematic Map menu item.

share|improve this answer
    
Is there possibility to get information about thematic layer already created and apply this to other layer this is my question actually. :) –  kinkajou Sep 1 '11 at 15:05
    
Ah sorry, I misread your question. As far as I know it can't be done. Though it is possible to save the thematic stylings as a template and then apply them to a different layer I don't think you can do this programmatically. If you find a way please let me know! –  Mr_Chimp Sep 1 '11 at 15:19
    
Ofcourse I will :) –  kinkajou Sep 2 '11 at 0:24
add comment
up vote 0 down vote accepted

Here I have the code that separates each shade layer and puts it into array. Although it doesn't work right now as it is just part of code it would give a glimpse of how it can be solved. It is solution form James S answer but now limited to single shade statement.

Function shadeInfo(ByVal shadeInfoText As String) As String
    CALL layersNoThematic

    Dim initLayer As Integer
    Dim tempShadeLayer As Integer
    Dim isFirstLoop As Logical
    Dim shadeInfoArraySize As Integer
    isFirstLoop = True
    initLayer = 0
    shadeInfoArraySize = 1

    Dim i, j As Integer 
    Dim m,n As Integer 
    m=1
    Dim sText, sShadeText As String 
    Dim sRec As String 
      CLS 
      sText = shadeInfoText 
      j= Len( sText )
      print "TOTAL LENGTH OF SHADE INFO : " &Len( sText ) 
      n = 1 
      Do While n < j 
        sRec = GetNextRecord( sText, n )
        ' look for the start of the shade clause 
        If Left$(sRec, 5) = "shade" Then 
          ' gather up all the lines in the shade clause 
          Do While n < j
            sShadeText = sShadeText + sRec 
            sRec = GetNextRecord( sText, n ) 
            If n > j THEN
              sShadeText = sShadeText + sRec 
            End If
            ' all lines in the shade clause after the first start with a space. 
            If Left$(sRec,1) <> " " OR n > j Then 
              ReDim shadeAndLayerStringArray(shadeInfoArraySize)
              shadeAndLayerStringArray(m).shadeString = sShadeText
              'print "This is shade information : " + chr$(10) +sShadeText +chr$(10)
               tempShadeLayer = DeformatNumber$(Mid$(sShadeText,7,InStr(1,sShadeText," w")-6))
                  IF initLayer > tempShadeLayer THEN
                    'print "Layer No Is :" & tempShadeLayer & chr$(10)
                    shadeAndLayerStringArray(m).LayerName =   layerNameFromOrder(tempShadeLayer)
                  ElseIF initLayer < tempShadeLayer THEN
                    IF isFirstLoop THEN
                      'print "Layer No Is :" & tempShadeLayer & chr$(10)
                      shadeAndLayerStringArray(m).LayerName =  layerNameFromOrder(tempShadeLayer)
                      isFirstLoop = FALSE
                    Else
                      'print "Layer No Is :" & initLayer & chr$(10)
                      shadeAndLayerStringArray(m).LayerName =  layerNameFromOrder(initLayer)
                    End IF

                  IF Left$(sRec,5) <> "shade" THEN
                         'print "Quiting Application"
                         Exit Sub 
                  ELSE
                       shadeInfoArraySize = shadeInfoArraySize +1
                       initLayer = tempShadeLayer
                       'print "SHADE ARRAY SIZE : " &  shadeInfoArraySize
                       sShadeText = ""  
                        m= m+1
                      'print "ARRAY M :" & m        

                  END IF
                END IF  

            End If 
          Loop 
        End If      
      Loop 
      For i=1 TO ubound(shadeAndLayerStringArray)
        print shadeAndLayerStringArray(i).layerName
        print shadeAndLayerStringArray(i).shadeString
      Next
End Function

Function GetNextRecord( ByVal sText As String, n As Integer ) As String 
    ' Read the next record in a body of text 
    Dim m As Integer 
    Dim sRec As String 
      m = InStr( n, sText, ""+Chr$(10)) 
      sRec = Mid$( sText, n, (m-n+1)) 
      n = m+1 
      GetNextRecord = sRec 

End Function 

I shall post full working code later :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.