You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found an issue with improperly computed bounding boxes when one geometry was fully contained in the eastern hemisphere and another fully contained in the western hemisphere. I think this new code should work in all cases, please review and let me know if you see a problem.
# compute bounding boxdefself.computeBbox(aGeo)# find all the eastings (x) and northings (y) in the GeoJSON objectaNorthings=[]aEastings=[]aGeo.eachdo |hGeo|
unpackGeometry(hGeo,aNorthings,aEastings)end# find most north/south pointsnorth=aNorthings.maxsouth=aNorthings.min# find most east/west spanning the meridianeastM=aEastings.maxwestM=aEastings.min# find most east/west spanning the anti-meridianpositiveEast=[]negativeEast=[]aEastings.eachdo |east|
negativeEast << eastifeast < 0.0positiveEast << eastifeast >= 0.0endeastAM=negativeEast.maxwestAM=positiveEast.min# if eastings are all positive or all negative no meridian was spannedifpositiveEast.empty? || negativeEast.empty?east=eastMwest=westMelse# choose which meridian was spanned based on smaller edge-to-edge distancedistanceM=eastM - westMdistanceAM=(180 + eastAM) + (180 - westAM)ifdistanceM <= distanceAM# this spanned to meridianeast=eastMwest=westMelse# this spanned tne anti-meridianeast=eastAMwest=westAMendendbBox={}bBox[:westLongitude]=westbBox[:eastLongitude]=eastbBox[:southLatitude]=southbBox[:northLatitude]=northreturnbBoxend
The text was updated successfully, but these errors were encountered:
I found an issue with improperly computed bounding boxes when one geometry was fully contained in the eastern hemisphere and another fully contained in the western hemisphere. I think this new code should work in all cases, please review and let me know if you see a problem.
The text was updated successfully, but these errors were encountered: