36 static ossimTrace traceDebug(
"ossimGmlSupportData:debug");
38 #define UNKNOWN_PCSCODE 32767 46 m_srsNameStringMap(
"http://www.opengis.net/def/crs/EPSG/0/32767"),
47 m_srsNameStringGeo(
"http://www.opengis.net/def/crs/EPSG/0/32767"),
48 m_srsDimensionString(
"2"),
49 m_axisLabelsStringMap(
"X Y"),
50 m_axisLabelsStringGeo(
"Lat Long"),
51 m_uomLabelsStringMap(
"m m"),
52 m_uomLabelsStringGeo(
"deg deg")
81 static const char MODULE[] =
"ossimGmlSupportData::initialize(geom)";
90 if ( mapProj.
valid() )
98 os <<
"http://www.opengis.net/def/crs/EPSG/0/" <<
m_pcsCodeMap;
121 status = configureGmljp2V1( rootNode, geom, rect );
134 << MODULE <<
" DEBUG Entered...\n";
151 getLimits( geom, gridHighString, gridLowString );
158 path =
"RectifiedGrid";
170 path =
"GridEnvelope";
187 bool success =
false;
190 if ( mapProj.
valid() )
202 getLimits( rect, gridHighString, gridLowString );
218 path =
"rangeParameters";
226 path =
"fileStructure";
230 path =
"gmlcov:rangeType";
234 path =
"gmljp2:featureMember";
238 path =
"gmljp2:GMLJP2RectifiedGridCoverage";
244 value =
"CodeStream_0";
252 path =
"RectifiedGrid";
277 path =
"GridEnvelope";
320 offsetVector1String, offsetVector2String );
325 offsetVector1String, offsetVector2String );
332 path =
"offsetVector";
342 path =
"offsetVector";
359 path =
"rangeParameters";
367 path =
"fileStructure";
387 getGeoBounds( geom, rect, upperCornerString, lowerCornerString );
414 name =
"srsDimension";
418 path =
"lowerCorner";
422 path =
"upperCorner";
433 ossimString os =
"gmljp2:GMLJP2CoverageCollection";
442 value =
"JPEG2000_0";
448 value =
"http://www.opengis.net/gml/3.2";
454 value =
"http://www.opengis.net/gml/3.2";
459 name =
"xmlns:gmlcov";
460 value =
"http://www.opengis.net/gmlcov/1.0";
465 name =
"xmlns:gmljp2";
466 value =
"http://www.opengis.net/gmljp2/2.0";
472 value =
"http://www.w3.org/2001/XMLSchema-instance";
477 name =
"xsi:schemaLocation";
478 value =
"http://www.opengis.net/gmljp2/2.0 http://schemas.opengis.net/gmljp2/2.0/gmljp2.xsd";
499 value =
"http://www.opengis.net/gml";
505 value =
"http://www.opengis.net/gml";
511 value =
"http://www.w3.org/2001/XMLSchema-instance";
516 name =
"xsi:schemaLocation";
517 value =
"http://www.opengis.net/gml gmlJP2Profile.xsd";
563 vector< ossimRefPtr<ossimXmlNode> > xml_nodes;
564 bool gotSensorImage =
false;
565 bool gotRectifiedImage =
false;
570 ossimString xpath_root =
"/gmljp2:GMLJP2CoverageCollection";
573 if ( xml_nodes.size() == 0 )
576 xpath_root =
"/GMLJP2CoverageCollection";
579 if ( xml_nodes.size() >= 1 )
581 const ossimString defaultNamespaceIdentifierStr(
"xmlns" );
582 ossimString defaultNamespacePrependStr = defaultNamespaceIdentifierStr +
":";
589 size_t nAttributes = attributeList.
size();
590 for (
size_t i=0; i<nAttributes; ++i )
597 if ( attribute_name != defaultNamespaceIdentifierStr &&
598 attribute_value == defaultNamespaceSettingStr )
600 defaultNamespaceStr = attribute_name.
after( defaultNamespacePrependStr );
601 defaultNamespaceStr +=
":";
607 ossimString xpath0 =
"/gmljp2:GMLJP2CoverageCollection/gmljp2:featureMember/gmljp2:GMLJP2ReferenceableGridCoverage/gml:domainSet/gmlcov:ReferenceableGridBySensorModel";
611 if ( xml_nodes.size() >= 1 )
614 gotSensorImage =
true;
619 ossimString pcsCodeDefinitionStr(
"http://www.opengis.net/def/crs/EPSG/0/" );
621 xpath0 =
"/gmljp2:GMLJP2CoverageCollection/gmljp2:featureMember/gmljp2:GMLJP2RectifiedGridCoverage/gml:domainSet/gml:RectifiedGrid";
625 if ( xml_nodes.size() >= 1 )
628 gotRectifiedImage =
true;
632 ossimString pcsCodeGridStr = originSrsName.
after( pcsCodeDefinitionStr.string() );
633 pcsCodeGrid = pcsCodeGridStr.
toUInt32();
634 if ( pcsCodeGrid != 32767 )
641 if ( pcsCodeGrid != 4326 )
645 pcsCodeGridStr.
c_str() );
658 ossimString xpath_limits_low =
"/gml:limits/gml:GridEnvelope/gml:low";
659 ossimString xpath_limits_high =
"/gml:limits/gml:GridEnvelope/gml:high";
661 xpath_limits_low = xpath_limits_low.
replaceAllThatMatch( defaultNamespaceStr.c_str(),
"" );
662 xpath_limits_high = xpath_limits_high.
replaceAllThatMatch( defaultNamespaceStr.c_str(),
"" );
669 if ( xml_nodes.size() == 1 )
671 const ossimString& lowerCorner = xml_nodes[0]->getText();
672 size_t spacePos = lowerCorner.
find(
' ' );
680 bool gotHigh =
false;
683 xpath = xpath0 + xpath_limits_high;
686 if ( xml_nodes.size() == 1 )
688 const ossimString& higherCorner = xml_nodes[0]->getText();
689 size_t spacePos = higherCorner.
find(
' ' );
692 highX = higherXString.
toInt32();
693 highY = higherYString.
toInt32();
697 if ( gotHigh && gotLow )
703 if ( gotSensorImage )
709 ossimString xpath_sensor_model =
"/gmlcov:sensorModel";
710 xpath_sensor_model = xpath_sensor_model.
replaceAllThatMatch( defaultNamespaceStr.c_str(),
"" );
711 xpath = xpath0 + xpath_sensor_model;
714 if ( xml_nodes.size() == 1 )
717 sensorModelHref = hrefAttribute->
getValue();
721 ossimString xpath_sensor_typeOf =
"/gmlcov:sensorInstance/sml:SimpleProcess/sml:typeOf";
722 xpath_sensor_typeOf = xpath_sensor_typeOf.
replaceAllThatMatch( defaultNamespaceStr.c_str(),
"" );
723 xpath = xpath0 + xpath_sensor_typeOf;
726 if ( xml_nodes.size() == 1 )
729 sensorInstanceHref = hrefAttribute->
getValue();
733 ossimString xpath_sensor_name =
"/gmlcov:sensorInstance/sml:SimpleProcess/gml:name";
734 xpath_sensor_name = xpath_sensor_name.
replaceAllThatMatch( defaultNamespaceStr.c_str(),
"" );
735 xpath = xpath0 + xpath_sensor_name;
738 int nSensorNames = (int)xml_nodes.size();
739 for (
int i=0; i<nSensorNames; ++i )
741 const ossimString& sensorName = xml_nodes[i]->getText();
748 if ( sensor_model.
valid() )
755 if ( !sensor_model.
valid() )
762 if ( sensorModelHref == sensorInstanceHref )
767 ossimString xpath_setValue =
"/gmlcov:sensorInstance/sml:SimpleProcess/sml:configuration/sml:Settings/sml:setValue";
769 xpath = xpath0 + xpath_setValue;
772 size_t nXmlNodes = xml_nodes.size();
773 for(
size_t i=0; i<nXmlNodes; ++i )
775 const ossimString& elementValue = xml_nodes[i]->getText();
780 bool successSetValue = sensor_model->
getImageGeometry( settingsRef, elementValue, geomKwl );
781 success &= successSetValue;
782 if ( !successSetValue )
789 ossimString xpath_setArrayValues =
"/gmlcov:sensorInstance/sml:SimpleProcess/sml:configuration/sml:Settings/sml:setArrayValues";
790 xpath_setArrayValues = xpath_setArrayValues.
replaceAllThatMatch( defaultNamespaceStr.c_str(),
"" );
791 xpath = xpath0 + xpath_setArrayValues;
794 nXmlNodes = xml_nodes.size();
795 for(
size_t i=0; i<nXmlNodes; ++i )
803 if ( children.size() > 0 )
807 if ( (grandchildren.size() > 1) && (grandchildren[1]->getTag() ==
ossimString(
"sml:value")) )
809 elementValue = grandchildren[1]->getText();
813 bool successSetArrayValues = sensor_model->
getImageGeometry( settingsRef, elementValue, geomKwl );
814 success &= successSetArrayValues;
815 if ( !successSetArrayValues )
822 else if ( gotRectifiedImage )
825 ossimString pcsCodeDefinitionStr(
"http://www.opengis.net/def/crs/EPSG/0/" );
830 xpath_axisLabels = xpath_axisLabels.
replaceAllThatMatch( defaultNamespaceStr.c_str(),
"" );
836 if ( xml_nodes.size() == 1 )
838 ossimString axisLabelsString = xml_nodes[0]->getText();
839 size_t spacePos = axisLabelsString.
find(
' ' );
840 firstAxisLabelString = axisLabelsString.
beforePos( spacePos );
841 secondAxisLabelString = axisLabelsString.
afterPos ( spacePos );
844 success = addTieAndScale( geomKwl );
852 ossimString xpath_originPoint =
"/gml:origin/gml:Point";
853 xpath_originPoint = xpath_originPoint.
replaceAllThatMatch( defaultNamespaceStr.c_str(),
"" );
854 xpath = xpath0 + xpath_originPoint;
857 if ( xml_nodes.size() == 1 )
860 size_t spacePos = originString.
find(
' ' );
865 ossimString pcsCodeOriginStr = originSrsName.
after( pcsCodeDefinitionStr.string() );
866 pcsCodeOrigin = pcsCodeOriginStr.
toUInt32();
868 if ( pcsCodeOrigin != 32767 )
870 std::string tie_point_xy;
871 std::string tie_point_units;
873 if ( pcsCodeOrigin == 4326 )
876 tie_point_units =
"degrees";
880 tie_point_units =
"meters";
883 if ( ( tie_point_units ==
"degrees" ) &&
884 ( firstAxisLabelString ==
"Lat" ) )
887 tie_point_xy += secondOriginString.
string();
889 tie_point_xy += firstOriginString.
string();
895 tie_point_xy += firstOriginString.
string();
897 tie_point_xy += secondOriginString.
string();
910 ossimString xpath_offsetVector =
"/gml:offsetVector";
911 xpath_offsetVector = xpath_offsetVector.
replaceAllThatMatch( defaultNamespaceStr.c_str(),
"" );
912 xpath = xpath0 + xpath_offsetVector;
916 if ( xml_nodes.size() )
918 const ossimString& offsetVectorString = xml_nodes[0]->getText();
919 size_t spacePos = offsetVectorString.
find(
' ' );
926 ossimString pcsCodeOffsetVectorStr = offsetVectorSrsName.
after( pcsCodeDefinitionStr.string() );
929 if ( pcsCodeOffsetVector != 32767 )
931 std::string scale_xy;
932 std::string scale_units;
933 if ( pcsCodeOffsetVector == 4326 )
935 scale_units =
"degrees";
939 scale_units =
"meters";
942 if ( ( scale_units ==
"degrees" ) && ( firstAxisLabelString ==
"Lat" ) )
945 scale_xy += secondOffsetVectorString.
c_str();
947 scale_xy += firstOffsetVectorString.
c_str();
953 scale_xy += firstOffsetVectorString.
c_str();
955 scale_xy += secondOffsetVectorString.
c_str();
990 os << tie.
lat <<
" " << tie.
lon;
991 originString = os.str();
995 os2 << -gsd.
y <<
" " <<
"0.0";
996 offsetVector1String =
os2.str();
1000 os3 <<
"0.0" <<
" " << gsd.
x;
1001 offsetVector2String = os3.str();
1017 if ( mapProj.
valid() != 0 )
1027 os << tie.
x <<
" " << tie.
y;
1028 originString = os.str();
1037 os2 << gsdMap.
x <<
" " <<
"0.0";
1038 offsetVector1String =
os2.str();
1042 os3 <<
"0.0" <<
" " << -gsdMap.
y;
1043 offsetVector2String = os3.str();
1056 if ( mapProj.
valid() )
1066 os << ulGpt.
lat <<
" " << ulGpt.
lon;
1067 upperCornerString = os.str();
1072 lowerCornerString =
os2.str();
1082 if ( rect.
hasNans() == false )
1085 gridLowString =
"0 0";
1091 os << (w-1) <<
" " << (h-1);
1092 gridHighString = os.str();
1102 vector< ossimRefPtr<ossimXmlNode> > xml_nodes;
1103 ossimString xpath0 =
"/gmljp2:GMLJP2CoverageCollection/gmljp2:featureMember/gmljp2:GMLJP2ReferenceableGridCoverage/gml:domainSet/gmlcov:ReferenceableGridBySensorModel";
1106 if ( xml_nodes.size() >= 1 )
1123 bool useGmlPrefix =
false;
1125 vector< ossimRefPtr<ossimXmlNode> > xml_nodes;
1127 ossimString xpath0 =
"/gmljp2:GMLJP2CoverageCollection/gmljp2:featureMember/gmljp2:GMLJP2RectifiedGridCoverage/domainSet/RectifiedGrid";
1129 if ( !xml_nodes.size() )
1131 xpath0 =
"/gmljp2:GMLJP2CoverageCollection/gmljp2:featureMember/gmljp2:GMLJP2RectifiedGridCoverage/gml:domainSet/gml:RectifiedGrid";
1133 if ( xml_nodes.size() )
1135 useGmlPrefix =
true;
1139 if ( xml_nodes.size() )
1142 const ossimString PCS_CODE_DEFINITION_STR(
"http://www.opengis.net/def/crs/EPSG/0/" );
1145 xml_nodes[0]->findAttribute( SRS_NAME );
1151 if ( pcsCode != 32767 )
1155 if ( pcsCode == 4326 )
1158 srsName += pcsCodeStr;
1165 if (
addTie( xpath0, useGmlPrefix, pcsCode, geomKwl ) )
1185 vector< ossimRefPtr<ossimXmlNode> > xml_nodes;
1191 xpath_limits_low =
"/gml:limits/gml:GridEnvelope/gml:low";
1195 xpath_limits_low =
"/limits/GridEnvelope/low";
1199 if ( xml_nodes.size() == 1 )
1201 const ossimString& lowerCorner = xml_nodes[0]->getText();
1202 size_t spacePos = lowerCorner.
find(
' ' );
1211 xpath_limits_high =
"/gml:limits/gml:GridEnvelope/gml:high";
1215 xpath_limits_high =
"/limits/GridEnvelope/high";
1218 xpath = xpath0 + xpath_limits_high;
1221 if ( xml_nodes.size() == 1 )
1223 const ossimString& higherCorner = xml_nodes[0]->getText();
1224 size_t spacePos = higherCorner.
find(
' ' );
1251 vector< ossimRefPtr<ossimXmlNode> > xml_nodes;
1262 xpath_axisLabels =
"/gml:axisLabels";
1266 xpath_axisLabels =
"/axisLabels";
1271 if ( xml_nodes.size() == 1 )
1273 ossimString axisLabelsString = xml_nodes[0]->getText();
1279 xpath_originPoint =
"/gml:origin/gml:Point";
1283 xpath_originPoint =
"/origin/Point";
1286 xpath = xpath0 + xpath_originPoint;
1289 if ( xml_nodes.size() == 1 )
1292 size_t spacePos = originString.
find(
' ' );
1296 std::string tie_point_xy;
1297 std::string tie_point_units;
1299 if ( pcsCode == 4326 )
1302 tie_point_units =
"degrees";
1306 tie_point_units =
"meters";
1309 if ( ( tie_point_units ==
"degrees" ) &&
1310 ( axisLabelsString ==
"Lat Long" ) )
1313 tie_point_xy += secondOriginString.
string();
1314 tie_point_xy +=
",";
1315 tie_point_xy += firstOriginString.
string();
1316 tie_point_xy +=
")";
1321 tie_point_xy += firstOriginString.
string();
1322 tie_point_xy +=
",";
1323 tie_point_xy += secondOriginString.
string();
1324 tie_point_xy +=
")";
1347 vector< ossimRefPtr<ossimXmlNode> > xml_nodes;
1358 xpath_axisLabels =
"/gml:axisLabels";
1362 xpath_axisLabels =
"/axisLabels";
1367 if ( xml_nodes.size() == 1 )
1369 ossimString axisLabelsString = xml_nodes[0]->getText();
1374 xpath_offsetVector =
"/gml:offsetVector";
1378 xpath_offsetVector =
"/offsetVector";
1381 xpath = xpath0 + xpath_offsetVector;
1384 if ( xml_nodes.size() == 2 )
1386 const ossimString& offsetVectorString0 = xml_nodes[0]->getText();
1387 const ossimString& offsetVectorString1 = xml_nodes[1]->getText();
1389 size_t spacePos0 = offsetVectorString0.
find(
' ' );
1390 size_t spacePos1 = offsetVectorString1.
find(
' ' );
1399 std::string scale_xy;
1400 std::string scale_units;
1401 if ( pcsCode == 4326 )
1403 scale_units =
"degrees";
1407 scale_units =
"meters";
1411 if ( ( scale_units ==
"degrees" ) &&
1412 ( axisLabelsString ==
"Lat Long" ) )
1414 scale.
x = secondOffsetVectorString1.
toFloat64();
1415 scale.
y = firstOffsetVectorString0.
toFloat64();
1419 scale.
x = firstOffsetVectorString0.
toFloat64();
1420 scale.
y = secondOffsetVectorString1.
toFloat64();
1422 if ( scale.
y < 0.0 )
1427 if ( ( scale_units ==
"degrees" ) && ( scale.
x != scale.
y ) )
void clear()
Erases the entire container.
void getLimits(const ossimIrect &rect, ossimString &gridHighString, ossimString &gridLowString) const
void setTag(const ossimString &tag)
ossimString m_srsDimensionString
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
const ossimString & getName() const
static const ossimFilename NIL
This was taken from Wx widgets for performing touch and access date stamps.
Represents serializable keyword/value map.
void setNameValue(const ossimString &name, const ossimString &value)
const ossimMapProjection * getAsMapProjection() const
virtual ossim_uint32 getPcsCode() const
Returns the EPSG PCS code or 32767 if the projection is a custom (non-EPSG) projection.
ossimString m_srsNameStringGeo
ossimString afterPos(std::string::size_type pos) const
ossimString m_axisLabelsStringMap
ossim_uint32 height() const
~ossimGmlSupportData()
destructor
std::vector< ossimRefPtr< ossimXmlAttribute > > AttributeListType
static const char * NUMBER_LINES_KW
virtual bool isGeographic() const
bool addLineSamps(const ossimString &xpath0, bool useGmlPrefix, ossimKeywordlist &geomKwl) const
Adds line and sample to keyword list.
const ossimIpt & ul() const
ossim_uint32 toUInt32() const
const ossimString & getValue() const
ossimDpt getDegreesPerPixel() const
Returns the resolution of this image in degrees/pixel.
static const char * TYPE_KW
bool addTie(const ossimString &xpath0, bool useGmlPrefix, ossim_uint32 pcsCode, ossimKeywordlist &geomKwl) const
Adds tie point to keyword list.
bool write(std::ostream &os)
Write xml doc to stream.
ossimRefPtr< ossimXmlDocument > m_xmlDocument
std::vector< ossimRefPtr< ossimXmlNode > > ChildListType
ossim_int32 toInt32() const
static const char * PIXEL_SCALE_XY_KW
bool getImageGeometry(ossimKeywordlist &geomKwl) const
Extracts geometry info to keyword list.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
bool addScale(const ossimString &xpath0, bool useGmlPrefix, ossim_uint32 pcsCode, ossimKeywordlist &geomKwl) const
Adds tie and scale to keyword list.
ossimRefPtr< ossimXmlNode > getGmljp2V1RootNode() const
void getGeoBounds(const ossimImageGeometry *geom, const ossimIrect &rect, ossimString &upperCornerString, ossimString &lowerCornerString) const
ossimString replaceAllThatMatch(const char *regularExpressionPattern, const char *value="") const
ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
static const char * TIE_POINT_XY_KW
bool localToWorld(const ossimDpt &local_pt, ossimGpt &world_pt) const
Exposes the 3D projection from image to world coordinates.
std::string::size_type size() const
unsigned int ossim_uint32
ossimDpt getMetersPerPixel() const
Returns the GSD associated with this image in the active projection.
ossim_float64 toFloat64() const
ossimRefPtr< ossimXmlDocument > getXmlDoc() const
ossimGmlSupportData()
default constructor
ossimString m_axisLabelsStringGeo
ossimRefPtr< ossimXmlNode > getGmljp2V2RootNode() const
void getGeoOrigin(const ossimImageGeometry *geom, const ossimIpt &ul, ossimString &originString, ossimString &offsetVector1String, ossimString &offsetVector2String) const
const ossimIpt & lr() const
ossim_uint32 m_pcsCodeGeo
bool initialize(const ossimImageGeometry *geom, const ossimIrect &rect)
Initializes gml block from geometry file.
ossim_uint32 width() const
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
virtual ossimDpt forward(const ossimGpt &worldPoint) const =0
All map projections will convert the world coordinate to an easting northing (Meters).
static ossimProjectionFactoryRegistry * instance()
static const char * ORIGIN_LATITUDE_KW
static const char * PCS_CODE_KW
virtual bool getImageGeometry(const ossimString &, const ossimString &, ossimKeywordlist &) const
Extracts geometry info from a non-ossim key,value pair to an ossim keyword list.
std::basic_istream< char > istream
Base class for char input streams.
bool getImageGeometryFromRectifiedGrid(ossimKeywordlist &geomKwl) const
For map projected data:
ossimString toString(ossim_uint32 precision=15) const
ossimString m_srsNameStringMap
void getMapOrigin(const ossimImageGeometry *geom, const ossimIpt &ul, ossimString &originString, ossimString &offsetVector1String, ossimString &offsetVector2String) const
ossim_uint32 m_pcsCodeMap
ossimString beforePos(std::string::size_type pos) const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
bool read(std::istream &in)
void addAttribute(ossimRefPtr< ossimXmlAttribute > attribute)
bool configureGmljp2V2(ossimRefPtr< ossimXmlNode > node, const ossimImageGeometry *geom, const ossimIrect &rect)
void findNodes(const ossimString &xpath, std::vector< ossimRefPtr< ossimXmlNode > > &nodelist) const
Appends any matching nodes to the list supplied (should be empty):
ossimString after(const ossimString &str, std::string::size_type pos=0) const
METHOD: after(str, pos) Returns string immediately after the token str.
bool getImageGeometryFromSeonsorModel(ossimKeywordlist &geomKwl) const
For sensor model data:
ossimString m_uomLabelsStringGeo
void initRoot(ossimRefPtr< ossimXmlNode > node)
void addChildNode(ossimRefPtr< ossimXmlNode > node)
static const char * NUMBER_SAMPLES_KW
std::string::size_type find(const std::string &s, std::string::size_type pos=0) const
Searches for s as a substring of *this, beginning at character pos of *this.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
static const char * SRS_NAME_KW
std::basic_ostream< char > ostream
Base class for char output streams.
static const char * PIXEL_SCALE_UNITS_KW
bool configureBounds(ossimRefPtr< ossimXmlNode > node, const ossimImageGeometry *geom, const ossimIrect &rect)
static const char * TIE_POINT_UNITS_KW
const std::string & string() const