/** * The coordinate reference system used for rendering the map. * * <p>The coordinate reference system used for rendering is often considered to be the "world" * coordinate reference system; this is distinct from the coordinate reference system used for * each layer (which is often data dependent). * * @return coordinate reference system used for rendering the map. */ public CoordinateReferenceSystem getCoordinateReferenceSystem() { monitor.readLock().lock(); try { return getViewport().getCoordinateReferenceSystem(); } finally { monitor.readLock().unlock(); } }
CoordinateReferenceSystem mapCrs = null; if (viewport != null) { mapCrs = viewport.getCoordinateReferenceSystem();
viewport != null ? viewport.getCoordinateReferenceSystem() : null;
result.getViewport() .setCoordinateReferenceSystem( mapContent.getViewport().getCoordinateReferenceSystem()); result.getViewport().setBounds(mapContent.getViewport().getBounds()); ZGroupLayer currentGroup = null;
@Test public void crsIsAutoSetWhenGetViewportCalledBeforeAddingLayers() { MapViewport viewport = mapContent.getViewport(); assertNull(viewport.getCoordinateReferenceSystem()); ReferencedEnvelope envNoCRS = new ReferencedEnvelope(WORLD, null); Layer layerNoCRS = new MockLayer(envNoCRS); mapContent.addLayer(layerNoCRS); assertNull(mapContent.getCoordinateReferenceSystem()); Layer layerWithCRS = new MockLayer(WORLD); mapContent.addLayer(layerWithCRS); assertEquals(WORLD.getCoordinateReferenceSystem(), viewport.getCoordinateReferenceSystem()); }
@Test public void settingBoundsSetsTheViewportCRS() { MapViewport vp = new MapViewport(); assertFalse( CRS.equalsIgnoreMetadata( WORLD_1_1.getCoordinateReferenceSystem(), vp.getCoordinateReferenceSystem())); vp.setBounds(WORLD_1_1); assertTrue( CRS.equalsIgnoreMetadata( WORLD_1_1.getCoordinateReferenceSystem(), vp.getCoordinateReferenceSystem())); }
@Test public void callSetCoordinateReferenceSystemWhenNonEditable() throws Exception { final CoordinateReferenceSystem crs = WORLD_1_1.getCoordinateReferenceSystem(); MapViewport vp = new MapViewport(); vp.setCoordinateReferenceSystem(crs); vp.setEditable(false); grabLogger(); vp.setCoordinateReferenceSystem(null); String s = getLogOutput(); assertTrue(s.contains("Ignored call to setCoordinateReferenceSystem")); assertTrue(CRS.equalsIgnoreMetadata(crs, vp.getCoordinateReferenceSystem())); releaseLogger(); }
/** * The coordinate reference system used for rendering the map. * <p> * The coordinate reference system used for rendering is often considered to be the "world" * coordinate reference system; this is distinct from the coordinate reference system used for * each layer (which is often data dependent). * </p> * * @return coordinate reference system used for rendering the map. */ public CoordinateReferenceSystem getCoordinateReferenceSystem() { monitor.readLock().lock(); try { return getViewport().getCoordinateReferenceSystem(); } finally { monitor.readLock().unlock(); } }
@Test public void defaultCtor() { MapViewport vp = new MapViewport(); assertFalse(vp.isMatchingAspectRatio()); assertTrue(vp.isEmpty()); assertTrue(vp.getBounds().isEmpty()); assertTrue(vp.getScreenArea().isEmpty()); assertNull(vp.getCoordinateReferenceSystem()); }
CoordinateReferenceSystem mapCrs = null; if (viewport != null) { mapCrs = viewport.getCoordinateReferenceSystem();
CoordinateReferenceSystem mapCRS = viewport != null ? viewport.getCoordinateReferenceSystem() : null;
/** * Force the output to be in WGS84 * @param mc * @return */ private WMSMapContent fixViewport(WMSMapContent mc) { MapViewport viewport = mc.getViewport(); if(!CRS.equalsIgnoreMetadata(viewport.getCoordinateReferenceSystem(), DefaultGeographicCRS.WGS84)) { viewport.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); GetMapRequest req = mc.getRequest(); req.setSRS("EPSG:4326"); req.setBbox(viewport.getBounds()); } return mc; }