59 static const char MODULE[]=
"ossimNitfProjectionFactory::createProjection";
63 << MODULE <<
" DEBUG:" 64 <<
"\nfilename: " << filename
65 <<
"\nentryIdx: " << entryIdx
87 long imageIndex =
static_cast<long>(entryIdx);
107 << MODULE <<
" DEBUG:" 108 <<
"\ncoordinateSysetm: " << coordinateSystem
137 const char* prefix)
const 176 in.read((
char*)nitfFile, 4);
178 if ( (s ==
"NITF") || (s ==
"NSIF") )
195 if (coordinateSystem ==
"G" || coordinateSystem ==
"D")
199 else if( (coordinateSystem ==
"S") || (coordinateSystem ==
"U") ||
200 ( version !=
"02.00" && (coordinateSystem ==
"N") ) )
202 result =
makeUtm(imageHeader, coordinateSystem);
216 std::vector<ossimGpt> gpts(0);
217 std::vector<ossimGpt> geolobPts(0);
218 std::vector<ossimGpt> blockaPts(0);
219 std::vector<ossimGpt> igeoloPts(0);
240 if ( blockaPts.empty() )
244 if ( geographicLocation.
size() )
249 <<
"ossimNitfProjectionFactory::makeGeographic DEBUG:" 250 <<
"\ngeographicLocation: " << geographicLocation
254 if (coordinateSysetm ==
"G")
267 else if (coordinateSysetm ==
"D")
282 bool isSkewedFlag =
false;
283 if ( blockaPts.size() )
286 if ( (isSkewedFlag ==
false) && geolobPts.size() )
295 else if ( igeoloPts.size() )
298 if ( (isSkewedFlag ==
false) && geolobPts.size() )
308 if (gpts.size() == 4)
317 if ( !isSkewedFlag && (
ossim::abs(scaleTest.
y/scaleTest.
x) <= 1.000001))
328 if (traceDebug() && proj)
331 <<
"ossimNitfProjectionFactory::makeGeographic DEBUG:" 332 <<
"\nUpper left corner: " << gpts[0]
333 <<
"\nUpper right corner: " << gpts[1]
334 <<
"\nLower right corner: " << gpts[2]
335 <<
"\nLower left corner: " << gpts[3] <<
"\n";
349 bool isBilinear =
false;
354 if ( geographicLocation.
size() )
356 std::vector<ossimDpt> utmPoints;
359 char hemisphere =
'N';
362 if ( coordinateSystem ==
"U")
371 if(coordinateSystem ==
"S")
382 s.push_back(hemisphere);
384 <<
"ossimNitfProjectionFactory::makeUtm DEBUG" 385 <<
"\ngeo string: " << geographicLocation
386 <<
"\nutm zone: " << zone
387 <<
"\nhemisphere: " << hemisphere
392 <<
"utmPoints[" << utmPoints[i] << std::endl;
402 std::vector<ossimGpt> gpts;
439 if( (scale.
hasNans() ==
false)&&(!isBilinear) )
450 std::vector<ossimGpt> gpts;
456 <<
"ossimNitfProjectionFactory::makeUtm DEBUG:" 457 <<
"\nTie point from blocka: " << gpts[0]
462 tie.
x += scale.
x/2.0;
463 tie.
y -= scale.
y/2.0;
467 tie.
x = utmPoints[0].x + scale.
x/2.0;
468 tie.
y = utmPoints[0].y - scale.
y/2.0;
474 <<
"ossimNitfProjectionFactory::makeUtm DEBUG:" 475 <<
"\nTie point: " << tie
476 <<
"\nScale: " << scale
521 std::vector<ossimDpt>& utmPoints)
const 530 if ( mgrsLocationString.
size() >= 60 )
533 std::vector<std::string> mgrsStr(4);
534 mgrsStr[0] = mgrsLocationString.
substr(0, 15);
535 mgrsStr[1] = mgrsLocationString.
substr(15, 15);
536 mgrsStr[2] = mgrsLocationString.
substr(30, 15);
537 mgrsStr[3] = mgrsLocationString.
substr(45, 15);
572 const std::vector<ossimGpt>& gpts)
const 597 if (
x > 1.0 )
x = 1.0;
605 tiePoint.
latd(gpts[0].latd() - (scale.
y/2.0));
606 tiePoint.
lond(gpts[0].lond() + (scale.
x/2.0));
619 const std::vector<ossimGpt>& gpts)
const 650 const std::vector<ossimGpt>& gpts)
const 653 return !( (gpts[0].latd() == gpts[1].latd()) &&
654 (gpts[2].latd() == gpts[3].latd()) &&
655 (gpts[0].lond() == gpts[3].lond()) &&
656 (gpts[1].lond() == gpts[2].lond()) );
661 const std::vector<ossimDpt>& dpts)
const 663 return !( (dpts[0].y == dpts[1].y) &&
664 (dpts[2].
y == dpts[3].
y) &&
665 (dpts[0].x == dpts[3].x) &&
666 (dpts[1].
x == dpts[2].
x) );
672 std::vector<ossimGpt>& gpts)
const 687 <<
"ossimNitfProjectionFactory::getBlockaPoints DEBUG:" 688 <<
"\nBLOCKA tag not found." 735 <<
"ossimNitfProjectionFactory::getBlockaPoints DEBUG:" 737 for (
int i=0; i<4; ++i)
740 <<
"gpt[" << i <<
"] " << gpts[i] << std::endl;
749 std::vector<ossimGpt>& gpts)
const 751 static const char MODULE[] =
"ossimNitfProjectionFactory::getGeolobPoints";
755 << MODULE <<
" entered...\n";
770 if ( (gsd.x > 0.0 ) && (gsd.y > 0.0) )
774 if ( (rows > 0) && (cols > 0) )
782 <<
"origin: " << origin
783 <<
"\ngsd: " << gsd <<
"\n";
794 gpt.
lond(origin.x + cols*gsd.x);
798 gpt.
latd(origin.y - rows*gsd.y);
799 gpt.
lond(origin.x + cols*gsd.x);
803 gpt.
latd(origin.y - rows*gsd.y);
812 else if (traceDebug())
815 <<
"No GEOLOB tag found.\n";
822 << MODULE <<
" exit status: " << (result?
"true":
"false") <<
"\n";
830 const std::vector<ossimGpt>& gpts,
844 double longitudeSize = 0.0;
845 double latitudeSize = 0.0;
846 if ( (gpts[1].lond() < 0.0) && (gpts[0].lond() >= 0) )
852 longitudeSize = (gpts[1].lond() + 360.0) - gpts[0].lond();
856 longitudeSize = gpts[1].lond() - gpts[0].lond();
859 latitudeSize = gpts[0].latd() - gpts[2].latd();
861 double rows = imageRect.
height();
862 double cols = imageRect.
width();
871 scale.
y = latitudeSize / rows;
872 scale.
x = longitudeSize / cols;
877 const std::vector<ossimDpt>& dpts,
891 double eastingSize = 0.0;
892 double northingSize = 0.0;
894 eastingSize = fabs(dpts[1].
x - dpts[0].
x);
895 northingSize = fabs(dpts[0].
y - dpts[3].
y);
897 double rows = imageRect.
height();
898 double cols = imageRect.
width();
905 scale.
y = northingSize / rows;
906 scale.
x = eastingSize / cols;
911 std::vector<ossimDpt>& utmPoints)
const 920 utmLocation.
begin() + idx + 2);
923 utmLocation.
begin() + idx + 6);
926 utmLocation.
begin() + idx + 7);
933 utmLocation.
begin() + idx + 2);
936 utmLocation.
begin() + idx + 6);
939 utmLocation.
begin() + idx + 7);
945 utmLocation.
begin() + idx + 2);
948 utmLocation.
begin() + idx + 6);
951 utmLocation.
begin() + idx + 7);
957 utmLocation.
begin() + idx + 2);
960 utmLocation.
begin() + idx + 6);
963 utmLocation.
begin() + idx + 7);
973 const ossimString& geographicLocation, std::vector<ossimGpt>& gpts)
const 977 if (geographicLocation.
size() != 60)
982 std::string::size_type geo_index = 0;
983 for (
int i=0; i<4; ++i)
992 std::string::size_type lat_index = 0;
993 std::string::size_type lon_index = 0;
994 const char SPACE =
' ';
999 latString[lat_index++] = geographicLocation[geo_index++];
1000 latString[lat_index++] = geographicLocation[geo_index++];
1004 latString[lat_index++] = geographicLocation[geo_index++];
1005 latString[lat_index++] = geographicLocation[geo_index++];
1009 latString[lat_index++] = geographicLocation[geo_index++];
1010 latString[lat_index++] = geographicLocation[geo_index++];
1014 latString[lat_index++] = geographicLocation[geo_index++];
1017 lonString[lon_index++] = geographicLocation[geo_index++];
1018 lonString[lon_index++] = geographicLocation[geo_index++];
1019 lonString[lon_index++] = geographicLocation[geo_index++];
1023 lonString[lon_index++] = geographicLocation[geo_index++];
1024 lonString[lon_index++] = geographicLocation[geo_index++];
1028 lonString[lon_index++] = geographicLocation[geo_index++];
1029 lonString[lon_index++] = geographicLocation[geo_index++];
1033 lonString[lon_index++] = geographicLocation[geo_index++];
1054 gpts.push_back(gpt);
1059 <<
"ossimNitfProjectionFactory::parseGeographicString DEBUG:" 1060 <<
"\nground point[" << i <<
"]: " << gpt
1067 std::vector<ossimGpt>& gpts)
const 1069 const char* bufPtr = geographicLocation.
c_str();
1104 <<
"ossimNitfProjectionFactory::parseDecimalDegreesString DEBUG:" 1105 <<
"\nground point[" << 0 <<
"]: " << gpts[0]
1106 <<
"\nground point[" << 1 <<
"]: " << gpts[1]
1107 <<
"\nground point[" << 2 <<
"]: " << gpts[2]
1108 <<
"\nground point[" << 3 <<
"]: " << gpts[3]
virtual ossimGpt inverse(const ossimDpt &eastingNorthing) const
Will take a point in meters and convert it to ground.
void computeScaleInDecimalDegrees(const ossimNitfImageHeader *hdr, const std::vector< ossimGpt > &gpts, ossimDpt &scale) const
Computes the scale in decimal degrees with scale.x being longitude, y being latitude.
ossimProjection * createProjectionFromGeometryFile(const ossimFilename &imageFile, ossim_uint32 entryIdx) const
This method takes the filename and tries to find an external ".geom" file.
ossimString getFrlcLoc() const
ossimNitfImageHeader * getNewImageHeader(ossim_uint32 imageNumber) const
ossimString getFrfcLoc() const
ossim_float64 getDegreesPerPixelLon() const
Gets degrees per pixel in lonitude direction from BRV field.
double lond() const
Will convert the radian measure to degrees.
Represents serializable keyword/value map.
std::basic_ifstream< char > ifstream
Class for char input file streams.
virtual ~ossimNitfProjectionFactory()
destructor
void parseUtmString(const ossimString &utmLocation, ossim_uint32 &zone, std::vector< ossimDpt > &utmPoints) const
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
ossimProjection * makeGeographic(const ossimNitfImageHeader *hdr, const ossimString &coordinateSysetm) const
ossim_uint32 height() const
ossimProjection * makeBilinear(const ossimNitfImageHeader *hdr, const std::vector< ossimGpt > &gpts) const
virtual ossimObject * createObject(const ossimString &typeName) const
Creates an object given a type name.
virtual void setDecimalDegreesPerPixel(const ossimDpt &gsd)
ossim_uint32 toUInt32() const
double latd() const
Will convert the radian measure to degrees.
static ossimNitfProjectionFactory * theInstance
ossimString getLrfcLoc() const
virtual void setMetersPerPixel(const ossimDpt &gsd)
ossim_float64 getPso() const
Gets the PSO field(Latitude Origin).
ossimProjection * makeEuiDistant(const ossimNitfImageHeader *hdr, const std::vector< ossimGpt > &gpts) const
void push_back(char c)
Equivalent to insert(end(), c).
bool parseMgrsString(const ossimString &mgrsLocationString, ossim_uint32 &zone, char &hemisphere, std::vector< ossimDpt > &utmPoints) const
Gets UTM points, zone and hemisphere from IGEOLO field when ICORDS files = U which is UTM expressed i...
virtual void setUlEastingNorthing(const ossimDpt &ulEastingNorthing)
virtual const ossimFilename & getFilename() const
Returns the filename.
std::string::size_type size() const
os2<< "> n<< " > nendobj n
std::string::iterator begin()
virtual ossimDpt getMetersPerPixel() const =0
static ossimNitfProjectionFactory * instance()
METHOD: instance()
const ossimNitfFileHeader * getHeader() const
unsigned int ossim_uint32
ossimNitfProjectionFactory()
Private constructor, users must go through instance() method.
bool setDegrees(const std::string &value)
setDegrees(char*).
virtual ossim_uint32 getCurrentEntry() const
virtual void setOrigin(const ossimGpt &origin)
double getDegrees() const
ossimProjection * createProjectionFromHeaders(ossimNitfFileHeader *fileHeader, ossimNitfImageHeader *imageHeader) const
const ossimNitfImageHeader * getCurrentImageHeader() const
void computeScaleInMeters(const ossimNitfImageHeader *hdr, const std::vector< ossimDpt > &dpts, ossimDpt &scale) const
Computes the scale in meters with scale.x being easting, y being northing.
ossim_uint32 width() const
ossimString getLrlcLoc() const
ossim_float64 getLso() const
Gets the LSO field(Longitude Origin).
const ossimGpt & getOrigin() const
void setZone(const ossimGpt &ground)
OSSIM_DLL long Convert_OSSIM_MGRS_To_UTM(const char *MGRS, long *Zone, char *Hemisphere, double *Easting, double *Northing)
ossimNitfProjectionFactory & operator=(const ossimNitfProjectionFactory &rhs)
Private operator = to hide from use.
const ossimNitfFileHeader * getFileHeader() const
bool getGeolobPoints(const ossimNitfImageHeader *hdr, std::vector< ossimGpt > &gpts) const
This class defines an abstract Handler which all image handlers(loaders) should derive from...
virtual ossimDpt forward(const ossimGpt &wp) const
bool isNitf(const ossimFilename &filename) const
void parseDecimalDegreesString(const ossimString &geographicLocation, std::vector< ossimGpt > &gpts) const
Parses Decimal degree stream.
ossimDms & setLatFlag(bool latFlag)
bool isSkewed(const std::vector< ossimGpt > &gpts) const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
bool getBlockaPoints(const ossimNitfImageHeader *hdr, std::vector< ossimGpt > &gpts) const
virtual void setUlTiePoints(const ossimGpt &gpt)
std::string substr(std::string::size_type pos=0, std::string::size_type n=std::string::npos) const
Equivalent to basic_string(*this, pos, n).
bool parseFile(const ossimFilename &file)
ossim_float64 getDegreesPerPixelLat() const
Gets degrees per pixel in latitude direction from BRV field.
void parseGeographicString(const ossimString &geographicLocation, std::vector< ossimGpt > &gpts) const
Parses geographic stream.
virtual void getTypeNameList(std::vector< ossimString > &typeList) const
This should return the type name of all objects in all factories.
void setHemisphere(const ossimGpt &ground)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossimProjection * makeUtm(const ossimNitfImageHeader *hdr, const ossimString &coordinateSysetm) const
virtual ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const