Ticket #2994 (closed defect: invalid)
TransformTo precision error when transforming a box that crosses 180 degrees on 32-bit system
| Reported by: | cdestigter | Owned by: | warmerdam |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | default | Version: | 1.6.0 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
The following python code reproduces the problem:
from osgeo import osr, ogr # a polygon that crosses 180 degrees ogr_geom = ogr.CreateGeometryFromWkt('POLYGON ((165.9134918212895400 -47.7347488403320312, 165.9134918212895400 -34.2310752868652344, 184.6205993652343977 -34.2310752868652344, 184.6205993652343977 -47.7347488403320312, 165.9134918212895400 -47.7347488403320312))') # from wgs84 src = osr.SpatialReference() src.ImportFromProj4('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ') ogr_geom.AssignSpatialReference(src) # to google mercator dest = osr.SpatialReference() dest.ImportFromProj4('+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs') ogr_geom.TransformTo(dest) print ogr_geom.ExportToWkt()
The output is:
POLYGON ((18469405.425279911607504 -6062839.394079929217696,18469405.425279911607504 -4059872.155139415990561,-19523145.574291624128819 -4059872.155139415990561,-19523145.574291624128819 -6062839.394079929217696,18469405.425279915332794 -6062839.394079929217696))
Note that the X coordinates of the first and last points are slightly different. Obviously this causes problems since this is no longer a valid polygon.
This only happens on 32-bit systems. Also, I have tried converting the same sequence of points with pyproj and that works okay, so seems like Proj is not to blame (I could be mistaken about this?)
Change History
Note: See
TracTickets for help on using
tickets.
