I submitted a pull request (https://github.com/geotools/geotools/pull/871) 
including a test. GeoTools and GeoServer build fine on my machine.

If calling the constructor is never the correct course of action, why is it not 
deprecated (should I add it on the pull request)?

Regards,
Hendrik

---------------------------------------------------------------------------

I like the 2nd option you propose.

We have an API challenge with ReferencedEnevelope in that calling new 
ReferencedEnvelope is *never* the correct course of action (since depending on 
the CRS we may need to create a ReferencedEnvelope or ReferencedEnvelope3D.

We have a factory method ReferencedEnvelope.create( .. ) that should be used. 
This would also be an appropriate location to detect an empty bounds and 
respond accordingly.



--
Jody Garnett

On 8 June 2015 at 02:30, Peilke, Hendrik 
<[email protected]<mailto:[email protected]>> wrote:
Hi,

while writing some tests for the handling of empty imagemosaics, I noticed the 
following: If new ReferencedEnvelope(GeneralEnvelope ...) gets called and the 
GeneralEnvelope is empty (maxx < minx or mmaxy < miny), the resulting 
ReferencedEnvelope is not.

Investigating further shows, that the constructor delegates to its superclass 
constuctor Envelope(minx,maxx,miny,maxy) inside JTS which then uses the method 
init(minx,maxx,miny,maxy). This method switches minx and maxx, if minx is 
greater than maxx and same with miny and maxy (by the way also the setBounds 
method calls this init method). So if the GeneralEnvelope was empty, the 
resulting ReferencedEnvelope is not.

It seems odd, that JTS does this switching here, but they probably have not 
thought that anybody would like to construct an empy ReferencedEnvelope by any 
other statement than new ReferencedEnvelope().

Imho this behavior is unwanted and can be solved by either
- changing JTS, which will cause a lot of code to fail and probably somebody 
had something  in mind when switching coordinates (if not, then this should be 
the right place -> all users and code should be able to provide correct order 
(as in clockwise or counterclockwise coordinates for Polygons and their holes))
- care for the special case of empty Envelopes in the ReferencedEnvelope class 
(and maybe also for empty bounding boxes and Rectangle2Ds?), but this would 
also leave out the robust coordinate switching of JTS and the question is if 
this is really the right place (seems only if JTS would not change and then 
what other Envelopes does GeoTools implement?)
- care for the special case in the code where needed. This seems wrong to me, 
but is the only possibility, if the base is to be left as is

Are there any other possibilities? Or did this problem occur already (maybe 
with an empty bounding box)? Did I miss something, which lead to total 
misunderstanding? If not, what suggestion would be the most preferable?

Regards,
Hendrik Peilke

________________________________
IBYKUS AG für Informationstechnologie, Erfurt / HRB 108616 - D-Jena / Vorstand: 
Helmut C. Henkel, Dr. Lutz Richter
Vorsitzender des Aufsichtsrates: Dr. Wolfgang Habel

------------------------------------------------------------------------------

_______________________________________________
GeoTools-Devel mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/geotools-devel


________________________________
IBYKUS AG für Informationstechnologie, Erfurt / HRB 108616 - D-Jena / Vorstand: 
Helmut C. Henkel, Dr. Lutz Richter
Vorsitzender des Aufsichtsrates: Dr. Wolfgang Habel
------------------------------------------------------------------------------
_______________________________________________
GeoTools-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to