Envelope RootDrawer::envelope2RootEnvelope(const ICoordinateSystem &csSource, const Envelope &env) { Envelope envelope = (!_coordinateSystem.isValid() || !csSource.isValid() || _coordinateSystem->isEqual(csSource.ptr()) || _coordinateSystem->isUnknown() || csSource->isUnknown()) ? env : _coordinateSystem->convertEnvelope(csSource, env); return envelope; }
void SubGridLayer::calcEnvelope(Coordinate& cmin, Coordinate& cmax) const { cmin = layerManager()->rootLayer()->zoomEnvelope().min_corner(); cmax = layerManager()->rootLayer()->zoomEnvelope().max_corner(); if (!cmin.isValid() || !cmax.isValid()) return; ICoordinateSystem screenCsy = layerManager()->rootLayer()->screenCsy(); if (!screenCsy.isValid()) return; if (screenCsy->isUnknown()) // cant do any extra calcs with unknown return; bool isLatLon = screenCsy->isLatLon(); if (isLatLon) { if (cmin.y <= -89) cmin.y = -89; if (cmin.x < -180) cmin.x = -180; if (cmax.y >= 89) cmax.y = 89; if (cmax.x > 180) cmax.x = 180; } else { LatLon llmin = screenCsy->coord2latlon(cmin); LatLon llmax = screenCsy->coord2latlon(cmax); if (llmin.isValid() && llmax.isValid()) { if (llmin.Lat() <= -85) cmin.y = screenCsy->latlon2coord(LatLon(-85, llmin.Lon())).y; if (llmin.Lon() < -180) cmin.x = screenCsy->latlon2coord(LatLon(llmin.Lat(), -180)).x; if (llmax.Lat() > 85) cmax.y = screenCsy->latlon2coord(LatLon(85, llmax.Lon())).y; if (llmax.Lon() > 180) cmax.x = screenCsy->latlon2coord(LatLon(llmax.Lat(), 180)).x; } } }