OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimGmlSupportData.cpp
Go to the documentation of this file.
1 //---
2 //
3 // License: MIT
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author: David Burken
8 //
9 // Description: GML support data object.
10 //
11 //---
12 // $Id$
13 
15 #include <ossim/base/ossimDrect.h>
16 #include <ossim/base/ossimGrect.h>
17 #include <ossim/base/ossimIpt.h>
18 #include <ossim/base/ossimIrect.h>
21 #include <ossim/base/ossimNotify.h>
22 #include <ossim/base/ossimTrace.h>
32 
33 #include <iomanip>
34 #include <sstream>
35 
36 static ossimTrace traceDebug("ossimGmlSupportData:debug");
37 
38 #define UNKNOWN_PCSCODE 32767
39 
41  :
42  m_xmlDocument(0),
43  // m_use_gmljp2_version2(true),
44  m_pcsCodeMap(UNKNOWN_PCSCODE),
45  m_pcsCodeGeo(UNKNOWN_PCSCODE),
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")
53 {
54 }
55 
57 {
58 }
59 
61 {
62  bool status = false;
63 
64  if ( in.good() )
65  {
67  m_xmlDocument->read( in );
68  status = true;
69  }
70  else
71  {
72  m_xmlDocument = 0;
73  }
74 
75  return status;
76 }
77 
79  const ossimIrect& rect )
80 {
81  static const char MODULE[] = "ossimGmlSupportData::initialize(geom)";
82 
83  bool status = false;
84 
85  if ( geom )
86  {
87  // ossim_uint32 code = UNKNOWN_PCSCODE; // unknown code
88 
90  if ( mapProj.valid() )
91  {
92  // Get the PCS code:
93  m_pcsCodeMap = mapProj->getPcsCode();
94  m_pcsCodeGeo = mapProj->getPcsCode();
95 
96  // Create an SRS Name for the map projection
98  os << "http://www.opengis.net/def/crs/EPSG/0/" << m_pcsCodeMap;
99  m_srsNameStringMap = os.str();
100 
101  // Create an SRS Name for the projection datum
103  os2 << "http://www.opengis.net/def/crs/EPSG/0/" << m_pcsCodeGeo;
104  m_srsNameStringGeo = os2.str();
105 
107 
108  // if ( m_use_gmljp2_version2 == true )
109  // {
110 
112  m_xmlDocument->initRoot( rootNode );
113  status = configureGmljp2V2( rootNode, geom, rect );
114  // }
115 
116 #if 0
117  else
118  {
120  m_xmlDocument->initRoot( rootNode );
121  status = configureGmljp2V1( rootNode, geom, rect );
122  }
123 #endif
124 
125  // cout << "gmljp2Node: " << *(gmljp2Node.get()) << endl;
126 
127  // cout << "xmlDoc: " << *(m_xmlDocument.get()) << endl;
128  }
129  }
130 
131  if ( status == false )
132  {
134  << MODULE << " DEBUG Entered...\n";
135 
136  }
137 
138  return status;
139 
140 } // End: ossimGmlSupportData::initialize( geom, mapProj )
141 
142 #if 0
143 bool ossimGmlSupportData::configureGmljp2V1( ossimRefPtr<ossimXmlNode> node0,
144  const ossimImageGeometry* geom )
145 {
146  bool success = true;
147  const ossimString BLANK = "";
148 
149  ossimString gridHighString;
150  ossimString gridLowString;
151  getLimits( geom, gridHighString, gridLowString );
152 
153  configureBounds( node0, geom );
154 
155  ossimString path = "rectifiedGridDomain";
156  ossimRefPtr<ossimXmlNode> node2 = node0->addChildNode( path, BLANK );
157 
158  path = "RectifiedGrid";
159  ossimRefPtr<ossimXmlNode> node2a = node2->addChildNode( path, BLANK );
160 
162  ossimString name = "dimension";
163  ossimString value = "2";
164  attr1->setNameValue( name, value );
165  node2a->addAttribute( attr1 );
166 
167  path = "limit";
168  ossimRefPtr<ossimXmlNode> node2a1 = node2a->addChildNode( path, BLANK );
169 
170  path = "GridEnvelope";
171  ossimRefPtr<ossimXmlNode> node2a1a = node2a1->addChildNode( path, BLANK );
172 
173  path = "low";
174  ossimRefPtr<ossimXmlNode> node2a1a1 = node2a1a->addChildNode( path, gridLowString );
175 
176  path = "high";
177  ossimRefPtr<ossimXmlNode> node2a1a2 = node2a1a->addChildNode( path, gridHighString );
178 
179  return success;
180 }
181 #endif
182 
184  const ossimImageGeometry* geom,
185  const ossimIrect& rect )
186 {
187  bool success = false;
188 
190  if ( mapProj.valid() )
191  {
192  bool isGeographic = mapProj->isGeographic();
193 
194  const ossimString BLANK = "";
195 
197  ossimString name;
198  ossimString value;
199 
200  ossimString gridHighString;
201  ossimString gridLowString;
202  getLimits( rect, gridHighString, gridLowString );
203 
204  configureBounds( node0, geom, rect );
205 
206  ossimString path = "domainSet";
208  node0->addChildNode( path, BLANK );
209 
210  path = "rangeSet";
212  node0->addChildNode( path, BLANK );
213 
214  path = "File";
216  node3->addChildNode( path, BLANK );
217 
218  path = "rangeParameters";
219  ossimRefPtr<ossimXmlNode> node3a1 =
220  node3a->addChildNode( path, BLANK );
221 
222  path = "fileName";
223  ossimRefPtr<ossimXmlNode> node3a2 =
224  node3a->addChildNode( path, "gmljp2://codestream" );
225 
226  path = "fileStructure";
227  ossimRefPtr<ossimXmlNode> node3a3 =
228  node3a->addChildNode( path, "inapplicable" );
229 
230  path = "gmlcov:rangeType";
232  node0->addChildNode( path, BLANK );
233 
234  path = "gmljp2:featureMember";
236  node0->addChildNode( path, BLANK );
237 
238  path = "gmljp2:GMLJP2RectifiedGridCoverage";
240  node5->addChildNode( path, BLANK );
241 
242  attr = new ossimXmlAttribute();
243  name = "gml:id";
244  value = "CodeStream_0";
245  attr->setNameValue( name, value );
246  node5a->addAttribute( attr );
247 
248  path = "domainSet";
249  ossimRefPtr<ossimXmlNode> node5a1 =
250  node5a->addChildNode( path, BLANK );
251 
252  path = "RectifiedGrid";
253  ossimRefPtr<ossimXmlNode> node5a1a =
254  node5a1->addChildNode( path, BLANK );
255 
256  attr = new ossimXmlAttribute();
257  name = "gml:id";
258  value = "RG0001";
259  attr->setNameValue( name, value );
260  node5a1a->addAttribute( attr );
261 
262  attr = new ossimXmlAttribute();
263  name = "dimension";
264  value = "2";
265  attr->setNameValue( name, value );
266  node5a1a->addAttribute( attr );
267 
268  attr = new ossimXmlAttribute();
269  name = "srsName";
270  attr->setNameValue( name, m_srsNameStringMap );
271  node5a1a->addAttribute( attr );
272 
273  path = "limits";
274  ossimRefPtr<ossimXmlNode> node5a1a1 =
275  node5a1a->addChildNode( path, BLANK );
276 
277  path = "GridEnvelope";
278  ossimRefPtr<ossimXmlNode> node5a1a1a =
279  node5a1a1->addChildNode( path, BLANK );
280 
281  path = "low";
282  ossimRefPtr<ossimXmlNode> node5a1a1a1 =
283  node5a1a1a->addChildNode( path, gridLowString );
284 
285  path = "high";
286  ossimRefPtr<ossimXmlNode> node5a1a1a2 =
287  node5a1a1a->addChildNode( path, gridHighString );
288 
289  path = "axisLabels";
290  ossimRefPtr<ossimXmlNode> node5a1a2 =
291  node5a1a->addChildNode( path,
292  mapProj->isGeographic() ?
294 
295  path = "origin";
296  ossimRefPtr<ossimXmlNode> node5a1a3 =
297  node5a1a->addChildNode( path, BLANK );
298 
299  path = "Point";
300  ossimRefPtr<ossimXmlNode> node5a1a3a =
301  node5a1a3->addChildNode( path, BLANK );
302 
303  attr = new ossimXmlAttribute();
304  name = "gml:id";
305  value = "P0001";
306  attr->setNameValue( name, value );
307  node5a1a3a->addAttribute( attr );
308 
309  attr = new ossimXmlAttribute();
310  name = "srsName";
311  attr->setNameValue( name, m_srsNameStringMap );
312  node5a1a3a->addAttribute( attr );
313 
314  ossimString originString;
315  ossimString offsetVector1String;
316  ossimString offsetVector2String;
317  if ( isGeographic )
318  {
319  getGeoOrigin( geom, rect.ul(), originString,
320  offsetVector1String, offsetVector2String );
321  }
322  else
323  {
324  getMapOrigin( geom, rect.ul(), originString,
325  offsetVector1String, offsetVector2String );
326  }
327 
328  path = "pos";
329  ossimRefPtr<ossimXmlNode> node5a1a3a1 =
330  node5a1a3a->addChildNode( path, originString );
331 
332  path = "offsetVector";
333  ossimRefPtr<ossimXmlNode> node5a1a4 =
334  node5a1a->addChildNode( path, offsetVector1String );
335 
336  attr = new ossimXmlAttribute();
337  name = "srsName";
338  attr->setNameValue( name,
339  (isGeographic ? m_srsNameStringGeo : m_srsNameStringMap ) );
340  node5a1a4->addAttribute( attr );
341 
342  path = "offsetVector";
343  ossimRefPtr<ossimXmlNode> node5a1a5 =
344  node5a1a->addChildNode( path, offsetVector2String );
345 
346  attr = new ossimXmlAttribute();
347  name = "srsName";
348  attr->setNameValue( name, (isGeographic ? m_srsNameStringGeo : m_srsNameStringMap) );
349  node5a1a5->addAttribute( attr );
350 
351  path = "rangeSet";
352  ossimRefPtr<ossimXmlNode> node5a2 =
353  node5a->addChildNode( path, BLANK );
354 
355  path = "File";
356  ossimRefPtr<ossimXmlNode> node5a2a =
357  node5a2->addChildNode( path, BLANK );
358 
359  path = "rangeParameters";
360  ossimRefPtr<ossimXmlNode> node5a2a1 =
361  node5a2a->addChildNode( path, BLANK );
362 
363  path = "fileName";
364  ossimRefPtr<ossimXmlNode> node5a2a2 =
365  node5a2a->addChildNode( path, "gmljp2://codestream" );
366 
367  path = "fileStructure";
368  ossimRefPtr<ossimXmlNode> node5a2a3 =
369  node5a2a->addChildNode( path, "inapplicable" );
370 
371  success = true;
372  }
373 
374  return success;
375 }
376 
379  const ossimImageGeometry* geom,
380  const ossimIrect& rect)
381 {
382  bool success = true;
383  const ossimString BLANK = "";
384 
385  ossimString upperCornerString;
386  ossimString lowerCornerString;
387  getGeoBounds( geom, rect, upperCornerString, lowerCornerString );
388 
389  ossimString path = "boundedBy";
390  ossimRefPtr<ossimXmlNode> node1 = node0->addChildNode( path, BLANK );
391 
392  path = "Envelope";
393  ossimRefPtr<ossimXmlNode> node1a = node1->addChildNode( path, BLANK );
394 
396  ossimString name;
397 
398  attr = new ossimXmlAttribute();
399  name = "srsName";
400  attr->setNameValue( name, m_srsNameStringGeo );
401  node1a->addAttribute( attr );
402 
403  attr = new ossimXmlAttribute();
404  name = "axisLabels";
405  attr->setNameValue( name, m_axisLabelsStringGeo );
406  node1a->addAttribute( attr );
407 
408  attr = new ossimXmlAttribute();
409  name = "uomLabels";
410  attr->setNameValue( name, m_uomLabelsStringGeo );
411  node1a->addAttribute( attr );
412 
413  attr = new ossimXmlAttribute();
414  name = "srsDimension";
415  attr->setNameValue( name, m_srsDimensionString );
416  node1a->addAttribute( attr );
417 
418  path = "lowerCorner";
419  ossimRefPtr<ossimXmlNode> node1a1 =
420  node1a->addChildNode( path, lowerCornerString );
421 
422  path = "upperCorner";
423  ossimRefPtr<ossimXmlNode> node1a2 =
424  node1a->addChildNode( path, upperCornerString );
425 
426  return success;
427 }
428 
430 {
432 
433  ossimString os = "gmljp2:GMLJP2CoverageCollection";
434  node->setTag( os );
435 
437  ossimString name;
438  ossimString value;
439 
440  attr = new ossimXmlAttribute();
441  name = "gml:id";
442  value = "JPEG2000_0";
443  attr->setNameValue( name, value );
444  node->addAttribute( attr );
445 
446  attr = new ossimXmlAttribute();
447  name = "xmlns";
448  value = "http://www.opengis.net/gml/3.2";
449  attr->setNameValue( name, value );
450  node->addAttribute( attr );
451 
452  attr = new ossimXmlAttribute();
453  name = "xmlns:gml";
454  value = "http://www.opengis.net/gml/3.2";
455  attr->setNameValue( name, value );
456  node->addAttribute( attr );
457 
458  attr = new ossimXmlAttribute();
459  name = "xmlns:gmlcov";
460  value = "http://www.opengis.net/gmlcov/1.0";
461  attr->setNameValue( name, value );
462  node->addAttribute( attr );
463 
464  attr = new ossimXmlAttribute();
465  name = "xmlns:gmljp2";
466  value = "http://www.opengis.net/gmljp2/2.0";
467  attr->setNameValue( name, value );
468  node->addAttribute( attr );
469 
470  attr = new ossimXmlAttribute();
471  name = "xmlns:xsi";
472  value = "http://www.w3.org/2001/XMLSchema-instance";
473  attr->setNameValue( name, value );
474  node->addAttribute( attr );
475 
476  attr = new ossimXmlAttribute();
477  name = "xsi:schemaLocation";
478  value = "http://www.opengis.net/gmljp2/2.0 http://schemas.opengis.net/gmljp2/2.0/gmljp2.xsd";
479  attr->setNameValue( name, value );
480  node->addAttribute( attr );
481 
482  return node;
483 
484 } // ossimGmlSupportData::getGmljp2V2Node()
485 
487 {
489 
490  ossimString os = "gml:FeatureCollection";
491  node->setTag( os );
492 
494  ossimString name;
495  ossimString value;
496 
497  attr = new ossimXmlAttribute();
498  name = "xmlns";
499  value = "http://www.opengis.net/gml";
500  attr->setNameValue( name, value );
501  node->addAttribute( attr );
502 
503  attr = new ossimXmlAttribute();
504  name = "xmlns:gml";
505  value = "http://www.opengis.net/gml";
506  attr->setNameValue( name, value );
507  node->addAttribute( attr );
508 
509  attr = new ossimXmlAttribute();
510  name = "xmlns:xsi";
511  value = "http://www.w3.org/2001/XMLSchema-instance";
512  attr->setNameValue( name, value );
513  node->addAttribute( attr );
514 
515  attr = new ossimXmlAttribute();
516  name = "xsi:schemaLocation";
517  value = "http://www.opengis.net/gml gmlJP2Profile.xsd";
518  attr->setNameValue( name, value );
519  node->addAttribute( attr );
520 
521  return node;
522 
523 } // ossimGmlSupportData::getGmljp2V1Node()
524 
526 {
527  bool status = false;
528 
529  if ( m_xmlDocument.valid() )
530  {
531  os << *(m_xmlDocument.get());
532 
533  status = true;
534  }
535 
536  return status;
537 }
538 
540 {
541  return m_xmlDocument;
542 }
543 
545 {
546  // Try for map projected geometry first...
547  bool success = getImageGeometryFromRectifiedGrid( geomKwl );
548  if ( !success )
549  {
550  // Look for sensor model block.
552  }
553 
554  return success;
555 }
556 
557 #if 0 /* Please leave. (drb) */
558 
560 {
561  if ( m_xmlDocument.valid() )
562  {
563  vector< ossimRefPtr<ossimXmlNode> > xml_nodes;
564  bool gotSensorImage = false;
565  bool gotRectifiedImage = false;
566  ossim_uint32 pcsCodeGrid = 32767; // only applies to rectified
567 
568  // Check the GMLJP2CoverageCollection attributes for the default namespace.
569  ossimString defaultNamespaceStr( "" );
570  ossimString xpath_root = "/gmljp2:GMLJP2CoverageCollection";
571  xml_nodes.clear();
572  m_xmlDocument->findNodes( xpath_root, xml_nodes );
573  if ( xml_nodes.size() == 0 )
574  {
575  // check if the default namespace is gmljp2
576  xpath_root = "/GMLJP2CoverageCollection";
577  m_xmlDocument->findNodes( xpath_root, xml_nodes );
578  }
579  if ( xml_nodes.size() >= 1 )
580  {
581  const ossimString defaultNamespaceIdentifierStr( "xmlns" );
582  ossimString defaultNamespacePrependStr = defaultNamespaceIdentifierStr + ":";
583 
584  const ossimRefPtr<ossimXmlAttribute> defaultNamespaceAttribute = xml_nodes[0]->findAttribute( defaultNamespaceIdentifierStr );
585  ossimString defaultNamespaceSettingStr = defaultNamespaceAttribute->getValue();
586 
587  // search for the attribute value in the other attributes
588  const ossimXmlNode::AttributeListType& attributeList = xml_nodes[0]->getAttributes();
589  size_t nAttributes = attributeList.size();
590  for ( size_t i=0; i<nAttributes; ++i )
591  {
592  const ossimRefPtr<ossimXmlAttribute> attribute = attributeList[i];
593 
594  const ossimString& attribute_name = attribute->getName();
595  const ossimString& attribute_value = attribute->getValue();
596 
597  if ( attribute_name != defaultNamespaceIdentifierStr &&
598  attribute_value == defaultNamespaceSettingStr )
599  {
600  defaultNamespaceStr = attribute_name.after( defaultNamespacePrependStr );
601  defaultNamespaceStr += ":";
602  }
603  }
604  }
605 
606  // Check for a sensor image
607  ossimString xpath0 = "/gmljp2:GMLJP2CoverageCollection/gmljp2:featureMember/gmljp2:GMLJP2ReferenceableGridCoverage/gml:domainSet/gmlcov:ReferenceableGridBySensorModel";
608  xpath0 = xpath0.replaceAllThatMatch( defaultNamespaceStr.c_str(), "" );
609  xml_nodes.clear();
610  m_xmlDocument->findNodes( xpath0, xml_nodes );
611  if ( xml_nodes.size() >= 1 )
612  {
613  // we've got a sensor model image
614  gotSensorImage = true;
615  }
616  else
617  {
618  const ossimString srsNameStr( "srsName" );
619  ossimString pcsCodeDefinitionStr( "http://www.opengis.net/def/crs/EPSG/0/" );
620 
621  xpath0 = "/gmljp2:GMLJP2CoverageCollection/gmljp2:featureMember/gmljp2:GMLJP2RectifiedGridCoverage/gml:domainSet/gml:RectifiedGrid";
622  xpath0 = xpath0.replaceAllThatMatch( defaultNamespaceStr.c_str(), "" );
623  xml_nodes.clear();
624  m_xmlDocument->findNodes( xpath0, xml_nodes );
625  if ( xml_nodes.size() >= 1 )
626  {
627  // we've got a rectified image
628  gotRectifiedImage = true;
629 
630  const ossimRefPtr<ossimXmlAttribute> hrefAttribute = xml_nodes[0]->findAttribute( srsNameStr );
631  const ossimString& originSrsName = hrefAttribute->getValue();
632  ossimString pcsCodeGridStr = originSrsName.after( pcsCodeDefinitionStr.string() );
633  pcsCodeGrid = pcsCodeGridStr.toUInt32();
634  if ( pcsCodeGrid != 32767 )
635  {
636  //---
637  // The ossimEpsgProjectionFactory will not pick up the origin latitude if code is
638  // 4326 (geographic) so we use the projection name; else, the origin_latitude will
639  // always be 0. This is so the gsd comes out correct for scale.
640  //---
641  if ( pcsCodeGrid != 4326 ) // map projection
642  {
643  // Add the pcs code.
645  pcsCodeGridStr.c_str() );
646  }
647  else // geographic
648  {
650  ossimString( "ossimEquDistCylProjection" ) );
651  }
652  }
653  }
654  }
655 
656  // Number of lines & samples, for either sensor or rectified imagery
657 
658  ossimString xpath_limits_low = "/gml:limits/gml:GridEnvelope/gml:low";
659  ossimString xpath_limits_high = "/gml:limits/gml:GridEnvelope/gml:high";
660 
661  xpath_limits_low = xpath_limits_low.replaceAllThatMatch( defaultNamespaceStr.c_str(), "" );
662  xpath_limits_high = xpath_limits_high.replaceAllThatMatch( defaultNamespaceStr.c_str(), "" );
663 
664  bool gotLow = false;
665  ossim_int32 lowX, lowY;
666  ossimString xpath = xpath0 + xpath_limits_low;
667  xml_nodes.clear();
668  m_xmlDocument->findNodes( xpath, xml_nodes );
669  if ( xml_nodes.size() == 1 )
670  {
671  const ossimString& lowerCorner = xml_nodes[0]->getText();
672  size_t spacePos = lowerCorner.find( ' ' );
673  ossimString lowerXString = lowerCorner.beforePos( spacePos );
674  ossimString lowerYString = lowerCorner.afterPos ( spacePos );
675  lowX = lowerXString.toInt32();
676  lowY = lowerYString.toInt32();
677  gotLow = true;
678  }
679 
680  bool gotHigh = false;
681  ossim_int32 highX = 0;
682  ossim_int32 highY = 0;
683  xpath = xpath0 + xpath_limits_high;
684  xml_nodes.clear();
685  m_xmlDocument->findNodes( xpath, xml_nodes );
686  if ( xml_nodes.size() == 1 )
687  {
688  const ossimString& higherCorner = xml_nodes[0]->getText();
689  size_t spacePos = higherCorner.find( ' ' );
690  ossimString higherXString = higherCorner.beforePos( spacePos );
691  ossimString higherYString = higherCorner.afterPos ( spacePos );
692  highX = higherXString.toInt32();
693  highY = higherYString.toInt32();
694  gotHigh = true;
695  }
696 
697  if ( gotHigh && gotLow )
698  {
699  geomKwl.add( ossimKeywordNames::NUMBER_LINES_KW, highY - lowY + 1 );
700  geomKwl.add( ossimKeywordNames::NUMBER_SAMPLES_KW, highX - lowX + 1 );
701  }
702 
703  if ( gotSensorImage )
704  {
705  const ossimString hrefStr( "xlink:href" );
706  const ossimString codeSpaceStr( "codeSpace" );
707 
708  ossimString sensorModelHref( "" );
709  ossimString xpath_sensor_model = "/gmlcov:sensorModel";
710  xpath_sensor_model = xpath_sensor_model.replaceAllThatMatch( defaultNamespaceStr.c_str(), "" );
711  xpath = xpath0 + xpath_sensor_model;
712  xml_nodes.clear();
713  m_xmlDocument->findNodes( xpath, xml_nodes );
714  if ( xml_nodes.size() == 1 )
715  {
716  const ossimRefPtr<ossimXmlAttribute> hrefAttribute = xml_nodes[0]->findAttribute( hrefStr );
717  sensorModelHref = hrefAttribute->getValue();
718  }
719 
720  ossimString sensorInstanceHref( "" );
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;
724  xml_nodes.clear();
725  m_xmlDocument->findNodes( xpath, xml_nodes );
726  if ( xml_nodes.size() == 1 )
727  {
728  const ossimRefPtr<ossimXmlAttribute> hrefAttribute = xml_nodes[0]->findAttribute( hrefStr );
729  sensorInstanceHref = hrefAttribute->getValue();
730  }
731 
732  ossimRefPtr<ossimSensorModel> sensor_model = 0;
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;
736  xml_nodes.clear();
737  m_xmlDocument->findNodes( xpath, xml_nodes );
738  int nSensorNames = (int)xml_nodes.size();
739  for ( int i=0; i<nSensorNames; ++i )
740  {
741  const ossimString& sensorName = xml_nodes[i]->getText();
742 
744  ossimProjection* proj = registry->createProjection( sensorName );
745 
746  // Is it a sensor model ?
747  sensor_model = dynamic_cast<ossimSensorModel*>( proj );
748  if ( sensor_model.valid() )
749  {
750  geomKwl.add( ossimKeywordNames::TYPE_KW, sensorName.c_str() );
751  break;
752  }
753  }
754 
755  if ( !sensor_model.valid() )
756  {
757  // Add debug message
758  return false;
759  }
760 
761  // Check if the sensor instance is typeOf the sensor model
762  if ( sensorModelHref == sensorInstanceHref )
763  {
764  const ossimString refStr( "ref" );
765 
766  // sml:setValue
767  ossimString xpath_setValue = "/gmlcov:sensorInstance/sml:SimpleProcess/sml:configuration/sml:Settings/sml:setValue";
768  xpath_setValue = xpath_setValue.replaceAllThatMatch( defaultNamespaceStr.c_str(), "" );
769  xpath = xpath0 + xpath_setValue;
770  xml_nodes.clear();
771  m_xmlDocument->findNodes( xpath, xml_nodes );
772  size_t nXmlNodes = xml_nodes.size();
773  for( size_t i=0; i<nXmlNodes; ++i )
774  {
775  const ossimString& elementValue = xml_nodes[i]->getText();
776 
777  const ossimRefPtr<ossimXmlAttribute> refAttribute = xml_nodes[i]->findAttribute( refStr );
778  const ossimString& settingsRef = refAttribute->getValue();
779 
780  bool successSetValue = sensor_model->getImageGeometry( settingsRef, elementValue, geomKwl );
781  success &= successSetValue;
782  if ( !successSetValue )
783  {
784  // Add debug message
785  }
786  }
787 
788  /* sml:setArrayValues */
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;
792  xml_nodes.clear();
793  m_xmlDocument->findNodes( xpath, xml_nodes );
794  nXmlNodes = xml_nodes.size();
795  for( size_t i=0; i<nXmlNodes; ++i )
796  {
797  ossimString elementValue( "" );
798 
799  const ossimRefPtr<ossimXmlAttribute> refAttribute = xml_nodes[i]->findAttribute( refStr );
800  const ossimString& settingsRef = refAttribute->getValue();
801 
802  const ossimXmlNode::ChildListType& children = xml_nodes[i]->getChildNodes();
803  if ( children.size() > 0 )
804  {
805  const ossimXmlNode::ChildListType& grandchildren = children[0]->getChildNodes();
806 
807  if ( (grandchildren.size() > 1) && (grandchildren[1]->getTag() == ossimString( "sml:value")) )
808  {
809  elementValue = grandchildren[1]->getText();
810  }
811  }
812 
813  bool successSetArrayValues = sensor_model->getImageGeometry( settingsRef, elementValue, geomKwl );
814  success &= successSetArrayValues;
815  if ( !successSetArrayValues )
816  {
817  // Add debug message
818  }
819  }
820  }
821  }
822  else if ( gotRectifiedImage )
823  {
824  const ossimString srsNameStr( "srsName" );
825  ossimString pcsCodeDefinitionStr( "http://www.opengis.net/def/crs/EPSG/0/" );
826 
827  /* axis labels for rectified imagery */
828 
829  ossimString xpath_axisLabels = "/gml:axisLabels";
830  xpath_axisLabels = xpath_axisLabels.replaceAllThatMatch( defaultNamespaceStr.c_str(), "" );
831  ossimString firstAxisLabelString( "" );
832  ossimString secondAxisLabelString( "" );
833  ossimString xpath = xpath0 + xpath_axisLabels;
834  xml_nodes.clear();
835  m_xmlDocument->findNodes( xpath, xml_nodes );
836  if ( xml_nodes.size() == 1 )
837  {
838  ossimString axisLabelsString = xml_nodes[0]->getText();
839  size_t spacePos = axisLabelsString.find( ' ' );
840  firstAxisLabelString = axisLabelsString.beforePos( spacePos );
841  secondAxisLabelString = axisLabelsString.afterPos ( spacePos );
842  }
843 
844  success = addTieAndScale( geomKwl );
845 
846  //---
847  // origin:
848  // Note: In GML the origin is the tie point, NOT the projection origin.
849  //---
850 
851  ossim_uint32 pcsCodeOrigin = 32767;
852  ossimString xpath_originPoint = "/gml:origin/gml:Point";
853  xpath_originPoint = xpath_originPoint.replaceAllThatMatch( defaultNamespaceStr.c_str(), "" );
854  xpath = xpath0 + xpath_originPoint;
855  xml_nodes.clear();
856  m_xmlDocument->findNodes( xpath, xml_nodes );
857  if ( xml_nodes.size() == 1 )
858  {
859  const ossimString& originString = xml_nodes[0]->getChildTextValue( ossimString( "pos" ) );
860  size_t spacePos = originString.find( ' ' );
861  ossimString firstOriginString = originString.beforePos( spacePos );
862  ossimString secondOriginString = originString.afterPos ( spacePos );
863  const ossimRefPtr<ossimXmlAttribute> hrefAttribute = xml_nodes[0]->findAttribute( srsNameStr );
864  const ossimString& originSrsName = hrefAttribute->getValue();
865  ossimString pcsCodeOriginStr = originSrsName.after( pcsCodeDefinitionStr.string() );
866  pcsCodeOrigin = pcsCodeOriginStr.toUInt32();
867 
868  if ( pcsCodeOrigin != 32767 )
869  {
870  std::string tie_point_xy;
871  std::string tie_point_units;
872 
873  if ( pcsCodeOrigin == 4326 ) // map projection
874  {
875  // Longitude first, e.g. (lon,lat)
876  tie_point_units = "degrees";
877  }
878  else
879  {
880  tie_point_units = "meters";
881  }
882 
883  if ( ( tie_point_units == "degrees" ) &&
884  ( firstAxisLabelString == "Lat" ) )
885  {
886  tie_point_xy = "(";
887  tie_point_xy += secondOriginString.string();
888  tie_point_xy += ",";
889  tie_point_xy += firstOriginString.string();
890  tie_point_xy += ")";
891  }
892  else
893  {
894  tie_point_xy = "(";
895  tie_point_xy += firstOriginString.string();
896  tie_point_xy += ",";
897  tie_point_xy += secondOriginString.string();
898  tie_point_xy += ")";
899  }
900 
901  geomKwl.add( ossimKeywordNames::TIE_POINT_XY_KW, tie_point_xy.c_str() );
902  geomKwl.add( ossimKeywordNames::TIE_POINT_UNITS_KW, tie_point_units.c_str() );
903  }
904  }
905 
906  //---
907  // offset vector
908  // Note this is the scale:
909 
910  ossimString xpath_offsetVector = "/gml:offsetVector";
911  xpath_offsetVector = xpath_offsetVector.replaceAllThatMatch( defaultNamespaceStr.c_str(), "" );
912  xpath = xpath0 + xpath_offsetVector;
913  xml_nodes.clear();
914  m_xmlDocument->findNodes( xpath, xml_nodes );
915 
916  if ( xml_nodes.size() )
917  {
918  const ossimString& offsetVectorString = xml_nodes[0]->getText();
919  size_t spacePos = offsetVectorString.find( ' ' );
920  ossimString firstOffsetVectorString = offsetVectorString.beforePos( spacePos );
921  ossimString secondOffsetVectorString = offsetVectorString.afterPos ( spacePos );
922 
923 
924  const ossimRefPtr<ossimXmlAttribute> hrefAttribute = xml_nodes[0]->findAttribute( srsNameStr );
925  const ossimString& offsetVectorSrsName = hrefAttribute->getValue();
926  ossimString pcsCodeOffsetVectorStr = offsetVectorSrsName.after( pcsCodeDefinitionStr.string() );
927  ossim_uint32 pcsCodeOffsetVector = pcsCodeOffsetVectorStr.toUInt32();
928 
929  if ( pcsCodeOffsetVector != 32767 )
930  {
931  std::string scale_xy;
932  std::string scale_units;
933  if ( pcsCodeOffsetVector == 4326 )
934  {
935  scale_units = "degrees";
936  }
937  else
938  {
939  scale_units = "meters";
940  }
941 
942  if ( ( scale_units == "degrees" ) && ( firstAxisLabelString == "Lat" ) )
943  {
944  scale_xy = "(";
945  scale_xy += secondOffsetVectorString.c_str();
946  scale_xy += ",";
947  scale_xy += firstOffsetVectorString.c_str();
948  scale_xy += ")";
949  }
950  else
951  {
952  scale_xy = "(";
953  scale_xy += firstOffsetVectorString.c_str();
954  scale_xy += ",";
955  scale_xy += secondOffsetVectorString.c_str();
956  scale_xy += ")";
957  }
958 
959  geomKwl.add( ossimKeywordNames::PIXEL_SCALE_XY_KW, scale_xy.c_str() );
960  geomKwl.add( ossimKeywordNames::PIXEL_SCALE_UNITS_KW, scale_units.c_str() );
961  }
962  }
963  }
964  }
965 
966  return success;
967 
968 } // End: ossimGmlSupportData::getImageGeometry( geomKwl )
969 #endif
970 
972  const ossimImageGeometry* geom,
973  const ossimIpt& ul,
974  ossimString& originString,
975  ossimString& offsetVector1String,
976  ossimString& offsetVector2String ) const
977 {
978  if ( geom )
979  {
980  // Get the gsd:
981  ossimDpt gsd;
982  geom->getDegreesPerPixel( gsd );
983 
984  // Get tie point:
985  ossimGpt tie;
986  geom->localToWorld( ul, tie );
987 
989  os.precision(15);
990  os << tie.lat << " " << tie.lon;
991  originString = os.str();
992 
994  os2.precision(15);
995  os2 << -gsd.y << " " << "0.0";
996  offsetVector1String = os2.str();
997 
998  std::ostringstream os3;
999  os3.precision(15);
1000  os3 << "0.0" << " " << gsd.x;
1001  offsetVector2String = os3.str();
1002  }
1003 
1004 } // End: ossimGmlSupportData::getGeoOrigin
1005 
1006 
1008  const ossimImageGeometry* geom,
1009  const ossimIpt& ul,
1010  ossimString& originString,
1011  ossimString& offsetVector1String,
1012  ossimString& offsetVector2String ) const
1013 {
1014  if ( geom )
1015  {
1017  if ( mapProj.valid() != 0 )
1018  {
1019  // Get the tie point:
1020  ossimGpt gpt;
1021  geom->localToWorld( ul, gpt );
1022 
1023  ossimDpt tie = mapProj->forward( gpt );
1024 
1025  std::ostringstream os;
1026  os.precision(15);
1027  os << tie.x << " " << tie.y;
1028  originString = os.str();
1029  }
1030 
1031  // Get the projected CS gsd:
1032  ossimDpt gsdMap;
1033  geom->getMetersPerPixel( gsdMap );
1034 
1036  os2.precision(15);
1037  os2 << gsdMap.x << " " << "0.0";
1038  offsetVector1String = os2.str();
1039 
1040  std::ostringstream os3;
1041  os3.precision(15);
1042  os3 << "0.0" << " " << -gsdMap.y;
1043  offsetVector2String = os3.str();
1044  }
1045 
1046 } // End: ossimGmlSupportData::getMapBounds
1047 
1049  const ossimIrect& rect,
1050  ossimString& upperCornerString,
1051  ossimString& lowerCornerString ) const
1052 {
1053  if ( geom )
1054  {
1056  if ( mapProj.valid() )
1057  {
1058  // Get the bounding rect. This assumes North up.
1059  ossimGpt ulGpt;
1060  ossimGpt lrGpt;
1061  geom->localToWorld( rect.ul(), ulGpt );
1062  geom->localToWorld( rect.lr(), lrGpt );
1063 
1064  std::ostringstream os;
1065  os.precision(15);
1066  os << ulGpt.lat << " " << ulGpt.lon;
1067  upperCornerString = os.str();
1068 
1070  os2.precision(15);
1071  os2 << lrGpt.lat << " " << lrGpt.lon;
1072  lowerCornerString = os2.str();
1073  }
1074  }
1075 
1076 } // End: ossimGmlSupportData::getGeoBounds
1077 
1079  ossimString& gridHighString,
1080  ossimString& gridLowString ) const
1081 {
1082  if ( rect.hasNans() == false )
1083  {
1084  // Zero based image rect.
1085  gridLowString = "0 0";
1086 
1087  ossim_uint32 w = rect.width();
1088  ossim_uint32 h = rect.height();
1089 
1090  std::ostringstream os;
1091  os << (w-1) << " " << (h-1);
1092  gridHighString = os.str();
1093  }
1094 }
1095 
1097 {
1098  bool status = false;
1099 
1100  if ( m_xmlDocument.valid() )
1101  {
1102  vector< ossimRefPtr<ossimXmlNode> > xml_nodes;
1103  ossimString xpath0 = "/gmljp2:GMLJP2CoverageCollection/gmljp2:featureMember/gmljp2:GMLJP2ReferenceableGridCoverage/gml:domainSet/gmlcov:ReferenceableGridBySensorModel";
1104 
1105  m_xmlDocument->findNodes( xpath0, xml_nodes );
1106  if ( xml_nodes.size() >= 1 )
1107  {
1108  // Put sensor model code here...
1109 
1110  status = true;
1111  }
1112  }
1113 
1114  return status;
1115 }
1116 
1118 {
1119  bool status = false;
1120 
1121  if ( m_xmlDocument.valid() )
1122  {
1123  bool useGmlPrefix = false;
1124 
1125  vector< ossimRefPtr<ossimXmlNode> > xml_nodes;
1126 
1127  ossimString xpath0 = "/gmljp2:GMLJP2CoverageCollection/gmljp2:featureMember/gmljp2:GMLJP2RectifiedGridCoverage/domainSet/RectifiedGrid";
1128  m_xmlDocument->findNodes( xpath0, xml_nodes );
1129  if ( !xml_nodes.size() )
1130  {
1131  xpath0 = "/gmljp2:GMLJP2CoverageCollection/gmljp2:featureMember/gmljp2:GMLJP2RectifiedGridCoverage/gml:domainSet/gml:RectifiedGrid";
1132  m_xmlDocument->findNodes( xpath0, xml_nodes );
1133  if ( xml_nodes.size() )
1134  {
1135  useGmlPrefix = true;
1136  }
1137  }
1138 
1139  if ( xml_nodes.size() )
1140  {
1141  const ossimString SRS_NAME( "srsName" );
1142  const ossimString PCS_CODE_DEFINITION_STR( "http://www.opengis.net/def/crs/EPSG/0/" );
1143 
1144  const ossimRefPtr<ossimXmlAttribute> hrefAttribute =
1145  xml_nodes[0]->findAttribute( SRS_NAME );
1146  const ossimString& originSrsName = hrefAttribute->getValue();
1147 
1148  ossimString pcsCodeStr = originSrsName.after( PCS_CODE_DEFINITION_STR.string() );
1149  ossim_uint32 pcsCode = pcsCodeStr.toUInt32();
1150 
1151  if ( pcsCode != 32767 )
1152  {
1153  // Add the pcs code.
1154  geomKwl.add( ossimKeywordNames::PCS_CODE_KW, pcsCodeStr.c_str() );
1155  if ( pcsCode == 4326 )
1156  {
1157  ossimString srsName = "EPSG:";
1158  srsName += pcsCodeStr;
1159  geomKwl.add( ossimKeywordNames::SRS_NAME_KW, srsName.c_str() );
1160  geomKwl.add( ossimKeywordNames::TYPE_KW, "ossimEquDistCylProjection");
1161  }
1162 
1163  if ( addLineSamps( xpath0, useGmlPrefix, geomKwl ) )
1164  {
1165  if ( addTie( xpath0, useGmlPrefix, pcsCode, geomKwl ) )
1166  {
1167  status = addScale( xpath0, useGmlPrefix, pcsCode, geomKwl );
1168  }
1169  }
1170  }
1171  }
1172  }
1173 
1174  return status;
1175 }
1176 
1178  bool useGmlPrefix,
1179  ossimKeywordlist& geomKwl ) const
1180 {
1181  bool status = false;
1182 
1183  if ( m_xmlDocument.valid() )
1184  {
1185  vector< ossimRefPtr<ossimXmlNode> > xml_nodes;
1186 
1187  // Number of lines & samples, for either sensor or rectified imagery:
1188  ossimString xpath_limits_low;
1189  if (useGmlPrefix)
1190  {
1191  xpath_limits_low = "/gml:limits/gml:GridEnvelope/gml:low";
1192  }
1193  else
1194  {
1195  xpath_limits_low = "/limits/GridEnvelope/low";
1196  }
1197  ossimString xpath = xpath0 + xpath_limits_low;
1198  m_xmlDocument->findNodes( xpath, xml_nodes );
1199  if ( xml_nodes.size() == 1 )
1200  {
1201  const ossimString& lowerCorner = xml_nodes[0]->getText();
1202  size_t spacePos = lowerCorner.find( ' ' );
1203  ossimString lowerXString = lowerCorner.beforePos( spacePos );
1204  ossimString lowerYString = lowerCorner.afterPos ( spacePos );
1205  ossim_uint32 lowX = lowerXString.toInt32();
1206  ossim_uint32 lowY = lowerYString.toInt32();
1207 
1208  ossimString xpath_limits_high;
1209  if ( useGmlPrefix )
1210  {
1211  xpath_limits_high = "/gml:limits/gml:GridEnvelope/gml:high";
1212  }
1213  else
1214  {
1215  xpath_limits_high = "/limits/GridEnvelope/high";
1216  }
1217 
1218  xpath = xpath0 + xpath_limits_high;
1219  xml_nodes.clear();
1220  m_xmlDocument->findNodes( xpath, xml_nodes );
1221  if ( xml_nodes.size() == 1 )
1222  {
1223  const ossimString& higherCorner = xml_nodes[0]->getText();
1224  size_t spacePos = higherCorner.find( ' ' );
1225  ossimString higherXString = higherCorner.beforePos( spacePos );
1226  ossimString higherYString = higherCorner.afterPos ( spacePos );
1227  ossim_uint32 highX = higherXString.toInt32();
1228  ossim_uint32 highY = higherYString.toInt32();
1229 
1230  geomKwl.add( ossimKeywordNames::NUMBER_LINES_KW, highY - lowY + 1 );
1231  geomKwl.add( ossimKeywordNames::NUMBER_SAMPLES_KW, highX - lowX + 1 );
1232 
1233  status = true;
1234  }
1235  }
1236  }
1237 
1238  return status;
1239 
1240 } // ossimGmlSupportData::addLineSamps
1241 
1243  bool useGmlPrefix,
1244  ossim_uint32 pcsCode,
1245  ossimKeywordlist& geomKwl ) const
1246 {
1247  bool status = false;
1248 
1249  if ( m_xmlDocument.valid() && (pcsCode != 32767 ) )
1250  {
1251  vector< ossimRefPtr<ossimXmlNode> > xml_nodes;
1252 
1253  //---
1254  // origin:
1255  // Note: In GML the origin is the tie point, NOT the projection origin.
1256  //---
1257 
1258  // axis labels for rectified imagery:
1259  ossimString xpath_axisLabels;
1260  if ( useGmlPrefix )
1261  {
1262  xpath_axisLabels = "/gml:axisLabels";
1263  }
1264  else
1265  {
1266  xpath_axisLabels = "/axisLabels";
1267  }
1268 
1269  ossimString xpath = xpath0 + xpath_axisLabels;
1270  m_xmlDocument->findNodes( xpath, xml_nodes );
1271  if ( xml_nodes.size() == 1 )
1272  {
1273  ossimString axisLabelsString = xml_nodes[0]->getText();
1274 
1275  ossimString xpath_originPoint;
1276 
1277  if ( useGmlPrefix )
1278  {
1279  xpath_originPoint = "/gml:origin/gml:Point";
1280  }
1281  else
1282  {
1283  xpath_originPoint = "/origin/Point";
1284  }
1285 
1286  xpath = xpath0 + xpath_originPoint;
1287  xml_nodes.clear();
1288  m_xmlDocument->findNodes( xpath, xml_nodes );
1289  if ( xml_nodes.size() == 1 )
1290  {
1291  const ossimString& originString = xml_nodes[0]->getChildTextValue( ossimString( "pos" ) );
1292  size_t spacePos = originString.find( ' ' );
1293  ossimString firstOriginString = originString.beforePos( spacePos );
1294  ossimString secondOriginString = originString.afterPos ( spacePos );
1295 
1296  std::string tie_point_xy;
1297  std::string tie_point_units;
1298 
1299  if ( pcsCode == 4326 ) // map projection
1300  {
1301  // Longitude first, e.g. (lon,lat)
1302  tie_point_units = "degrees";
1303  }
1304  else
1305  {
1306  tie_point_units = "meters";
1307  }
1308 
1309  if ( ( tie_point_units == "degrees" ) &&
1310  ( axisLabelsString == "Lat Long" ) )
1311  {
1312  tie_point_xy = "(";
1313  tie_point_xy += secondOriginString.string();
1314  tie_point_xy += ",";
1315  tie_point_xy += firstOriginString.string();
1316  tie_point_xy += ")";
1317  }
1318  else
1319  {
1320  tie_point_xy = "(";
1321  tie_point_xy += firstOriginString.string();
1322  tie_point_xy += ",";
1323  tie_point_xy += secondOriginString.string();
1324  tie_point_xy += ")";
1325  }
1326  geomKwl.add( ossimKeywordNames::TIE_POINT_XY_KW, tie_point_xy.c_str() );
1327  geomKwl.add( ossimKeywordNames::TIE_POINT_UNITS_KW, tie_point_units.c_str() );
1328  status = true;
1329  }
1330  }
1331 
1332  } // Matches: if ( m_xmlDocument.valid() && (pscCode != 32767 ) )
1333 
1334  return status;
1335 
1336 } // End: ossimGmlSupportData::addTie( ... )
1337 
1339  bool useGmlPrefix,
1340  ossim_uint32 pcsCode,
1341  ossimKeywordlist& geomKwl ) const
1342 {
1343  bool status = false;
1344 
1345  if ( m_xmlDocument.valid() && (pcsCode != 32767 ) )
1346  {
1347  vector< ossimRefPtr<ossimXmlNode> > xml_nodes;
1348 
1349  //---
1350  // origin:
1351  // Note: In GML the origin is the tie point, NOT the projection origin.
1352  //---
1353 
1354  // axis labels for rectified imagery:
1355  ossimString xpath_axisLabels;
1356  if ( useGmlPrefix )
1357  {
1358  xpath_axisLabels = "/gml:axisLabels";
1359  }
1360  else
1361  {
1362  xpath_axisLabels = "/axisLabels";
1363  }
1364 
1365  ossimString xpath = xpath0 + xpath_axisLabels;
1366  m_xmlDocument->findNodes( xpath, xml_nodes );
1367  if ( xml_nodes.size() == 1 )
1368  {
1369  ossimString axisLabelsString = xml_nodes[0]->getText();
1370 
1371  ossimString xpath_offsetVector;
1372  if ( useGmlPrefix )
1373  {
1374  xpath_offsetVector = "/gml:offsetVector";
1375  }
1376  else
1377  {
1378  xpath_offsetVector = "/offsetVector";
1379  }
1380 
1381  xpath = xpath0 + xpath_offsetVector;
1382  xml_nodes.clear();
1383  m_xmlDocument->findNodes( xpath, xml_nodes );
1384  if ( xml_nodes.size() == 2 )
1385  {
1386  const ossimString& offsetVectorString0 = xml_nodes[0]->getText();
1387  const ossimString& offsetVectorString1 = xml_nodes[1]->getText();
1388 
1389  size_t spacePos0 = offsetVectorString0.find( ' ' );
1390  size_t spacePos1 = offsetVectorString1.find( ' ' );
1391 
1392  ossimString firstOffsetVectorString0 = offsetVectorString0.beforePos( spacePos0 );
1393  ossimString secondOffsetVectorString0 = offsetVectorString0.afterPos ( spacePos0 );
1394  ossimString firstOffsetVectorString1 = offsetVectorString1.beforePos( spacePos1 );
1395  ossimString secondOffsetVectorString1 = offsetVectorString1.afterPos ( spacePos1 );
1396 
1397  // TODO: Add for rotational matrix:
1398 
1399  std::string scale_xy;
1400  std::string scale_units;
1401  if ( pcsCode == 4326 )
1402  {
1403  scale_units = "degrees";
1404  }
1405  else
1406  {
1407  scale_units = "meters";
1408  }
1409 
1410  ossimDpt scale;
1411  if ( ( scale_units == "degrees" ) &&
1412  ( axisLabelsString == "Lat Long" ) )
1413  {
1414  scale.x = secondOffsetVectorString1.toFloat64();
1415  scale.y = firstOffsetVectorString0.toFloat64();
1416  }
1417  else
1418  {
1419  scale.x = firstOffsetVectorString0.toFloat64();
1420  scale.y = secondOffsetVectorString1.toFloat64();
1421  }
1422  if ( scale.y < 0.0 )
1423  {
1424  scale.y *= -1.0; // make positive
1425  }
1426 
1427  if ( ( scale_units == "degrees" ) && ( scale.x != scale.y ) )
1428  {
1429  // Compute/add the origin latitude of true scale.
1430  ossim_float64 origin_lat = ossim::acosd(scale.y/scale.x);
1431 
1432  geomKwl.add( ossimKeywordNames::ORIGIN_LATITUDE_KW, origin_lat );
1433  }
1434 
1436  geomKwl.add( ossimKeywordNames::PIXEL_SCALE_UNITS_KW, scale_units.c_str() );
1437  status = true;
1438  }
1439  }
1440 
1441  } // Matches: if ( m_xmlDocument.valid() && (pscCode != 32767 ) )
1442 
1443  return status;
1444 
1445 } // End: ossimGmlSupportData::addScale( ... )
std::ostringstream os2
void clear()
Erases the entire container.
Definition: ossimString.h:432
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.
Definition: ossimIosFwd.h:35
const ossimString & getName() const
static const ossimFilename NIL
This was taken from Wx widgets for performing touch and access date stamps.
Definition: ossimFilename.h:40
Represents serializable keyword/value map.
bool valid() const
Definition: ossimRefPtr.h:75
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 afterPos(std::string::size_type pos) const
ossimString m_axisLabelsStringMap
double y
Definition: ossimDpt.h:165
ossim_uint32 height() const
Definition: ossimIrect.h:487
~ossimGmlSupportData()
destructor
std::vector< ossimRefPtr< ossimXmlAttribute > > AttributeListType
Definition: ossimXmlNode.h:31
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
Definition: ossimIrect.h:274
double acosd(double x)
Definition: ossimCommon.h:264
ossim_uint32 toUInt32() const
const ossimString & getValue() const
ossimDpt getDegreesPerPixel() const
Returns the resolution of this image in degrees/pixel.
#define UNKNOWN_PCSCODE
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
Definition: ossimXmlNode.h:30
ossim_int32 toInt32() const
static const char * PIXEL_SCALE_XY_KW
bool getImageGeometry(ossimKeywordlist &geomKwl) const
Extracts geometry info to keyword list.
double ossim_float64
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
ossim_float64 lon
Definition: ossimGpt.h:266
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
Definition: ossimString.h:405
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
Definition: ossimIrect.h:276
bool initialize(const ossimImageGeometry *geom, const ossimIrect &rect)
Initializes gml block from geometry file.
ossim_uint32 width() const
Definition: ossimIrect.h:500
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
return status
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.
Definition: ossimIosFwd.h:20
bool getImageGeometryFromRectifiedGrid(ossimKeywordlist &geomKwl) const
For map projected data:
ossimString toString(ossim_uint32 precision=15) const
Definition: ossimDpt.cpp:160
void getMapOrigin(const ossimImageGeometry *geom, const ossimIpt &ul, ossimString &originString, ossimString &offsetVector1String, ossimString &offsetVector2String) const
double x
Definition: ossimDpt.h:164
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&#39;s contents...
Definition: ossimString.h:396
bool read(std::istream &in)
bool hasNans() const
Definition: ossimIrect.h:337
ossim_float64 lat
Definition: ossimGpt.h:265
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.
Definition: ossimString.h:753
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.
Definition: ossimIosFwd.h:23
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
int ossim_int32
const std::string & string() const
Definition: ossimString.h:414