ThinkGeo.com    |     Blog    |     Wiki    |     Support

Exception when setting TextStyle Property FittingPolygonInScreen = True

Hi,

At some point following our upgrade to ThinkGeo 10 Winforms we began to get an exception setting a text style on a polygon layer. As it turns out, the problem only happens when setting FittingPolygonInScreen = True on the TextStyle object. I have put together a sample project to demonstrate the problem as it only seems to happen on certain layers. Also, when zoomed in very close it does not seem to be an issue. Here is the exception:

NetTopologySuite.Geometries.TopologyException: found non-noded intersection between LINESTRING(455.1281433334056 615.6444568346825, 455.1297784675105 619.2013670628603) and LINESTRING(455.1297784675105 619.2013670627714, 454.95201264192355 619.71364984453942) [ (455.12977846751045, 619.20136706277151, NaN) ]
at NetTopologySuite.Operation.Overlay.Snap.SnapIfNeededOverlayOp.GetResultGeometry(SpatialFunction opCode)
at NetTopologySuite.Geometries.Geometry.Intersection(IGeometry other)
at ThinkGeo.MapSuite.Shapes.AreaBaseShape.GetIntersectionCore(AreaBaseShape targetShape)
at ThinkGeo.MapSuite.Shapes.AreaBaseShape.GetIntersection(AreaBaseShape targetShape)
at ThinkGeo.MapSuite.Styles.PositionStyle.dh4=(MultipolygonShape multipolygonShape, RectangleShape screenExtent)
at ThinkGeo.MapSuite.Styles.PositionStyle.gB4=(MultipolygonShape multipolygonShape, String text, GeoCanvas canvas)
at ThinkGeo.MapSuite.Styles.PositionStyle.fh4=(MultipolygonShape multipolygonShape, String text, GeoCanvas canvas)
at ThinkGeo.MapSuite.Styles.PositionStyle.GetLabelingCandidateCore(Feature feature, GeoCanvas canvas)
at ThinkGeo.MapSuite.Styles.PositionStyle.GetLabelingCandidates(Feature feature, GeoCanvas canvas)
at ThinkGeo.MapSuite.Styles.PositionStyle.cB4=(Feature feature, GeoCanvas canvas, Collection1 labelsInThisLayer, Collection1 labelsInAllLayers)
at ThinkGeo.MapSuite.Styles.PositionStyle.DrawCore(IEnumerable1 features, GeoCanvas canvas, Collection1 labelsInThisLayer, Collection1 labelsInAllLayers) at ThinkGeo.MapSuite.Styles.Style.Draw(IEnumerable1 features, GeoCanvas canvas, Collection1 labelsInThisLayer, Collection1 labelsInAllLayers)
at ThinkGeo.MapSuite.Layers.ZoomLevel.DrawCore(GeoCanvas canvas, IEnumerable1 features, Collection1 currentLayerLabels, Collection1 allLayerLabels) at ThinkGeo.MapSuite.Layers.ZoomLevel.Draw(GeoCanvas canvas, IEnumerable1 features, Collection1 currentLayerLabels, Collection1 allLayerLabels)
at ThinkGeo.MapSuite.Layers.ShapeFileFeatureLayer.bjo=(GeoCanvas canvas, RectangleShape drawingExtent, Collection1 labelsInAllLayers, ZoomLevel currentZoomLevel, Collection1 columnNames, ShapeFileFeatureSource shapeFileFeatureSource, Collection1 idsToDraw) at ThinkGeo.MapSuite.Layers.ShapeFileFeatureLayer.bTo=(GeoCanvas canvas, RectangleShape marginWorldExtent, Collection1 labelsInAllLayers, ZoomLevel currentZoomLevel, Collection1 columnNames, ShapeFileFeatureSource shapeFileFeatureSource, Collection1 smallBoxes, Collection1 ids) at ThinkGeo.MapSuite.Layers.ShapeFileFeatureLayer.DrawCore(GeoCanvas canvas, Collection1 labelsInAllLayers)
at ThinkGeo.MapSuite.Layers.Layer.lCc=(GeoCanvas canvas, Collection1 labelsInAllLayers) at ThinkGeo.MapSuite.Layers.Layer.Draw(GeoCanvas canvas, Collection1 labelsInAllLayers)
at ThinkGeo.MapSuite.WinForms.LayerOverlay.DrawCore(GeoCanvas canvas)
at ThinkGeo.MapSuite.WinForms.Overlay.pVU=(GeoCanvas canvas)
at ThinkGeo.MapSuite.WinForms.Overlay.Draw(GeoCanvas canvas)
at ThinkGeo.MapSuite.WinForms.WinformsMap.XlU=(IEnumerable`1 drawingOverlays, RectangleShape extent)
at ThinkGeo.MapSuite.WinForms.WinformsMap.XVU=(RectangleShape drawingExtent, RectangleShape extent)
at ThinkGeo.MapSuite.WinForms.WinformsMap.fFU=(RectangleShape extent)
at ThinkGeo.MapSuite.WinForms.WinformsMap.CRk=(Int32 delayInterval, RectangleShape extent)
at ThinkGeo.MapSuite.WinForms.WinformsMap.Refresh()
at LabelingIssue.Form1.mLabelLayer() in C:\Users\ZipPa\Documents\Visual Studio 2015\Projects\ThinkGeo\TG 10\LabelingIssue\Form1.vb:line 80

LabelingIssue.zip (96.4 KB)

Is there a workaround?

Thanks!

Steve

Hi Setve,

Thanks for your sample.

That’s a known exception from NTS, but the strange thing is we can reproduce it under release mode but when we tried to debug it the exception won’t be thrown under debug mode.

Our developer still look into it and try to find what’s the reason here.

And here is a workaround for it:

Public Class customTextStyle
Inherits ThinkGeo.MapSuite.Styles.TextStyle
Protected Overrides Function GetLabelingCandidateCore(feature As Feature, canvas As GeoCanvas) As Collection(Of LabelingCandidate)
    Try
        Return MyBase.GetLabelingCandidateCore(feature, canvas)
    Catch ex As Exception
        Trace.WriteLine(ex.Message)
        Return New Collection(Of LabelingCandidate)
    End Try
End Function

End Class

Wish that’s helpful.

Regards,

Ethan