bool IlwisObjectModel::isProjectedCoordinateSystem() const { try { ICoordinateSystem csy; if ( hasType(_ilwisobject->ilwisType(), itCOVERAGE | itCOORDSYSTEM)){ csy = hasType(_ilwisobject->ilwisType(), itCOVERAGE) ? _ilwisobject.as<Coverage>()->coordinateSystem() : _ilwisobject.as<CoordinateSystem>(); } if ( hasType(_ilwisobject->ilwisType(), itGEOREF)){ csy = _ilwisobject.as<GeoReference>()->coordinateSystem(); } if ( csy.isValid()){ if ( csy->isLatLon()) return false; if (csy->ilwisType() != itCONVENTIONALCOORDSYSTEM) return false; return true; } return false; }catch(const ErrorObject& ){ // no exceptions may escape here } return ""; }
Coordinate ConventionalCoordinateSystem::coord2coord(const ICoordinateSystem &sourceCs, const Coordinate &crdSource) const { //TODO isLatLon guard doesn't consider latlon cs other than WGS84! if (sourceCs->id() == id()) // the 'real'isEqual test is too expensive here, as this method can be called 100000's of times (resample) return crdSource; LatLon ll = sourceCs->isLatLon() ? LatLon(crdSource.y,crdSource.x) : sourceCs->coord2latlon(crdSource); if (ll.isValid()) { if (hasType(sourceCs->ilwisType(), itCONVENTIONALCOORDSYSTEM)) { const IConventionalCoordinateSystem & srcCs = sourceCs.as<ConventionalCoordinateSystem>(); if (srcCs->datum().get() && datum().get() && !srcCs->datum()->equal(*datum().get())) { // different datums given, datum shift needed ll = srcCs->datum()->llToWGS84(ll, *srcCs->ellipsoid().ptr()); ll = datum()->llFromWGS84(ll, *ellipsoid().ptr()); } } return isLatLon() ? ll : latlon2coord(ll); } return Coordinate(); }