ThinkGeo.com    |     Documentation    |     Premium Support

Error when labeling and reprojecting from Albers to Google

Hi,

I recently discovered an error that occurs when applying a TextStyle to a layer of polygons, but only under certain circumstances. The error occurs when:

  1. You apply a TextStyle and set the FittingPolygon property (oTextStyle.FittingPolygonInScreen = True)
  2. The original coordinate system of the layer is Albers (Srid=102003)
  3. You reproject the layer into the Google, Spherical Mercator coordinate system.

The hard part is that the error only happens when you zoom to certain areas in the layer.

Of course I have provided a sample project. When the project starts it will open a shapefile and zoom to a “safe” area. When you click the button the map will zoom to a “bad” area and you will see the error (“side location conflict [ (-0.433096078633671, 317.023383767702, NaN) ]”). The error comes from the NetTopology dll.

Thanks!

Steve

LabelEdgeConflict.zip (1.2 MB)

Hi Steven,

Thanks for your sample, I reproduced this issue.

It seems that there are some invalid shapes for the “Intersection” API of NTS in the “bad” area.

After we reproject the layer, the geometric of shape has been changed, then some shapes become invalid.

If oTextStyle.FittingPolygonInScreen = true, it calls the “Intersection” API in the process of rendering text.

And attached is a sample shows that, please check it out.

Thanks,
Emil
Desktop_LabelEdge.zip (1.2 MB)

1 Like

Hi all,

I have discovered the same issue when using ETRS89 projection and also some of the German older (EPSG 31466, 31467).
Howto prevent the text or Polygons to go wrong?
We store the data in PostGIS?

Regards
Hardy

Emil.

Sorry for the delay my response, Thank-you for the sample and the explanation.

Let me summarize what I believe is the problem to make sure I (and others) understand:
Some spatial data, while valid in its native coordinate system, will not be valid when reprojected to some other coordinate systems. This is not due to a programming bug, it is just the way things work the the GIS world.

In our case, we had some polygon data which did not self-intersect in its native coordinate system (102003). However, when reprojected into the Google coordinate system that same polygon self intersects. The problem is revealed when we try to intersect the now self-intersecting polygon with some other area shape. When labels are applied, this is automatically done for every feature when the TextStyle.FittingPolyginInScreen property is applied.

The solutions? I see 3 (maybe there are more!)

  1. Do not set the TextStyle.FittingPolygonInScreen = True.
  2. Modifiy the offending polygon so that the self-intersection does not occur when it is reprojected.
  3. Do not use the target coordinate system that causes the problem.

Cheers!

Steve

Hi Steven,
You are welcome, it’s my pleasure.
Thanks for your summaries, and sorry for I did not explicitly give the solution in the last reply.

Currently, I think the solution is only what you mentioned. Because the result I first investigated just like you said, I’m still working for investigating it and see how to solve it, any update I will let you know.

In fact, I have found a workaround to modify the polygon. Attached is a sample shows that, please check it out.
Thanks,
Emil
Desktop_LabelEdge2.zip (1.2 MB)