コード例 #1
0
ファイル: geo_get.cs プロジェクト: LogoPhonix/libgeotiff.net
		public static int GTIFKeyInfo(GTIF gtif, geokey_t key, out tagtype_t type)
		{
			type=tagtype_t.TYPE_UNKNOWN;
			if(!gtif.gt_keys.ContainsKey(key)) return 0;
			GeoKey keyptr=gtif.gt_keys[key];
			type=keyptr.gk_type;
			return keyptr.gk_count;
		}
コード例 #2
0
        public static int GTIFKeyInfo(GTIF gtif, geokey_t key, out tagtype_t type)
        {
            type = tagtype_t.TYPE_UNKNOWN;
            if (!gtif.gt_keys.ContainsKey(key))
            {
                return(0);
            }
            GeoKey keyptr = gtif.gt_keys[key];

            type = keyptr.gk_type;
            return(keyptr.gk_count);
        }
コード例 #3
0
		public static string GTIFTypeName(tagtype_t type)
		{
			return FindName(_formatInfo, (int)type);
		}
コード例 #4
0
        static int ReadKey(GTIF gt, GTIFReadMethod scan, object aux)
        {
            string message = scan(aux);

            if (message == null)
            {
                return(-1);
            }
            if (message.Length >= 12)
            {
                if (message.ToLower().Substring(0, 12) == FMT_KEYEND.ToLower().Substring(0, 12))
                {
                    return(0);
                }
            }

            try
            {
                int firstp = message.IndexOfAny(new char[] { '(', ' ', '\t' });
                if (firstp < 0)
                {
                    return(StringError(message));
                }

                string name     = message.Substring(0, firstp).Trim();
                string message1 = message.Substring(firstp);

                int colon = message1.IndexOf(':');
                if (colon < 0)
                {
                    return(StringError(message1));
                }

                string head = message1.Substring(0, colon);
                head = head.Trim(' ', '\t', '(', ')');

                string[] spl = head.Split(',');
                if (spl.Length != 2)
                {
                    return(StringError(head));
                }

                string type  = spl[0];
                int    count = int.Parse(spl[1]);

                // skip white space
                string data = message1.Substring(colon + 1).Trim();
                if (data.Length == 0)
                {
                    return(StringError(message));
                }

                if (GTIFKeyCode(name) < 0)
                {
                    return(StringError(name));
                }
                geokey_t key = (geokey_t)GTIFKeyCode(name);

                if (GTIFTypeCode(type) < 0)
                {
                    return(StringError(type));
                }
                tagtype_t ktype = (tagtype_t)GTIFTypeCode(type);

                switch (ktype)
                {
                case tagtype_t.TYPE_ASCII:
                {
                    string cdata = "";

                    int firstDoubleQuote = data.IndexOf('"');
                    if (firstDoubleQuote < 0)
                    {
                        return(StringError(data));
                    }

                    data = data.Substring(firstDoubleQuote + 1);

                    bool wasesc = false;
                    char c      = '\0';
                    for (int i = 0; i < data.Length; i++)
                    {
                        c = data[i];
                        if (wasesc)
                        {
                            if (c == '\\')
                            {
                                cdata += '\\';
                            }
                            else if (c == '"')
                            {
                                cdata += '"';
                            }
                            else if (c == 'n')
                            {
                                cdata += '\n';
                            }
                            else if (c == 't')
                            {
                                cdata += '\t';
                            }
                            else if (c == 'b')
                            {
                                cdata += '\b';
                            }
                            else if (c == 'r')
                            {
                                cdata += '\r';
                            }
                            else if (c == '0')
                            {
                                cdata += '\0';
                            }

                            wasesc = false;
                            continue;
                        }

                        if (c == '\\')
                        {
                            wasesc = true;
                            continue;
                        }

                        if (c == '\0')
                        {
                            break;
                        }
                        if (c == '"')
                        {
                            break;
                        }

                        cdata += c;

                        if (cdata.Length == count)
                        {
                            c = data[i + 1];
                            break;
                        }
                    }

                    if (cdata.Length < count)
                    {
                        return(StringError(message));
                    }
                    if (c != '"')
                    {
                        return(StringError(message));
                    }

                    GTIFKeySet(gt, key, cdata);
                }
                break;

                case tagtype_t.TYPE_DOUBLE:
                {
                    double[] dptr = new double[count];
                    int      i    = 0;
                    for (; count > 0; count -= 3)
                    {
                        spl = data.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                        if (spl.Length != Math.Min(3, count))
                        {
                            return(StringError(data));
                        }

                        foreach (string part in spl)
                        {
                            message   = part;
                            dptr[i++] = GTIFAtof(part);
                        }

                        if (count > 3)
                        {
                            message = data = scan(aux);
                        }
                    }
                    GTIFKeySet(gt, key, dptr);
                }
                break;

                case tagtype_t.TYPE_SHORT:
                    if (count == 1)
                    {
                        int icode = GTIFValueCode(key, data);
                        if (icode < 0)
                        {
                            return(StringError(data));
                        }
                        ushort code = (ushort)icode;
                        GTIFKeySet(gt, key, code);
                    }
                    else                             // multi-valued short - no such thing yet
                    {
                        ushort[] sptr = new ushort[count];
                        int      i    = 0;
                        for (; count > 0; count -= 3)
                        {
                            spl = data.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                            if (spl.Length != Math.Min(3, count))
                            {
                                return(StringError(data));
                            }

                            foreach (string part in spl)
                            {
                                message   = part;
                                sptr[i++] = ushort.Parse(part);
                            }

                            if (count > 3)
                            {
                                message = data = scan(aux);
                            }
                        }
                        GTIFKeySet(gt, key, sptr);
                    }
                    break;

                default: return(-1);
                }
            }
            catch
            {
                return(StringError(message));
            }
            return(1);
        }
コード例 #5
0
 public static string GTIFTypeName(tagtype_t type)
 {
     return(FindName(_formatInfo, (int)type));
 }