[gdal-dev] Extract CGM from a NITF file

xavier lhomme lhomme.xavier at gmail.com
Thu Jun 20 02:15:54 PDT 2013


Thanks it works well ! I succeed to export graphics from the NITF file.
But I didn't understand why my C# function was wrong.


Best regards.


2013/6/20 Livneh Yehiyam <yehil at rafael.co.il>

>  Hi****
>
> You can use the GDAL unescape function like this:****
>
> ** **
>
> /// <summary>****
>
>         /// Remove "backslash quotable" escape characters from the string
> and convert it to byte array.****
>
>         /// </summary>****
>
>         public static byte[] RemoveEscapeCharacters(this string value)****
>
>         {****
>
>             if(String.IsNullOrEmpty(value))****
>
>             {****
>
>                 return new byte[0];****
>
>             }****
>
>             int length = value.Length;****
>
>             IntPtr escapedString = CPLUnescapeString(value, ref length,
> 0);****
>
>             byte[] escapedBytes = new byte[length];****
>
>             Marshal.Copy(escapedString, escapedBytes, 0, length);****
>
>             VSIFree(escapedString);****
>
>             return escapedBytes;****
>
>         }****
>
> ** **
>
>         [DllImport("gdal18.dll", EntryPoint = "CPLUnescapeString",
> CallingConvention = CallingConvention.Cdecl)]****
>
>         private static extern IntPtr CPLUnescapeString(string input, ref
> int length, int scheme);****
>
> ** **
>
>         [DllImport("gdal18.dll", EntryPoint = "VSIFree",
> CallingConvention = CallingConvention.Cdecl)]****
>
>         private static extern void VSIFree(IntPtr input);****
>
> ** **
>
> ** **
>
> Yehiyam****
>
> ** **
>
> *From:* gdal-dev-bounces at lists.osgeo.org [mailto:
> gdal-dev-bounces at lists.osgeo.org] *On Behalf Of *xavier lhomme
> *Sent:* Wednesday, June 19, 2013 11:50 PM
> *To:* gdal-dev
> *Subject:* [gdal-dev] Extract CGM from a NITF file****
>
> ** **
>
> Hi ****
>
> ** **
>
>   I'm trying to extract CGM files from a NITF but the CGM are corrupt. ***
> *
>
> ** **
>
>   First I Unescape the CGM Data and I obtain something like****
>
>    "\0,\vCreated CGM \"\0 f\0 ÿÿ\0 ...****
>
>   Then write the text file. ****
>
>  ****
>
>   I compared this string with a CGM obtained from NITRO NITF
> (nitro_extract_cgm.exe).****
>
>   The new CGM file start with  ****
>
>     "\0,\vCreated CGM \"\0 f\0 ��\0****
>
>  I succeed to read this CGM file with a CGM viewer. ****
>
> ** **
>
> One of the difference come from caracter like ÿ (from GDAL) � from NITRO**
> **
>
> ** **
>
> Then It's probably something I missed in the Escaping/Unescaping function
> ****
>
> ** **
>
> Because UnescapeScring wasn't exposed in C# I wrote a function : ****
>
> static public string UnescapeString(string pszInput)****
>
>         {****
>
>              string pszOutput="";    ****
>
>             int iIn = 0;****
>
>             for (iIn = 0; iIn<pszInput.Length; iIn++)****
>
>             {****
>
>                 if (pszInput[iIn] == '\\')****
>
>                 {****
>
>                     iIn++;****
>
>                     if (pszInput[iIn] == 'n')****
>
>                         pszOutput += '\n';****
>
>                     else if (pszInput[iIn] == '0')****
>
>                         pszOutput += '\0';****
>
>                     else****
>
>                         pszOutput += pszInput[iIn];****
>
>                 }****
>
>                 else****
>
>                 {****
>
>                     pszOutput += pszInput[iIn];****
>
>                 }****
>
>             }****
>
>             return pszOutput;****
>
>         }****
>
> ** **
>
> thanks in advance!****
>
> Best regards ****
>   ________________________________________
> This message (including any attachments) issued by RAFAEL- ADVANCED
> DEFENSE SYSTEMS LTD. (hereinafter "RAFAEL") contains confidential
> information intended for a specific individual and purpose, may constitute
> information that is privileged or confidential or otherwise protected from
> disclosure. If you are not the intended recipient, you should contact us
> immediately and thereafter delete this message from your system. You are
> hereby notified that any disclosure, copying, dissemination, distribution
> or forwarding of this message, or the taking of any action based on it, is
> strictly prohibited. If you have received this e-mail in error, please
> notify us immediately by e-mail mailto:lawraf at rafael.co.il and completely
> delete or destroy any and all electronic or other copies of the original
> message and any attachments thereof.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130620/7478011b/attachment.html>


More information about the gdal-dev mailing list