Hermann: This is looking really good! I will be doing more testing as I integrate it into my project, but at this stage, it is behaving as expected.
Thanks so much. Hoping I can repay you in some way. Let me know. Best, Bill P > On Jun 30, 2017, at 8:58 PM, prothero--- via use-livecode > <[email protected]> wrote: > > Herman, > I can't begin to tell you how much I appreciate you doing this! Thanks so > much!! > > I'm off my computer for the day, but will run it through its paces tomorrow. > > Thanks again! > > Bill P > > William Prothero > http://es.earthednet.org > >> On Jun 30, 2017, at 8:27 PM, hh via use-livecode >> <[email protected]> wrote: >> >> Sorry all, I'm used to work in the forums where one can easily edit posts to >> remove errors and typos. >> >> So here another correction, a constant (pixelsPerLonRadian) was wrong in the >> first two versions above. >> >> My last version, hope it's all correct now: >> >> local MERCATOR_RANGE=256, pixelOrigin, pixelsPerLonDegree, pixelsPerLonRadian >> >> on mouseUp >> put (55.9537534, -3.1988236) into centerPoint -- LC Home >> put trunc(the thumbpos of sb "zoom") into zom -- zoom >> put 600 into wdth -- image width >> put 450 into hght -- image height >> put getCorners (centerpoint,zom,wdth,hght) >> -- result is "SW: 55.780374,-3.610811,NE: 56.126359,-2.786836" >> end mouseUp >> >> function getCorners center,zom,mapWidth,mapHeight >> put (MERCATOR_RANGE/2, MERCATOR_RANGE/2) into pixelOrigin >> put MERCATOR_RANGE/360 into pixelsPerLonDegree >> put MERCATOR_RANGE/2/pi into pixelsPerLonRadian >> put 2^zom into scle >> put fromLatLngToPoint(center) into centerPx >> put ( (item 1 of centerPx)-(mapWidth/2)/scle, \ >> (item 2 of centerPx)+(mapHeight/2)/scle ) into SWPoint >> put fromPointToLatLng(SWPoint) into SWLatLon >> put ( (item 1 of centerPx)+(mapWidth/2)/scle, \ >> (item 2 of centerPx)-(mapHeight/2)/scle ) into NEPoint >> put fromPointToLatLng(NEPoint) into NELatLon >> return ("SW: " & SWLatLon, "NE: "& NELatLon) >> end getCorners >> >> function bound val, opt_min, opt_max >> if (opt_min is not empty) then put max(val, opt_min) into val >> if (opt_max is not empty) then put min(val, opt_max) into val >> return val >> end bound >> >> function degreesToRadians deg >> return deg * pi / 180; >> end degreesToRadians >> >> function radiansToDegrees rad >> return 180 * rad / pi >> end radiansToDegrees >> >> function fromLatLngToPoint latLng, opt_point >> put opt_point into point >> put pixelOrigin into origin >> put (item 1 of origin)+(item 2 of latLng)*pixelsPerLonDegree into item 1 of >> point >> put bound(sin(degreesToRadians(item 1 of latLng)), -0.9999, 0.9999) into siny >> put (item 2 of origin)+0.5*ln((1-siny)/(1+siny))*pixelsPerLonRadian into >> item 2 of point >> return point >> end fromLatLngToPoint >> >> function fromPointToLatLng point >> put pixelOrigin into origin >> put (item 1 of point -item 1 of origin)/pixelsPerLonDegree into lng >> put (item 2 of origin-item 2 of point)/pixelsPerLonRadian into latRadians >> put radiansToDegrees(2*atan(exp(latRadians))-pi/2) into lat >> return (lat,lng) >> end fromPointToLatLng >> >> // pixelCoordinate = worldCoordinate * 2^zoomLevel >> >> >> _______________________________________________ >> use-livecode mailing list >> [email protected] >> Please visit this url to subscribe, unsubscribe and manage your subscription >> preferences: >> http://lists.runrev.com/mailman/listinfo/use-livecode > > > _______________________________________________ > use-livecode mailing list > [email protected] > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode _______________________________________________ use-livecode mailing list [email protected] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
