I wish to find in mapbasic how to extract the shade (style, color,...)
from a thematic map... Is it possible?
To make a thematic map, the command is:
"Set Shade [ Window window_id ] { map_layer_id | "table (
theme_layer_id )" } . . . "
To extract a thematic map, i suppose that i must use: layerinfo()...
but i don't know how to determine the number of values used in thematic
map, and for each value the style/color of the objects...
How to find by example the values (extracted from a .WOR) without write
and read a .WOR...:
>
shade 1 with Type values
"AB" Brush (2,16711680,16777215) Pen (1,2,0) ,
"BC" Brush (5,65280,16777215) Pen (1,2,0) ,
"CD" Brush (2,255,16777215) Pen (4,2,16711680) ,
"ESP" Brush (2,16711935,16777215) Pen (1,2,0)
default Brush (1,0,16777215) Pen (1,2,0) # color 1 #
>
How to know in mapbasic that i have 4 values ("AB", "BC", "CD" and
"ESP") in my thematic map?
objectinfo() tell me that i have a thematic but not the number and the
values inside...
And how to know the type of objects and their styles?
I suppose that i must use the function: styleattr()...
For 1st value: object/thematic with value "AB"...
value_pen_width = StyleAttr(object/thematic with value "AB", PEN_WIDTH)
value_pen_color = StyleAttr(object/thematic with value "AB", PEN_COLOR)
...
For 2nd value: object/thematic with value "BC"...
value_pen_width = StyleAttr(object/thematic with value "BC", PEN_WIDTH)
value_pen_color = StyleAttr(object/thematic with value "BC", PEN_COLOR)
...
...
Thanks to help me to find the solution.
' ExtractThematic.mb
Include "MapBasic.def"
Declare Sub Main
Declare Function GetNextRecord(
ByVal sText As String, ' lines of text to parse
n As Integer ) ' updated pointer into the text
As String ' returns the next line of text
Sub Main
Dim i, j As Integer
Dim m,n As Integer
Dim sText, sShadeText As String
Dim sRec As String
CLS
sText = WindowInfo( FrontWindow(), WIN_INFO_CLONEWINDOW )
j = 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 )
' all lines in the shade clause after the first start with a space.
If Left$(sRec,1) <> " " Then
Exit Do
End If
Loop
End If
' if any thematic clause was found, display it and exit the loop
If Len(sShadeText) > 0 Then
Print sShadeText
Exit Do
End If
Loop
End Sub
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
Ce message entrant est certifié sans virus connu. Analyse effectuée par AVG - www.avg.fr Version: 8.0.238 / Base de données virale: 270.11.25/2019 - Date: 03/23/09 18:51:00