<div dir="ltr">First, long time no see!  Been a while since I've posted to this mailing list.  ;)<div><br></div><div>I'm developing a plug-in that will allow a user to use the Twitter REST API to create a layer of tweets.  Yes, I already know of the articles on the net regarding how to do that manually.  However, I'm wrapping that functionality in a nice GUI to shield the lay user from messing about with code.</div>
<div><br></div><div>I already have the plugin working with specified lat/lon coordinates and a given radius.  That's the easy part.  What I'd also like to do is have the user specify such things as "gimme the tweets for the current layer extent" or "gimme the tweets for just the area in the viewport."  I *suspect* that these are easy, but my first pass through the available high level documentation didn't give me a whole lot to steer by.</div>
<div><br></div><div>For the first scenario, I would need to do the following:</div><div><br></div><div><ol><li>get the current layer<br></li><li>get the MBR for said layer<br></li><li>compute the centroid/midpoint<br></li>
<li>project to lat/lon if necessary<br></li><li>compute distance from midpoint to edge<br></li></ol></div><div><div>Step #1 would, I presume, entail talking to the singleton layer manager to get the currently selected layer.  Step #2 would presumably be available in the corresponding QgsLayer object.  Step #3 I could use the GEOS geometry ops to compute.  Step #4 would be a bit tricky since I'd have to first determine if reprojection was even necessary, and if so then jump through the hoops to get my lat/lon.  Step #5 I note the existence of QgsDistance, which I could use to compute the distance from the centroid to an edge of the layer MBR; doing a flat or ellipsoidal distance calculation would depend on the CRS of the selected layer, natch.</div>
<div><br></div><div>My nagging feeling is "surely this, or a subset of these, is/are common use cases" ... and that there'd be corresponding syntactic sugar for implementing them.  The QgsDistance class is sort of an example since it presumably handles projection and geometric distance headaches for you in desired units.</div>
<div><br></div><div>So, does there exist such a set of convenience classes/functions?  Similarly does there exist somewhere a set of corresponding code snippets?  (The official online code snippets don't cover these, alas.)</div>
<div><br></div><div>Cheers!</div><div><br></div><div>Mark</div>-- <br><a href="mailto:mcoletti@gmail.com" target="_blank">mcoletti@gmail.com</a><br><div><br></div>
</div></div>