Alex,
I stumbled upon this problem recently and deduced that this was due to the fact that any font size would only be correct at 1 specific map zoom as the font scales with the zoom. I guess using the object bounds as you’ve done would be the only way to get a size for the text. If there is another way I’d be interested to hear it too!
Cheers,
Tom Bacon
GIS Engineer, Mouchel
T 01444 472380 │ E thomas...@mouchel.com │ W www.mouchel.com
Our values: innovation │ excellence │ integrity │ responsibility
--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
|
|
Mouchel Limited (Mouchel) is registered in England and Wales with registered number 01686040 at Export House, Cawsey Way, Woking, Surrey, UK, GU21 6QX. The information in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. Any views or opinions expressed in this e-mail may be solely those of the author and are not necessarily those of Mouchel. No contracts may be concluded on behalf of Mouchel by means of email communications. Mouchel reserves the right to monitor and intercept emails sent and received on our network. |
“The problem with this is that the text objects are often not horizontal (which they need to be for 'Top' and 'Bottom' to be correct), hence Alter Object...TextAngle, but this Alter Object statement also modifies the size of the text object for some reason. So when you then define the MBR after you've rotated the text object the size won't be correct.”
I guess the text size must be defined by its MBR so rotating the text would affect the way it fits inside the bounding rectangle and hence the size of the text. I’m not sure how you’d calculate the height and width in this case!
Tom Bacon
GIS Engineer, Mouchel
T 01444 472380 │ E thomas...@mouchel.com │ W www.mouchel.com
Our values: innovation │ excellence │ integrity │ responsibility
From: mapi...@googlegroups.com [mailto:mapi...@googlegroups.com]
On Behalf Of Alex Eastwood
Sent: 17 April 2015 14:48
To: mapi...@googlegroups.com
Subject: [MI-L] Text Objects - Determining Text Size
Hi,
--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No virus found in this
message.
Checked by AVG - www.avg.com
Version: 2014.0.4800 / Virus
Database: 4311/9558 - Release Date: 04/17/15
Text height for this data is fixed, not sure how I would use the current zoom level to extract the text height...? Bearing in mind I have 400k objects I'm trying to do this with so this all needs to be automated and wouldn't actually be displayed in a map window or otherwise!FONT_POINTSIZE:
Integer indicating the Font size, in points.
Note: If the Text object is in a mappable table (as opposed to a Layout window), the point size is returned as zero, and the text height is dictated by the Map window's current zoom.
Thanks for the update Alex, and also the link. Good to have this reference as I’m sure I’ll end up trying to do similar at some point!
Cheers,
Tom Bacon
GIS Engineer, Mouchel
T 01444 472380 │ E thomas...@mouchel.com │ W www.mouchel.com
Our values: innovation │ excellence │ integrity │ responsibility
--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thomas,
I was looking at this problem a while ago as I wanted to store text objects in SQL Server by storing their properties separately to the object, and then recreating the text object from those properties. Unfortunately, there was one property that couldn’t be accessed from MapBasic, something like the unrotated height.
So I pass my test program to you to see if you can make any more progress than I. The code has lost its formatting I am afraid. Good luck.
Rob.
Sub Main
Create Table "TestTextObj" (ID Integer) File ApplicationDirectory$() + "TestTextObj.tab"
Create Map For TestTextObj CoordSys Earth Projection 1,104
fFont = MakeFont("Arial", 1, 12, BLACK, -1)
Create Text Into Variable oTextObj
"Looooooooooong Test String 0"
(153,-24) (153.1, -24.1)
Font fFont
Angle 0
Insert Into TestTextObj (ID, Obj) Values (-1, oTextObj)
Insert Into TestTextObj (ID, Obj) Values (0, MBR(oTextObj))
Create Text Into Variable oTextObj
"Looooooooooong Test String 30"
(153,-25) (153.1, -25.1)
Font fFont
Alter Object oTextObj Geography OBJ_GEO_TEXTANGLE, 30
Insert Into TestTextObj (ID, Obj) Values (-1, oTextObj)
Insert Into TestTextObj (ID, Obj) Values (0, MBR(oTextObj))
Create Text Into Variable oTextObj
"Looooooooooong Test String 225"
(154,-25) (154.1, -25.1)
Font fFont
Alter Object oTextObj Geography OBJ_GEO_TEXTANGLE, 225
Insert Into TestTextObj (ID, Obj) Values (-1, oTextObj)
Insert Into TestTextObj (ID, Obj) Values (0, MBR(oTextObj))
Create Text Into Variable oTextObj
"Looooooooooong Test String 90"
(154.5,-25) (154.6, -25.1)
Font fFont
Alter Object oTextObj Geography OBJ_GEO_TEXTANGLE, 90
Insert Into TestTextObj (ID, Obj) Values (-1, oTextObj)
Insert Into TestTextObj (ID, Obj) Values (0, MBR(oTextObj))
Create Text Into Variable oTextObj
"Looooooooooong Test String 125"
(155,-25) (155.1, -25.1)
Font fFont
Alter Object oTextObj Geography OBJ_GEO_TEXTANGLE, 125
Insert Into TestTextObj (ID, Obj) Values (-1, oTextObj)
Insert Into TestTextObj (ID, Obj) Values (0, MBR(oTextObj))
Commit Table TestTextObj
Close Table TestTextObj
Open Table ApplicationDirectory$() + "TestTextObj.tab"
Map From TestTextObj
Set Map Window FrontWindow() Zoom Entire
Create Menu "Test Object Functions" As
"Do Text Operations" Calling TransformText
Alter Menu Bar Add "Test Object Functions"
End Sub
Sub TransformText
'-----------------------
'Subroutine: Main
'Called By: None
'Description: This subroutine calls other subs to sets up the menus and initial variables.
'-----------------------
'Set up general error handler
ONERROR GOTO ErrorHandler
Dim oOrigTextObject, oMBROrigTextObject, oMBRotatedTextObj, oNewTextObj As Object
Dim oObjProp As tObjProperties
'Dim oMBROrigText As tObjMBX
Dim RotationAngle As Float
Dim arraysize As Integer
Select * From TestTextObj Where ID > 0 Into SelText
Delete From SelText
Select * From TestTextObj Where ID <= 0 Into SelText
If TableIsOpen("TmpObjects") Then
Drop Table TmpObjects
End If
Create Table "TmpObjects" (TextRotation Float) File ApplicationDirectory$() + "TmpObjects.tab"
Create Map For TmpObjects CoordSys Earth Projection 1,104
Select * From TestTextObj Where Obj Into SelTemp
Select * From SelTemp Where Int(ObjectInfo(Obj, OBJ_INFO_TYPE)) = OBJ_TYPE_TEXT Into SelTempText
If SelectionInfo(SEL_INFO_NROWS) > 0 Then
Insert Into TmpObjects (TextRotation, Obj) Select ObjectGeography(Obj, OBJ_GEO_TEXTANGLE), Obj From SelTempText
End If
Select * From SelTemp Where Int(ObjectInfo(Obj, OBJ_INFO_TYPE)) <> OBJ_TYPE_TEXT Into SelTempNotText
If SelectionInfo(SEL_INFO_NROWS) > 0 Then
Insert Into TmpObjects (TextRotation, Obj) Select 0, Obj From SelTempNotText
End If
Select * From TmpObjects Into SelTemp
Update SelTemp Set Obj = fUnRotateText(Obj)
If SelectionInfo(SEL_INFO_NROWS) > 0 Then
Fetch First From SelTemp
Do Until EOT(SelTemp)
If fGetObjProperties(SelTemp.Obj, oObjProp) = FALSE Then
Note "Failed to extract properties from text object."
Else
oOrigTextObject = SelTemp.Obj
oObjProp.iTextAngle = SelTemp.TextRotation
'RotationAngle = ObjectGeography(oOrigTextObject, OBJ_GEO_TEXTANGLE)
'oMBROrigTextObject = MBR(oOrigTextObject)
'Insert Into TestTextObj (ID, Obj) Values (1, oMBROrigTextObject)
oNewTextObj = fCreateObjFromProperties(oObjProp.iObjectType,
oObjProp.cTextString,
oObjProp.cFontName,
oObjProp.IfontStyle,
oObjProp.IfontSize,
RED,
oObjProp.IfontbackColor,
oObjProp.iTextSpacing,
oObjProp.iTextJustIfy,
oObjProp.iTextLineType,
oObjProp.cTextLinePen,
oObjProp.fTextLineX,
oObjProp.fTextLineY,
oObjProp.iTextAngle,
oObjProp.oObj)
Insert Into TestTextObj (ID, Obj) Values (3, oNewTextObj)
End If
Fetch Next From SelTemp
Loop
End If
Exit Sub
ErrorHandler:
Note Error$()
End Sub
Function fUnRotateText(ByVal oObj As Object) As Object
'-----------------------
'Subroutine: Main
'Called By: None
'Description: This subroutine calls other subs to sets up the menus and initial variables.
'-----------------------
'Set up general error handler
ONERROR GOTO ErrorHandler
Dim oUnRotObj As Object
Dim iTextAngle, iObjectType As Integer
iObjectType = ObjectInfo(oObj, OBJ_INFO_TYPE)
Do Case iObjectType
Case OBJ_TYPE_TEXT
iTextAngle = ObjectGeography(oObj,OBJ_GEO_TEXTANGLE)
If iTextAngle <> 0 Then
Alter Object oObj Geography OBJ_GEO_TEXTANGLE, 0
End If
Case Else
fUnRotateText = oObj
End Case
Exit Function
ErrorHandler:
CALL ErrorMessage("fUnRotateText")
END Function 'fUnRotateText
Function fCreateObjFromProperties(ByVal iObjectType As SmallInt,
ByVal cTextString As String,
ByVal cFontName As String,
ByVal iFontStyle As Integer,
ByVal iFontSize As Integer,
ByVal iFontForeColor As Integer,
ByVal iFontbackColor As Integer,
ByVal fTextSpacing As Float,
ByVal iTextJustify As SmallInt,
ByVal iTextLineType As SmallInt,
ByVal cTextLinePen As String,
ByVal fTextLineX As Float,
ByVal fTextLineY As Float,
ByVal iTextAngle As Integer,
ByVal oObj As Object) As Object
'-----------------------
'Subroutine: Main
'Called By: None
'Description: This subroutine calls other subs to sets up the menus and initial variables.
'-----------------------
'Set up general error handler
ONERROR GOTO ErrorHandler
Dim oText As Object
Dim fFont As Font
Dim UnRotText As Object
Dim oMBRUnRotText As Object
Dim Xi As Float
Dim Hi As Float
Dim Xr As Float
Dim Hr As Float
Dim K As Float
Dim a As Float
Dim b As Float
Dim Discriminant As Float
' ------------
' | / /|
' | / / |
' | / / |
' | / /Xi |
' | / / |
' | /Hi/ |
' ------------
' a b
' Xr
If iFontSize = 0 Then
iFontSize = 100
End If
If iObjectType <> OBJ_TYPE_TEXT Then
fCreateObjFromProperties = oObj
Exit Function
Else
fCreateObjFromProperties = oObj
fFont = MakeFont(cFontName, iFontStyle, iFontSize, iFontForeColor, iFontbackColor)
If iTextAngle = 0 Then
Print "Found a ext object with a text andgle of 0"
Create Text Into Variable oText
cTextString
(ObjectGeography(oObj, OBJ_GEO_MINX), ObjectGeography(oObj, OBJ_GEO_MINY)) (ObjectGeography(oObj, OBJ_GEO_MAXX), ObjectGeography(oObj, OBJ_GEO_MAXY))
Font fFont
Spacing fTextSpacing
Else
Print "Found a ext object with a text andgle of " + iTextAngle
Create Text Into Variable UnRotText
cTextString
(ObjectGeography(oObj, OBJ_GEO_MINX), ObjectGeography(oObj, OBJ_GEO_MINY)) (ObjectGeography(oObj, OBJ_GEO_MAXX), ObjectGeography(oObj, OBJ_GEO_MAXY))
Font fFont
Spacing fTextSpacing
'Get proportion of hieght to base on text object.
oMBRUnRotText = MBR(UnRotText)
K = (ObjectGeography(oMBRUnRotText, OBJ_GEO_MAXX)- ObjectGeography(oMBRUnRotText, OBJ_GEO_MINX))/ (ObjectGeography(oMBRUnRotText, OBJ_GEO_MAXY) - ObjectGeography(oMBRUnRotText, OBJ_GEO_MINY))
Print "K Len/ Height of Unrotated Text = " + K
Xr = ObjectGeography(oObj, OBJ_GEO_MAXX) - ObjectGeography(oObj, OBJ_GEO_MINX)
Print "Xr= " + Xr
Hi = Xr / (Sin(iTextAngle*DEG_2_RAD) + (K * Cos(iTextAngle*DEG_2_RAD)))
' Discriminant = (Xr ^ 2) - (4 * Sin(-1*iTextAngle*DEG_2_RAD) * K * Cos(iTextAngle*DEG_2_RAD))
' Print "Discriminant= " + Discriminant
' Hi = ((-1 * Xr) + Sqr(Discriminant)) / (-2 * Sin(iTextAngle*DEG_2_RAD))
' Hi = ObjectGeography(oMBRUnRotText, OBJ_GEO_MAXY) - ObjectGeography(oMBRUnRotText, OBJ_GEO_MINY)
Print "Hi= " + Hi
Create Text Into Variable oText
cTextString
(ObjectGeography(oObj, OBJ_GEO_MINX), ObjectGeography(oObj, OBJ_GEO_MINY)) (ObjectGeography(oObj, OBJ_GEO_MAXX), ObjectGeography(oObj, OBJ_GEO_MAXY))
' (ObjectGeography(oObj, OBJ_GEO_MINX), ObjectGeography(oObj, OBJ_GEO_MINY)) (ObjectGeography(oObj, OBJ_GEO_MAXX), ObjectGeography(oObj, OBJ_GEO_MINY)+Hi)
Font fFont
Spacing fTextSpacing
Angle iTextAngle
End If
If iTextLineType In(0,1,2) Then
Alter Object oText Info OBJ_INFO_TEXTARROW, iTextLineType
End If
If fTextLineX > 0 Then
Alter Object oText Geography OBJ_GEO_TEXTLINEX, fTextLineX
End If
If fTextLineY > 0 Then
Alter Object oText Geography OBJ_GEO_TEXTLINEY, fTextLineY
End If
fCreateObjFromProperties = oText
End If
Exit Function
ErrorHandler:
CALL ErrorMessage("fCreateObjFromProperties")
END Function 'fCreateObjFromProperties
From: mapi...@googlegroups.com [mailto:mapi...@googlegroups.com] On Behalf Of Thomas Bacon
Sent: Wednesday, 13 May 2015 7:54 PM
To: mapi...@googlegroups.com