Changeset 14519 in josm for trunk


Ignore:
Timestamp:
2018-12-08T01:04:03+01:00 (6 months ago)
Author:
Don-vip
Message:

see #16073 - handle entries with several shapes (like French 'BDOrtho IGN')

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java

    r14516 r14519  
    1313import java.util.Set;
    1414import java.util.TreeMap;
     15import java.util.stream.Collectors;
    1516
    1617import org.junit.Rule;
     
    2728import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryBounds;
    2829import org.openstreetmap.josm.data.imagery.ImageryLayerInfo;
     30import org.openstreetmap.josm.data.imagery.Shape;
    2931import org.openstreetmap.josm.data.imagery.TemplatedWMSTileSource;
    3032import org.openstreetmap.josm.data.imagery.WMSEndpointTileSource;
    3133import org.openstreetmap.josm.data.imagery.WMTSTileSource;
    3234import org.openstreetmap.josm.data.imagery.WMTSTileSource.WMTSGetCapabilitiesException;
     35import org.openstreetmap.josm.data.projection.Projection;
    3336import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3437import org.openstreetmap.josm.testutils.JOSMTestRules;
     38import org.openstreetmap.josm.tools.Geometry;
    3539import org.openstreetmap.josm.tools.HttpClient;
    3640import org.openstreetmap.josm.tools.HttpClient.Response;
     
    102106    }
    103107
     108    private static LatLon getCenter(ImageryBounds bounds) {
     109        List<Shape> shapes = bounds.getShapes();
     110        Projection proj = ProjectionRegistry.getProjection();
     111        return shapes != null && shapes.size() > 1
     112                ? proj.eastNorth2latlon(
     113                        Geometry.getCentroidEN(shapes.get(0).getPoints().stream()
     114                                .map(CoordinateConversion::coorToLL)
     115                                .map(proj::latlon2eastNorth)
     116                                .collect(Collectors.toList())))
     117                : bounds.getCenter();
     118    }
     119
    104120    private void checkEntry(ImageryInfo info) {
    105121        Logging.info("Checking "+ info);
     
    121137            ImageryBounds bounds = info.getBounds();
    122138            // Some imagery sources do not define tiles at (0,0). So pickup Greenwich Royal Observatory for global sources
    123             ICoordinate center = CoordinateConversion.llToCoor(bounds != null ? bounds.getCenter() : new LatLon(51.47810, -0.00170));
     139            ICoordinate center = CoordinateConversion.llToCoor(bounds != null ? getCenter(bounds) : new LatLon(51.47810, -0.00170));
    124140            AbstractTileSource tileSource = getTileSource(info);
    125141            checkTileUrl(info, tileSource, center, info.getMinZoom());
Note: See TracChangeset for help on using the changeset viewer.