| 643 | | else if( EQUALN(pszSRSName,"urn:ogc:def:crs:EPSG::",22) ) |
|---|
| 644 | | { |
|---|
| 645 | | OGRSpatialReference oSRS; |
|---|
| 646 | | if( oSRS.importFromEPSG( atoi(pszSRSName + 22) ) == OGRERR_NONE ) |
|---|
| 647 | | oSRS.exportToWkt( &pszProjection ); |
|---|
| 648 | | } |
|---|
| 649 | | else if( EQUALN(pszSRSName,"urn:ogc:def:crs:EPSG:",21) ) |
|---|
| 650 | | { |
|---|
| 651 | | const char *pszCode = pszSRSName+21; |
|---|
| 652 | | while( *pszCode != ':' && *pszCode != '\0' ) |
|---|
| 653 | | pszCode++; |
|---|
| 654 | | |
|---|
| 655 | | OGRSpatialReference oSRS; |
|---|
| 656 | | if( oSRS.importFromEPSG( atoi(pszCode+1) ) == OGRERR_NONE ) |
|---|
| 657 | | oSRS.exportToWkt( &pszProjection ); |
|---|
| | 658 | else if( EQUALN(pszSRSName,"urn:",4) |
|---|
| | 659 | && strstr(pszSRSName,":def:") != NULL |
|---|
| | 660 | && oSRS.importFromURN(pszSRSName) == OGRERR_NONE ) |
|---|
| | 661 | { |
|---|
| | 662 | oSRS.exportToWkt( &pszProjection ); |
|---|
| | 759 | /* -------------------------------------------------------------------- */ |
|---|
| | 760 | /* This is a backdoor to let us embed a literal gmljp2 chunk */ |
|---|
| | 761 | /* supplied by the user as an external file. This is mostly */ |
|---|
| | 762 | /* for preparing test files with exotic contents. */ |
|---|
| | 763 | /* -------------------------------------------------------------------- */ |
|---|
| | 764 | if( CPLGetConfigOption( "GMLJP2OVERRIDE", NULL ) != NULL ) |
|---|
| | 765 | { |
|---|
| | 766 | FILE *fp = VSIFOpenL( CPLGetConfigOption( "GMLJP2OVERRIDE",""), "r" ); |
|---|
| | 767 | char *pszGML = NULL; |
|---|
| | 768 | |
|---|
| | 769 | if( fp == NULL ) |
|---|
| | 770 | { |
|---|
| | 771 | CPLError( CE_Failure, CPLE_AppDefined, |
|---|
| | 772 | "Unable to open GMLJP2OVERRIDE file." ); |
|---|
| | 773 | return NULL; |
|---|
| | 774 | } |
|---|
| | 775 | |
|---|
| | 776 | VSIFSeekL( fp, 0, SEEK_END ); |
|---|
| | 777 | int nLength = (int) VSIFTellL( fp ); |
|---|
| | 778 | pszGML = (char *) CPLCalloc(1,nLength+1); |
|---|
| | 779 | VSIFSeekL( fp, 0, SEEK_SET ); |
|---|
| | 780 | VSIFReadL( pszGML, 1, nLength, fp ); |
|---|
| | 781 | VSIFCloseL( fp ); |
|---|
| | 782 | |
|---|
| | 783 | GDALJP2Box *apoGMLBoxes[2]; |
|---|
| | 784 | |
|---|
| | 785 | apoGMLBoxes[0] = GDALJP2Box::CreateLblBox( "gml.data" ); |
|---|
| | 786 | apoGMLBoxes[1] = |
|---|
| | 787 | GDALJP2Box::CreateLabelledXMLAssoc( "gml.root-instance", |
|---|
| | 788 | pszGML ); |
|---|
| | 789 | |
|---|
| | 790 | GDALJP2Box *poGMLData = GDALJP2Box::CreateAsocBox( 2, apoGMLBoxes); |
|---|
| | 791 | |
|---|
| | 792 | delete apoGMLBoxes[0]; |
|---|
| | 793 | delete apoGMLBoxes[1]; |
|---|
| | 794 | |
|---|
| | 795 | CPLFree( pszGML ); |
|---|
| | 796 | |
|---|
| | 797 | return poGMLData; |
|---|
| | 798 | } |
|---|
| | 799 | |
|---|