Hi,

I agree getCoordinate must be replaced by getEnvelopeInternal, but your 
method is way too complex.
If you study Envelope class, you'll notice that EmptyGeometry envelopes 
are already managed by this class, so that the following few lines 
should do what you want :

public Envelope getEnvelopeForFeatures(*Feature[] features*) {
   
    Envelope env = new Envelope();

    for (Feature f : features) {
        env.expandToInclude(f.getGeometry().getEnvelopeInternal());
    }
    return env;
}

Note that the code is absolutely untested

Michaël

Sunburned Surveyor a écrit :
> 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


------------------------------------------------------------------------------
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to