ThinkGeo.com    |     Documentation    |     Premium Support

Printing, Points will be translated

Hi,

some strange behaviour when Printing.
I’m using the Printing Demo Project to print out maps.
When generating the preview everything is fine.
But exporting to PDF all Points styled with ImagePointStyle (from examples) will be translated.


On the left you see the PlotForm, right the PDF.

When opening the preview Dialog for printing to device all Points will be scaled:

But if I Export the Plot to Bitmap everything is fine!

Any idea what causes that behaviour?

I’m using Desktop Daily Full Development 9.0.363.0

Regards
Hardy

Hi Hardy,

Are you using the PointStyle like the code as below or some special custom pointstyle? I tried that with our printing demo but I hadn’t reproduced the scaled issue, for pdf issue I will test that after I build another test scenario, from the simple test I cannot see whether it moved.

  InMemoryFeatureLayer inMemoryFeatureLayer = new InMemoryFeatureLayer();
        inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(new GeoImage(@"..\..\Images\point.jpg"));
        inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
        inMemoryFeatureLayer.InternalFeatures.Add(new Feature(0, 0));
        inMemoryFeatureLayer.InternalFeatures.Add(new Feature(20, 20));
        inMemoryFeatureLayer.InternalFeatures.Add(new Feature(-20, -20));
        inMemoryFeatureLayer.InternalFeatures.Add(new Feature(-20, 20));

And I want to know whether this works well in your older version?

Regards,

Don

Hi Don,

below is my Code for the PointStyle.
I have reduced to the essential lines…
Public Class gisMEImagePointStyle
Inherits PointStyle

Public Sub New(theImage As GeoImage, MapUnit As GeographyUnit, ImageWorldWidth As String, ImageWorldHeight As String, ImageUnit As DistanceUnit, RotateAngle As Single, Optional RotationColumn As String = “”, Optional CodeColumn As String = “”, Optional scaleColumn As String = “”, Optional Layer As FeatureLayer = Nothing, Optional Level As String = “”, Optional offsetx As String = “”, Optional offsety As String = “”, Optional minimalScale As Integer = 0, Optional maximalScale As Integer = 0)
'Me.m_image = GeoImage
Me.m_image = theImage
Me.m_mapUnit = MapUnit
Me.m_imageWorldWidth = ImageWorldWidth
Me.m_imageWorldHeight = ImageWorldHeight
Me.m_imageUnit = ImageUnit
Me.m_rotateAngle = RotateAngle
Me.m_rotationColumn = RotationColumn
Me.m_FeatureCodeColumn = CodeColumn
Me.m_ScaleColumn = scaleColumn
Me.m_Layer = Layer
m_DrawingLevel = Level
m_offsetx = offsetx
m_offsety = offsety
End Sub

 Protected Overrides Sub DrawCore(features As IEnumerable(Of ThinkGeo.MapSuite.Core.Feature), canvas As GeoCanvas, labelsInThisLayer As Collection(Of SimpleCandidate), labelsInAllLayers As Collection(Of SimpleCandidate))
    
        Dim Scale As Single = 1
        Dim width As Double = 1
        Dim height As Double = 1
        Dim offsetxDrawing As Double = 0
        Dim offsetyDrawing As Double = 0

        'Dim columnCounter As Integer = 0
        Dim myColumns() As String = Nothing

        For Each feature As ThinkGeo.MapSuite.Core.Feature In features
            
            If m_imageWorldWidth <> "" Then
                If IsNumeric(m_imageWorldWidth) Then
                    width = m_imageWorldWidth
                Else
                    width = feature.ColumnValues(m_imageWorldWidth)
                End If
                
            End If
			
            If m_imageWorldHeight <> "" Then
                If IsNumeric(m_imageWorldHeight) Then
                    height = m_imageWorldHeight
                Else
                    height = feature.ColumnValues(m_imageWorldHeight)
                End If
                
            End If
			
            Dim imageWidthMeter As Double = Conversion.ConvertMeasureUnits(width, m_imageUnit, DistanceUnit.Meter)
            Dim imageHeightMeter As Double = Conversion.ConvertMeasureUnits(height, m_imageUnit, DistanceUnit.Meter)

            Dim widthSize As Single = 1
			
			'GmGisRibbonForm is the Mainform from Application
            If GmGisRibbonForm.canvasWidthMeter > 0.01 Then
                widthSize = CSng((imageWidthMeter * canvas.Width) / GmGisRibbonForm.canvasWidthMeter)
            Else
                widthSize = imageWidthMeter * canvas.Width
            End If
			
            If widthSize < 1 Then Exit Sub

            Dim heightSize As Single = 1
            
            If GmGisRibbonForm.canvasHeightMeter > 0.01 Then
                heightSize = CSng((imageHeightMeter * canvas.Height) / GmGisRibbonForm.canvasHeightMeter)
            Else
                heightSize = imageHeightMeter * canvas.Height
            End If

            Select Case feature.GetWellKnownType()
                Case WellKnownType.Point, WellKnownType.Multipoint
                Case Else
                    Exit Sub
            End Select

            'Column testen
            m_rotateAngle = 0 ' GmGisRibbonForm.rotateProjection.Angle
            If m_rotationColumn <> "" Then
                Try
                    If IsNumeric(m_rotationColumn) Then
                        m_rotateAngle += m_rotationColumn
                    Else
                        m_rotateAngle += feature.ColumnValues(m_rotationColumn).ToString
                    End If

                    If Not IsNumeric(m_rotateAngle) Then '.ToString = "-1.#IND"
                        m_rotateAngle = 0
                    End If
                Catch ex As Exception
                    m_rotateAngle = 0
                End Try
            End If

            If m_ScaleColumn <> "" Then
                Try
                    If IsNumeric(m_ScaleColumn) Then
                        Scale = m_ScaleColumn
                    Else
                        Scale = feature.ColumnValues(m_ScaleColumn)
                        
                        If Not IsNumeric(Scale) Then
                            Scale = 1
                        End If
                    End If
                    
                Catch e As Exception
                    Try
                        Scale = feature.ColumnValues(m_ScaleColumn)
                    Catch ex As Exception
                        Scale = 1
                    End Try
                End Try
            Else
                Scale = 1
            End If

            If m_DrawingLevel <> "" Then
                
                    If IsNumeric(m_DrawingLevel) Then
                        m_Level = m_DrawingLevel
                    Else
                        m_Level = feature.ColumnValues(m_DrawingLevel)
                    End If
                
            Else
                m_Level = Core.DrawingLevel.LevelOne
            End If

            If m_offsetx <> "" Then
                Try
                    If IsNumeric(m_offsetx) Then
                        offsetxDrawing = m_offsetx
                    Else
                        offsetxDrawing = selectedFeature.ColumnValues(m_offsetx)
                    End If
                Catch e As Exception
                    offsetxDrawing = 0
                End Try
            End If
            If m_offsety <> "" Then
                Try
                    If IsNumeric(m_offsety) Then
                        offsetyDrawing = m_offsety
                    Else
                        offsetyDrawing = selectedFeature.ColumnValues(m_offsety)
                    End If
                Catch e As Exception
                    offsetyDrawing = 0
                End Try
            End If

            Try
                Select Case feature.GetWellKnownType()
                    Case WellKnownType.Point ', WellKnownType.Multipoint
                        ' Call the canvas method to draw the image scaled.
                        Dim point As New PointShape(feature.GetWellKnownBinary())

                        If m_image IsNot Nothing Then
                            
                            canvas.DrawWorldImage(m_image, point.X + offsetxDrawing, point.Y + offsetyDrawing, widthSize * Scale * GmGisRibbonForm.SymbolWidthScale, heightSize * Scale * GmGisRibbonForm.SymbolHeightScale, m_Level, 0, 0, m_rotateAngle)
                            
                        End If
                    Case WellKnownType.Multipoint
                        ' Let's make sure the features being passed in are points or multi points.
                        ' Call the canvas method to draw the image scaled.
                        Dim point As PointShape
                        point = CType(feature.GetShape, MultipointShape).GetCenterPoint

                        If m_image IsNot Nothing Then
                            canvas.DrawWorldImage(m_image, point.X + offsetxDrawing, point.Y + offsetyDrawing, widthSize * Scale * GmGisRibbonForm.SymbolWidthScale, heightSize * Scale * GmGisRibbonForm.SymbolHeightScale, m_Level, 0, 0, m_rotateAngle)
                        End If
                End Select
            Catch e As Exception
                Debug.WriteLine(m_Layer.Name)
                Debug.WriteLine(e.Message)
            End Try
        Next


End Sub

End Class

I think there is a dependency to Transformation (World to Paper).

Regards
Hardy

Hi Hardy,

I am sorry! It looks because system problem I hadn’t received the remind about your reply so I just found this topic hadn’t been replied today.

I will look into your problem tomorrow.

Any question I will let you know.

Regards,

Don

Hi Don,

any News on that?

Hardy

Hi Hardy,

It looks our developer hadn’t update about this problem, I asked them about it.

Any question I will reply you here.

Regards,

Don

Hi Hardy,

Sorry for the delay. Don is out of the office today. I try to recreate this issue, but it’s failed. Following shows the result, the image on the left side shows the result from the application and the right side is from pdf file.

We fixed an issue about export map to pdf with WorldMapKitLayer a few days ago, I don’t know if it’s used in your application? If so, please get the newest version and have a try again. Or could you please tell us what kinds of layers used to export to the pdf?

Thanks,
Peter

Hi Peter,

I’m using PostGIS Layers exporting to pdf.
The Layers srid=25832.

Hope that helps.

Regards
Hardy

Hi Hardy,

Thanks for more information here. It will take more time to prepare the test data with SRID=25832 to help me to recreate the issue. If you can share the testing data here, it will help a lot.

I noticed the source code and guess this issue may be caused by the gisMEImagePointStyle you created, as I use the PointStyle and export to the PDF, it works well. Please following to make a confirmation:

Use the PointStyle instead of the gisMEImagePointStyle and to see if the issue still occurs. If the issue is gone, we can know it caused by the gisMEImagePointStyle, and please try using the canvas.DrawScreenImage instead of DrawWorldImage when the canvas is PdfGeoCanvas.

If not, hope you can get us more information:

  1. Is the TileCache used in the application?
  2. Is the m_rotateAngle not equal to 0 in your application?

Thanks,
Peter

Hi Hardy,

I created a shape file with SRID=25832 and it works well.

Attached is the test file, please get it and test it in your application to see if it works well.
T.zip (1.6 KB)

Thanks,
Peter