Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
Close
From: Johnathan Kool <jkool@rs...>  20040916 15:58:21
Attachments:
Message as HTML

I was just going over my posting and realized I should probably clarify  I'm not looking to do a group 'contains()' (i.e. select all polygons that contain ANY of the points). I'm looking to return a list of: Point #1 is contained by THIS polygon, Point #2 is contained by THIS polygon, Point #3 isn't contained by any Polygons. etc. etc.. So rather than bundling all of the array points together as a single Geometry, I'm wondering if I would need to create a Geometry for each individual coordinate if I wanted to use MultiPolygon's contains(Geometry) method. Thanks again, J 
From: Andrea Aime <andrea.aime@al...>  20040916 16:22:11

Johnathan Kool wrote: > I was just going over my posting and realized I should probably clarify – > > > > I’m not looking to do a group ‘contains()’ (i.e. select all polygons > that contain ANY of the points). I’m looking to return a list of: > Point #1 is contained by THIS polygon, Point #2 is contained by THIS > polygon, Point #3 isn’t contained by any Polygons… etc. etc…. So rather > than bundling all of the array points together as a single Geometry, I’m > wondering if I would need to create a Geometry for each individual > coordinate if I wanted to use MultiPolygon’s contains(Geometry) method. > Oh, yes, the clarification was needed. You should probably build an array of point objects, and an array to hold the references to the polygons that contain the point at the same array index (or, if the polygons may overlap, an array of arraylist of polygons). If there are many points and many polygons (hundreds) for performance reasons you may want to: * do a bbox test first, that is, the polygon's bbox does contain the point? If so proceed with the real contains(...) test, which is much slower; * build a spatial index (quadtree, STRTree) that contains the points, so that given the polygon bbox you will get in return the list of all point that may intersect with the polygon (again, usually based on a bbox estimate, so you have to perform the contains method) Best regards Andrea Aime 
From: Andrea Aime <andrea.aime@al...>  20040916 16:42:41

Andrea Aime wrote: > Johnathan Kool wrote: > >> I was just going over my posting and realized I should probably clarify – >> >> >> >> I’m not looking to do a group ‘contains()’ (i.e. select all polygons >> that contain ANY of the points). I’m looking to return a list of: >> Point #1 is contained by THIS polygon, Point #2 is contained by THIS >> polygon, Point #3 isn’t contained by any Polygons… etc. etc…. So >> rather than bundling all of the array points together as a single >> Geometry, I’m wondering if I would need to create a Geometry for each >> individual coordinate if I wanted to use MultiPolygon’s >> contains(Geometry) method. >> > > Oh, yes, the clarification was needed. You should probably build an array > of point objects, and an array to hold the references to the polygons that > contain the point at the same array index (or, if the polygons may overlap, > an array of arraylist of polygons). If there are many points and many > polygons (hundreds) for performance reasons you may want to: > * do a bbox test first, that is, the polygon's bbox does contain the point? > If so proceed with the real contains(...) test, which is much slower; > * build a spatial index (quadtree, STRTree) that contains the points, > so that given the polygon bbox you will get in return the list of > all point that may intersect with the polygon (again, usually based > on a bbox estimate, so you have to perform the contains method) > > Best regards > Andrea Aime Erm... now it's my time to clarify. The simple solution is to load a polygon, and perform the contains for every point, if the polygon contains the point, put it in the second array in the same position as the point. The first * is just an optimization for that loop. The spatial index instead is different: build the point objects and add them to the spatial index, for each polygon, compute the envelope, query the spatial index with the envelope and you'll get a list of candidate points ( hopefully much smaller than the full number of points), on whose you can loop to find the containment relations using contains... the result may be put into the same data structure as before (or you can use an hashmap if you prefer). Best regards Andrea Aime 
From: Rueben Schulz <r_j_schulz@ya...>  20040918 05:41:46

Hi, This would make a great howto / demo since other users have asked this question before (I have answered this one at least once). It is a nice demonstration of the power of JTS. If noone wants or has time to put this on the wiki, I should have some time in october to do this. Johnathan, if you want to donate your code as a demo, just put it up on the wiki as a howto document. If you do not have time, but can donate your code, please send it to me and I will put something up in a few weeks. Rueben On Thu, 20040916 at 09:51, Andrea Aime wrote: > Andrea Aime wrote: > > > Johnathan Kool wrote: > > > >> I was just going over my posting and realized I should probably cla= rify =96 > >> > >> > >> > >> I=92m not looking to do a group =91contains()=92 (i.e. select all p= olygons > >> that contain ANY of the points). I=92m looking to return a list of= : > >> Point #1 is contained by THIS polygon, Point #2 is contained by THI= S > >> polygon, Point #3 isn=92t contained by any Polygons=85 etc. etc=85.= So > >> rather than bundling all of the array points together as a single > >> Geometry, I=92m wondering if I would need to create a Geometry for = each > >> individual coordinate if I wanted to use MultiPolygon=92s > >> contains(Geometry) method. > >> > > > > Oh, yes, the clarification was needed. You should probably build an = array > > of point objects, and an array to hold the references to the polygon= s that > > contain the point at the same array index (or, if the polygons may o= verlap, > > an array of arraylist of polygons). If there are many points and man= y > > polygons (hundreds) for performance reasons you may want to: > > * do a bbox test first, that is, the polygon's bbox does contain the= point? > > If so proceed with the real contains(...) test, which is much slow= er; > > * build a spatial index (quadtree, STRTree) that contains the points= , > > so that given the polygon bbox you will get in return the list of > > all point that may intersect with the polygon (again, usually base= d > > on a bbox estimate, so you have to perform the contains method) > > > > Best regards > > Andrea Aime > > Erm... now it's my time to clarify. The simple solution is to load a p= olygon, > and perform the contains for every point, if the polygon contains the = point, > put it in the second array in the same position as the point. The firs= t > * is just an optimization for that loop. > The spatial index instead is different: build the point objects and ad= d them > to the spatial index, for each polygon, compute the envelope, query t= he > spatial index with the envelope and you'll get a list of candidate poi= nts ( > hopefully much smaller than the full number of points), on whose you c= an loop > to find the containment relations using contains... the result may be = put > into the same data structure as before (or you can use an hashmap if y= ou prefer). > > Best regards > Andrea Aime > > > >  > This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 > Project Admins to receive an Apple iPod Mini FREE for your judgement o= n > who ports your project to Linux PPC the best. Sponsored by IBM. > Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php > _______________________________________________ > Geotoolsgt2users mailing list > Geotoolsgt2users@... > https://lists.sourceforge.net/lists/listinfo/geotoolsgt2users 