I'm using mercator-projected overlays from a crowdsourced website where volunteers georectify images of maps by hand. Unfortunately, the slippy map that serves as the site's interface wraps and allows users to place points outside [-180, 180]/[90,-90].
I have a bunch of features with bad coordinates, like the following:
var feature = {"geometry": {"type": "Polygon", "coordinates": [[[-231.304241727798, 1682.74422719708], [825.474710540096, 1682.74422719708], [825.474710540096, -272.6456886681], [-231.304241727798, -272.6456886681], [-231.304241727798, 1682.74422719708]]]}, "type": "Feature", "properties": {"id": "7014"}}
Here's some relevant data from the WMS file:
<SRS>EPSG:4269</SRS>
<SRS>EPSG:4326</SRS>
<SRS>EPSG:900913</SRS>
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
<BoundingBox SRS="EPSG:4326"
minx="-180" miny="-90" maxx="180" maxy="90" />
...
<Layer queryable="0" opaque="0" cascaded="0">
<Name>image</Name>
<SRS>EPSG:4326</SRS>
<SRS>EPSG:4269</SRS>
<SRS>EPSG:900913</SRS>
<LatLonBoundingBox minx="-231.304" miny="-272.646" maxx="825.475" maxy="1682.74" />
<BoundingBox SRS="EPSG:4326"
minx="-231.304" miny="-272.646" maxx="825.475" maxy="1682.74" />
I've tried to wrap the coordinates back into something that a map library can read, but to no avail, first using this:
lng = ((x + 180) % 360) - 180), lat = ((y + 90) % 180) - 90)
then after figuring out problems with mod in Javascript:
lng = ((((x + 180) % 360) + 360) % 360) - 180
lat = ((((y + 90) % 180) + 180) % 180) - 90
but I still get incorrect coordinates. How do I convert these out-of-bounds mercator coordinates back to something that I can put on a map?