最近在ArcEngine中写了一个唯一值专题图的程序,运行之后却发现了一个奇怪的问题。在IUniqueVlaueRender中添加的字段是一个double类型的字段,都设置好后发现,在Toccontrol中每一个值都添加进去了,但是在MapControl中对象却都没有显示。但是很奇怪的是,唯有一个对象的值是0的,能够正常显示,其他的处于0-1的值都无法显示。
起初怀疑是不是ArcGIS中的Scale设置的只是显示小数点位数,实际上存储的还是超过了6位小数点,到处找也没找到相关的资料,遂放弃。然后回到arcMap中,尝试不同的工具。使用Identify工具,查看到某对象的值是0.256903,然后使用这个值去到Find工具里去找,竟然没找到。。
观察了一下,Identify中显示的值是“.256903”,更换了一个值之后,再回到Find里找“.256903”,找到了。回到AE中,将IUniqueValueRender中SetValue时所有的值介于-1 - +1之间的小数的0都trim掉,一切就好了。
到此,清楚了,原来是系统的零起始设置(控制面板,区域和语言,其他设置,零起始显示)的问题。像上文一样更改了之后,当然可以解决问题。但是假如某台电脑的设置是0起始显示设置为带零的呢?又得重新设置。所以此处需要获取系统中的是否显示起始零的设置,然后更改程序中的值。
获得“零起始显示”需要调用系统API,方法如下:
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]public static extern int GetLocaleInfoEx(String lpLocaleName, LCTYPE LCType, StringBuilder lpLCData, int cchData);[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]public static extern int GetUserDefaultLocaleName(StringBuilder lpLocaleName, int cchLocaleName);public enum LCTYPE : uint{LOCALE_NOUSEROVERRIDE = 0x80000000, // do not use user overridesLOCALE_RETURN_NUMBER = 0x20000000, // return number instead of string// Modifier for genitive namesLOCALE_RETURN_GENITIVE_NAMES = 0x10000000, //Flag to return the Genitive forms of month names//// The following LCTypes are mutually exclusive in that they may NOT// be used in combination with each other.////// These are the various forms of the name of the locale://LOCALE_SLOCALIZEDDISPLAYNAME = 0x00000002, // localized name of locale, eg "German (Germany)" in UI languageLOCALE_SENGLISHDISPLAYNAME = 0x00000072, // Display name (language + country usually) in English, eg "German (Germany)"LOCALE_SNATIVEDISPLAYNAME = 0x00000073, // Display name in native locale language, eg "Deutsch (Deutschland)LOCALE_SLOCALIZEDLANGUAGENAME = 0x0000006f, // Language Display Name for a language, eg "German" in UI languageLOCALE_SENGLISHLANGUAGENAME = 0x00001001, // English name of language, eg "German"LOCALE_SNATIVELANGUAGENAME = 0x00000004, // native name of language, eg "Deutsch"LOCALE_SLOCALIZEDCOUNTRYNAME = 0x00000006, // localized name of country, eg "Germany" in UI languageLOCALE_SENGLISHCOUNTRYNAME = 0x00001002, // English name of country, eg "Germany"LOCALE_SNATIVECOUNTRYNAME = 0x00000008, // native name of country, eg "Deutschland"// Additional LCTYPEsLOCALE_SABBREVLANGNAME = 0x00000003, // abbreviated language nameLOCALE_ICOUNTRY = 0x00000005, // country codeLOCALE_SABBREVCTRYNAME = 0x00000007, // abbreviated country nameLOCALE_IGEOID = 0x0000005B, // geographical location idLOCALE_IDEFAULTLANGUAGE = 0x00000009, // default language idLOCALE_IDEFAULTCOUNTRY = 0x0000000A, // default country codeLOCALE_IDEFAULTCODEPAGE = 0x0000000B, // default oem code pageLOCALE_IDEFAULTANSICODEPAGE = 0x00001004, // default ansi code pageLOCALE_IDEFAULTMACCODEPAGE = 0x00001011, // default mac code pageLOCALE_SLIST = 0x0000000C, // list item separatorLOCALE_IMEASURE = 0x0000000D, // 0 = metric, 1 = USLOCALE_SDECIMAL = 0x0000000E, // decimal separatorLOCALE_STHOUSAND = 0x0000000F, // thousand separatorLOCALE_SGROUPING = 0x00000010, // digit groupingLOCALE_IDIGITS = 0x00000011, // number of fractional digitsLOCALE_ILZERO = 0x00000012, // leading zeros for decimalLOCALE_INEGNUMBER = 0x00001010, // negative number modeLOCALE_SNATIVEDIGITS = 0x00000013, // native digits for 0-9LOCALE_SCURRENCY = 0x00000014, // local monetary symbolLOCALE_SINTLSYMBOL = 0x00000015, // uintl monetary symbolLOCALE_SMONDECIMALSEP = 0x00000016, // monetary decimal separatorLOCALE_SMONTHOUSANDSEP = 0x00000017, // monetary thousand separatorLOCALE_SMONGROUPING = 0x00000018, // monetary groupingLOCALE_ICURRDIGITS = 0x00000019, // # local monetary digitsLOCALE_IINTLCURRDIGITS = 0x0000001A, // # uintl monetary digitsLOCALE_ICURRENCY = 0x0000001B, // positive currency modeLOCALE_INEGCURR = 0x0000001C, // negative currency modeLOCALE_SDATE = 0x0000001D, // date separator (derived from LOCALE_SSHORTDATE, use that instead)LOCALE_STIME = 0x0000001E, // time separator (derived from LOCALE_STIMEFORMAT, use that instead)LOCALE_SSHORTDATE = 0x0000001F, // short date format stringLOCALE_SLONGDATE = 0x00000020, // long date format stringLOCALE_STIMEFORMAT = 0x00001003, // time format stringLOCALE_IDATE = 0x00000021, // short date format ordering (derived from LOCALE_SSHORTDATE, use that instead)LOCALE_ILDATE = 0x00000022, // long date format ordering (derived from LOCALE_SLONGDATE, use that instead)LOCALE_ITIME = 0x00000023, // time format specifier (derived from LOCALE_STIMEFORMAT, use that instead)LOCALE_ITIMEMARKPOSN = 0x00001005, // time marker position (derived from LOCALE_STIMEFORMAT, use that instead)LOCALE_ICENTURY = 0x00000024, // century format specifier (short date, LOCALE_SSHORTDATE is preferred)LOCALE_ITLZERO = 0x00000025, // leading zeros in time field (derived from LOCALE_STIMEFORMAT, use that instead)LOCALE_IDAYLZERO = 0x00000026, // leading zeros in day field (short date, LOCALE_SSHORTDATE is preferred)LOCALE_IMONLZERO = 0x00000027, // leading zeros in month field (short date, LOCALE_SSHORTDATE is preferred)LOCALE_S1159 = 0x00000028, // AM designatorLOCALE_S2359 = 0x00000029, // PM designatorLOCALE_ICALENDARTYPE = 0x00001009, // type of calendar specifierLOCALE_IOPTIONALCALENDAR = 0x0000100B, // additional calendar types specifierLOCALE_IFIRSTDAYOFWEEK = 0x0000100C, // first day of week specifierLOCALE_IFIRSTWEEKOFYEAR = 0x0000100D, // first week of year specifierLOCALE_SDAYNAME1 = 0x0000002A, // long name for MondayLOCALE_SDAYNAME2 = 0x0000002B, // long name for TuesdayLOCALE_SDAYNAME3 = 0x0000002C, // long name for WednesdayLOCALE_SDAYNAME4 = 0x0000002D, // long name for ThursdayLOCALE_SDAYNAME5 = 0x0000002E, // long name for FridayLOCALE_SDAYNAME6 = 0x0000002F, // long name for SaturdayLOCALE_SDAYNAME7 = 0x00000030, // long name for SundayLOCALE_SABBREVDAYNAME1 = 0x00000031, // abbreviated name for MondayLOCALE_SABBREVDAYNAME2 = 0x00000032, // abbreviated name for TuesdayLOCALE_SABBREVDAYNAME3 = 0x00000033, // abbreviated name for WednesdayLOCALE_SABBREVDAYNAME4 = 0x00000034, // abbreviated name for ThursdayLOCALE_SABBREVDAYNAME5 = 0x00000035, // abbreviated name for FridayLOCALE_SABBREVDAYNAME6 = 0x00000036, // abbreviated name for SaturdayLOCALE_SABBREVDAYNAME7 = 0x00000037, // abbreviated name for SundayLOCALE_SMONTHNAME1 = 0x00000038, // long name for JanuaryLOCALE_SMONTHNAME2 = 0x00000039, // long name for FebruaryLOCALE_SMONTHNAME3 = 0x0000003A, // long name for MarchLOCALE_SMONTHNAME4 = 0x0000003B, // long name for AprilLOCALE_SMONTHNAME5 = 0x0000003C, // long name for MayLOCALE_SMONTHNAME6 = 0x0000003D, // long name for JuneLOCALE_SMONTHNAME7 = 0x0000003E, // long name for JulyLOCALE_SMONTHNAME8 = 0x0000003F, // long name for AugustLOCALE_SMONTHNAME9 = 0x00000040, // long name for SeptemberLOCALE_SMONTHNAME10 = 0x00000041, // long name for OctoberLOCALE_SMONTHNAME11 = 0x00000042, // long name for NovemberLOCALE_SMONTHNAME12 = 0x00000043, // long name for DecemberLOCALE_SMONTHNAME13 = 0x0000100E, // long name for 13th month (if exists)LOCALE_SABBREVMONTHNAME1 = 0x00000044, // abbreviated name for JanuaryLOCALE_SABBREVMONTHNAME2 = 0x00000045, // abbreviated name for FebruaryLOCALE_SABBREVMONTHNAME3 = 0x00000046, // abbreviated name for MarchLOCALE_SABBREVMONTHNAME4 = 0x00000047, // abbreviated name for AprilLOCALE_SABBREVMONTHNAME5 = 0x00000048, // abbreviated name for MayLOCALE_SABBREVMONTHNAME6 = 0x00000049, // abbreviated name for JuneLOCALE_SABBREVMONTHNAME7 = 0x0000004A, // abbreviated name for JulyLOCALE_SABBREVMONTHNAME8 = 0x0000004B, // abbreviated name for AugustLOCALE_SABBREVMONTHNAME9 = 0x0000004C, // abbreviated name for SeptemberLOCALE_SABBREVMONTHNAME10 = 0x0000004D, // abbreviated name for OctoberLOCALE_SABBREVMONTHNAME11 = 0x0000004E, // abbreviated name for NovemberLOCALE_SABBREVMONTHNAME12 = 0x0000004F, // abbreviated name for DecemberLOCALE_SABBREVMONTHNAME13 = 0x0000100F, // abbreviated name for 13th month (if exists)LOCALE_SPOSITIVESIGN = 0x00000050, // positive signLOCALE_SNEGATIVESIGN = 0x00000051, // negative signLOCALE_IPOSSIGNPOSN = 0x00000052, // positive sign position (derived from INEGCURR)LOCALE_INEGSIGNPOSN = 0x00000053, // negative sign position (derived from INEGCURR)LOCALE_IPOSSYMPRECEDES = 0x00000054, // mon sym precedes pos amt (derived from ICURRENCY)LOCALE_IPOSSEPBYSPACE = 0x00000055, // mon sym sep by space from pos amt (derived from ICURRENCY)LOCALE_INEGSYMPRECEDES = 0x00000056, // mon sym precedes neg amt (derived from INEGCURR)LOCALE_INEGSEPBYSPACE = 0x00000057, // mon sym sep by space from neg amt (derived from INEGCURR)LOCALE_FONTSIGNATURE = 0x00000058, // font signatureLOCALE_SISO639LANGNAME = 0x00000059, // ISO abbreviated language nameLOCALE_SISO3166CTRYNAME = 0x0000005A, // ISO abbreviated country nameLOCALE_IDEFAULTEBCDICCODEPAGE = 0x00001012, // default ebcdic code pageLOCALE_IPAPERSIZE = 0x0000100A, // 1 = letter, 5 = legal, 8 = a3, 9 = a4LOCALE_SENGCURRNAME = 0x00001007, // english name of currencyLOCALE_SNATIVECURRNAME = 0x00001008, // native name of currencyLOCALE_SYEARMONTH = 0x00001006, // year month format stringLOCALE_SSORTNAME = 0x00001013, // sort nameLOCALE_IDIGITSUBSTITUTION = 0x00001014, // 0 = context, 1 = none, 2 = nationalLOCALE_SNAME = 0x0000005c, // locale name (with sort info) (ie: de-DE_phoneb)LOCALE_SDURATION = 0x0000005d, // time duration formatLOCALE_SKEYBOARDSTOINSTALL = 0x0000005e, // (windows only) keyboards to installLOCALE_SSHORTESTDAYNAME1 = 0x00000060, // Shortest day name for MondayLOCALE_SSHORTESTDAYNAME2 = 0x00000061, // Shortest day name for TuesdayLOCALE_SSHORTESTDAYNAME3 = 0x00000062, // Shortest day name for WednesdayLOCALE_SSHORTESTDAYNAME4 = 0x00000063, // Shortest day name for ThursdayLOCALE_SSHORTESTDAYNAME5 = 0x00000064, // Shortest day name for FridayLOCALE_SSHORTESTDAYNAME6 = 0x00000065, // Shortest day name for SaturdayLOCALE_SSHORTESTDAYNAME7 = 0x00000066, // Shortest day name for SundayLOCALE_SISO639LANGNAME2 = 0x00000067, // 3 character ISO abbreviated language nameLOCALE_SISO3166CTRYNAME2 = 0x00000068, // 3 character ISO country nameLOCALE_SNAN = 0x00000069, // Not a NumberLOCALE_SPOSINFINITY = 0x0000006a, // + InfinityLOCALE_SNEGINFINITY = 0x0000006b, // - InfinityLOCALE_SSCRIPTS = 0x0000006c, // Typical scripts in the localeLOCALE_SPARENT = 0x0000006d, // Fallback name for resourcesLOCALE_SCONSOLEFALLBACKNAME = 0x0000006e, // Fallback name for within the console}/// <summary>/// 获取系统当前的是否显示前导零设置/// </summary>/// <returns>0:不显示前导0 1:显示前导0</returns>public int getIfShowLeadingZero(){StringBuilder lpLCData = new StringBuilder(10);StringBuilder localeName = new StringBuilder(20);GetUserDefaultLocaleName(localeName, 20);GetLocaleInfoEx(localeName.ToString(), LCTYPE.LOCALE_ILZERO, lpLCData, 10);return Convert.ToInt32(lpLCData.ToString());}
在设置IUNiqueValueRender的值时,如果值在-1 - +1之间,若显示前导0(getIfShowLeadingZero()==1),
则不予处理;否则(getIfShowLeadingZero()==0)将前导的“0.”替换为“.”。
其他处理方式不变。
问题是解决了,但系统中的“起始零显示”难道不应该只是影响数据的显示么?在此怎么影响到数据的查询了?

浙公网安备 33010602011771号