On Tue, Sep 7, 2010 at 10:57 PM, Judd Taylor <[email protected]> wrote:
> Hmmm, I have some C++/PDL code that may help you here. It is a set of 
> rendering primitives that operate directly on piddles, including filled 
> polygons. You can use that to render a mask based on your mouse clicks.
>
> I don't get your algorithm below. Why is the min bound rec in there at all? 
> If that is what you want to get to, why do you need the polygon at all, as 
> it's waaaay easier to just keep track of the bounds of the mouse clicks.
>
> I suspect you don't really want anything to do with the bbox at all, in which 
> case the polygons are a good idea...

I might have obfuscated my intent with that comment. Here was my
logic... a 2D piddle, by definition, is a rect object (in my
carto-geographic mindset). I have a large Piddle (capital P), say,
covering the state of Wisconsin. Since Wisconsin is not rectangular,
the large Piddle is really the tightest box containing Wisconsin, all
cells outside Wisconsin having been set to BAD.

The user clicks on a map (in the browser) and creates an irregular
polygon. I have to now find all the cells that fall within this poly
and do my calculations on those cells. Those cells will make up an
irregular poly inside a rectangular piddle (lowercase p), much like
Wisconsin is to the larger Piddle. All the cells inside this little
rectangular piddle that don't lie within the clicked poly will be set
to BAD. The others will have the values that the large Piddle gave
them.

So, my task is to find the smallest piddle that contains the clicked
poly, and set all those elements to BAD that are not within the
clicked poly.

Maybe I am thinking about this in too convoluted a way, but there it is.

>
> Anyway, I'll send you a load of mapping code tomorrow morning. I'll let you 
> pick out the rendering portion on your own, as it should be an educational 
> exercise to see it's context and implementations.

Thanks. Really appreciate that. I don't know the first + of C++, but
heck, not too long ago I didn't know the first P of PDL.


>
> Also, the code here has nothing to do with the PDL::IO::GD rendering, which 
> operates on gd objects, not piddles. What I'll send tomorrow is hugely 
> faster, as well.

By the way, tremendous thanks for the PDL::IO::GD code, which works
very fast. I do have some issues with its documentation and the fact
that it segfaults on me, but that is subject of a separate thread.


>
> -Judd
>
> On Sep 7, 2010, at 8:48 PM, "P Kishor" <[email protected]> wrote:
>
>> On Tue, Sep 7, 2010 at 8:39 PM, Craig DeForest
>> <[email protected]> wrote:
>>> I am on alert about local wildfires, so I will not type up a large
>>> discussion of hulls, but if you generate a selection mask image (zero
>>> outside the selection, one inside it) then the obvious thing to use is
>>> either "do_something_to($source->where($mask));" if you don't need to track
>>> the coordinates themselves, or "$dex = $mask->whichND;
>>> do_something_to($source->indexND($dex));" if you do.
>>
>>
>> Thanks Craig. I did see the where and which methods, but, I guess the
>> challenge here is to generate the selection mask in the first place.
>> Don't want to take your mind away form wildfires, but if you have any
>> suggestions on the path to explore for the selection itself given a
>> set of click coordinates, send them my way when you get a chance.
>>
>> Additionally, I also noticed the annotation in the docs that there is
>> no whereND. I will investigate this further and see if it affects me.
>>
>> Thanks for the suggestion.
>>
>>>
>>>
>>>
>>> On Sep 7, 2010, at 7:31 PM, P Kishor wrote:
>>>
>>>> Rectangular selections from 2D piddles are easy and fast with the
>>>> range operator. However, I would like to grab a non-rectangular
>>>> selection out of a piddle, setting all out-of-area-of-interest
>>>> elements to BAD.
>>>>
>>>> Background --
>>>>
>>>> - The user clicks on a map and creates an irregular polygon
>>>> - I (somehow **) figure out the piddle elements, aka cells, that lie
>>>> within the drawn poly
>>>> - Out of the base piddle, I grab the tightest rect that contains the
>>>> cells within the drawn poly (the min. bounding box)
>>>> - Set all the cells outside the drawn poly to BAD so they don't figure
>>>> in the rest of the calculations
>>>>
>>>> I searched the docs, but the closest discussion I found was on
>>>> convex-hulls from June 2005 [1]. Suggestions?
>>>>
>>>> ** the reason I say "somehow" is because I can do a lookup using a
>>>> database to get the indices of the mouse-clicks, and the elements that
>>>> lie within the bounding rect, but I would prefer to do this without a
>>>> database. I am generally finding PDL to be substantively faster than a
>>>> database, and would like to stay out of a db as much as possible. I
>>>> initiated a discussion on this a while back, but that was restricted
>>>> to rectangular selects.
>>>>
>>>> [1] http://mailman.jach.hawaii.edu/pipermail/perldl/2005-June/000036.html
>>>>



-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to