Hi > If all we need to do is replace > calls to getCoordinate with getCentroid, I can prepare a patch for > this as well. > I don't know who (which plugin) use it, but I think that with the current implementation, the centerOfMass of a set of polygons made of a single regular polygon will return a point of the boundary (which is not what people usually call a center)
Michaël > 2009/6/24 Michaël Michaud <michael.mich...@free.fr>: > >> Hi, >> >> I think you're right again. >> For a better result with non puntal geometries, one should use >> getCentroid instead of getCoordinate in getCenterOfMass method >> One could also compute something closer to a center of mass by using the >> area or the length of the feature as the "mass" of each feature >> Of course, computing getCentroid + getArea + getLength can take much >> more time than a single getCoordinate() >> >> Michaël >> >>> While we are on the topic, could you guys look at the getCenterOfMass >>> method in the same class. Its supposed to act like the >>> Geometry.getCentroid method, but for a group of Feature objects. >>> However, I didn't see any use of the getCentroid method on the member >>> feature geometries from within the method. There is some math going on >>> in the method using coordinates obtained via the getCoordinate() >>> method, but I don't think it does what it is supposed to. >>> >>> I think we should clarify the purpose of the method in the javadoc >>> comment, or perhaps discuss alternate implementations of the >>> getCenterOfMass method. This might be a good discussion for the JTS >>> mailing list. >>> >>> I know you guys are busy. Only peek if you have time. I'll have a >>> revamped FeatureCollectionTools class ready by the end of the week I >>> hope. There should be some stuff in there I can port back to OJ after >>> you guys take a look. The revamped class will include a method to >>> compare the equality of FeatureCollections, which should be handy for >>> unit testing. >>> >>> SS >>> >>> On Wed, Jun 24, 2009 at 10:44 AM, Larry Becker<becker.la...@gmail.com> >>> wrote: >>> >>> >>>> Yes, you are right. The getCoordinate() only works when looping through a >>>> single feature's points. >>>> >>>> Larry >>>> >>>> On Wed, Jun 24, 2009 at 12:12 PM, Sunburned Surveyor >>>> <sunburned.surve...@gmail.com> wrote: >>>> >>>> >>>>> Thanks for the responses Larry and Michael. I have attached a text >>>>> file with my modified method. (Note: There are other changes to my >>>>> method that I would not include in the patch.) I believe that the use >>>>> of getCoordinate method should be replaced with the >>>>> getEnvelopeInternal method. >>>>> >>>>> But I could be wrong. >>>>> >>>>> SS >>>>> >>>>> On Wed, Jun 24, 2009 at 6:22 AM, Larry Becker<becker.la...@gmail.com> >>>>> wrote: >>>>> >>>>> >>>>>> Hi SS, >>>>>> >>>>>> If you are talking about this code, it looks like it works to me: >>>>>> >>>>>> public static Envelope getEnvelopeForFeatures(Feature[] features){ >>>>>> Envelope env = null; >>>>>> Feature feat; >>>>>> >>>>>> for (int i=0; i<features.length; i++){ >>>>>> feat = features[i]; >>>>>> if (env==null){ >>>>>> env = new Envelope(feat.getGeometry().getCoordinate()); >>>>>> } else { >>>>>> env.expandToInclude(feat.getGeometry().getCoordinate()); >>>>>> } >>>>>> } >>>>>> >>>>>> return env; >>>>>> } >>>>>> >>>>>> regards, >>>>>> Larry >>>>>> >>>>>> 2009/6/24 Michaël Michaud <michael.mich...@free.fr> >>>>>> >>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> >>>>>>>> I believe there may be a bug in the getEnvelopeForFeatures method of >>>>>>>> the FeatureCollectionTools class. It uses the Geometry.getCoordinate >>>>>>>> method when it should use the Geometry.getEnvelopeInternal method. >>>>>>>> This may result in the calculation of an envolope that does not >>>>>>>> include the envelope of all features. >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> I think you're right. Using getCoordinate to compute an envelope is not >>>>>>> correct. >>>>>>> Feel free to fix it. You've got a correct implementation in >>>>>>> com.vividsolutions.jump.feature.FeatureDataset.getEnvelope(). >>>>>>> >>>>>>> Michaël >>>>>>> >>>>>>> >>>>>>>> When I get my modified version of the getEnvelopeForFeature method >>>>>>>> tested I will submit a patch. >>>>>>>> >>>>>>>> SS >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> ------------------------------------------------------------------------------ >>>>>>>> _______________________________________________ >>>>>>>> Jump-pilot-devel mailing list >>>>>>>> Jump-pilot-devel@lists.sourceforge.net >>>>>>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> ------------------------------------------------------------------------------ >>>>>>> _______________________________________________ >>>>>>> Jump-pilot-devel mailing list >>>>>>> Jump-pilot-devel@lists.sourceforge.net >>>>>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel >>>>>>> >>>>>>> >>>>>> -- >>>>>> Larry Becker >>>>>> Integrated Systems Analysts, Inc. >>>>>> >>>>>> >>>>>> ------------------------------------------------------------------------------ >>>>>> >>>>>> _______________________________________________ >>>>>> Jump-pilot-devel mailing list >>>>>> Jump-pilot-devel@lists.sourceforge.net >>>>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel >>>>>> >>>>>> >>>>>> >>>>>> >>>>> ------------------------------------------------------------------------------ >>>>> >>>>> _______________________________________________ >>>>> Jump-pilot-devel mailing list >>>>> Jump-pilot-devel@lists.sourceforge.net >>>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel >>>>> >>>>> >>>>> >>>> -- >>>> Larry Becker >>>> Integrated Systems Analysts, Inc. >>>> >>>> ------------------------------------------------------------------------------ >>>> >>>> _______________________________________________ >>>> Jump-pilot-devel mailing list >>>> Jump-pilot-devel@lists.sourceforge.net >>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel >>>> >>>> >>>> >>>> >>> ------------------------------------------------------------------------------ >>> _______________________________________________ >>> Jump-pilot-devel mailing list >>> Jump-pilot-devel@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel >>> >>> >>> >>> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Jump-pilot-devel mailing list >> Jump-pilot-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel >> >> > > ------------------------------------------------------------------------------ > _______________________________________________ > Jump-pilot-devel mailing list > Jump-pilot-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > > ------------------------------------------------------------------------------ _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel