[josm-dev] WMSPlugin Update

Dirk Stöcker openstreetmap at dstoecker.de
Thu Sep 2 13:03:39 BST 2010


On Thu, 2 Sep 2010, Dirk Stöcker wrote:

> On Wed, 1 Sep 2010, Ian Dees wrote:
>
>>  I checked in the changes a few minutes ago and released the plugin to
>>  dist.
>>  Let me know if anyone has any problems.
>
> Your supported projections check is to easy. The projections containing 
> preferences have much more projections.
>
> For these projections you need to call getPreferencesFromCode() and when this 
> succeeds, then that code is supported. For the others toCode() is correct.

    private boolean isProjSupported(String crs) {
        for (Projection proj : Projection.allProjections) {
            if (proj instanceof ProjectionSubPrefs) {
                return ((ProjectionSubPrefs) proj).getPreferencesFromCode(crs) == null;
            } else {
                return proj.toCode().equals(crs);
            }
        }
        return false;
    }

Shouldn't that be

if (proj instanceof ProjectionSubPrefs) {
     if(((ProjectionSubPrefs) proj).getPreferencesFromCode(crs) == null)
         return true;
} else {
     if(proj.toCode().equals(crs))
         return true;
}

or otherwise you always test the first entry only.

Ciao
-- 
http://www.dstoecker.eu/ (PGP key available)


More information about the josm-dev mailing list