地籍数据属性质检功能设计与实现
要質(zhì)檢的數(shù)據(jù)包括使用權(quán)宗地、所有權(quán)宗地、自然幢,屬性質(zhì)檢規(guī)則如下:
使用權(quán)宗地、所有權(quán)宗地屬性質(zhì)檢項(xiàng)如下:
1.???????必填項(xiàng)
區(qū)縣代碼(QXDM)、宗地特征碼(ZDTZM)、坐落(ZL)、定著物特征碼(DZWTZM)、權(quán)力人(QLR)、面積單位(MJDW)。
2.???????字段限制
1)???????要素代碼(YSDM)為空,或不為空必須是10位數(shù)字組成;
2)???????宗地代碼(ZDDM)為空,或不為空必須是19位、數(shù)字或字母組成;
3)???????不動(dòng)產(chǎn)單元號(hào)(BDCDYH)為空,或不為空必須是28位、數(shù)字或字母組成;
4)???????宗地特征碼(ZDTZM),2個(gè)字母組成,如果第一個(gè)字母是G、第二個(gè)字母只能是BDEFSXY中的一個(gè),第一個(gè)字母是J、第二字母是ABCDEFSXY中一個(gè),第一個(gè)字母是Z、第二個(gè)字母只能是W,無其他組合;
5)???????定著物特征碼(DZWTZM),宗地只能是W。
自然幢屬性質(zhì)檢項(xiàng)如下:
1.???????字段限制
1)???????區(qū)縣代碼(QXDM)為空,或不為空只能是6位數(shù)字;
2)???????要素代碼(YSDM)為空,或不為空必須是10位數(shù)字組成;
3)???????宗地代碼(ZDDM)為空,或不為空必須是19位、數(shù)字或字母組成;
4)???????不動(dòng)產(chǎn)單元號(hào)(BDCDYH)為空,或不為空必須是28位、數(shù)字或字母組成;
5)???????自然幢號(hào)(ZRZH)為空,或不為空必須是24位、數(shù)字或字母組成;
宗地宗海特征碼(ZDZHTZM)為空,或不為空由2個(gè)字母組成,如果第一個(gè)字母是G、第二個(gè)字母只能是BDEFSXY中的一個(gè),第一個(gè)字母是J、第二字母是ABCDEFSXY中一個(gè),第一個(gè)字母是Z、第二個(gè)字母只能是W,無其他組合。設(shè)計(jì)時(shí),考慮通用性和可復(fù)用性,設(shè)計(jì)了質(zhì)檢類CheckFieldValue,并在此基礎(chǔ)上設(shè)計(jì)了一宗地?cái)?shù)據(jù)的宗地特征碼、自然幢數(shù)據(jù)的宗地宗海特征碼檢查類ParcelCheckFieldValue。
如下:
using GISWebService.HttpRequestContent; using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Web;namespace GISWebService.Common {/// <summary>/// 屬性質(zhì)檢/// </summary>public class CheckFieldValue{/// <summary>/// 要質(zhì)檢的屬性與值/// </summary>private static Dictionary<string, object> _dictFieldValue { get; set; }/// <summary>/// 質(zhì)檢結(jié)果/// </summary>//private static List<CheckFieldResult> _listResult { get; set; }private static List<string> _listResult { get; set; }/// <summary>/// 屬性質(zhì)檢/// </summary>/// <param name="name">字段名</param>/// <param name="value">字段值</param>public CheckFieldValue(string name, object value){CheckInstance();object oValue = null;if (_dictFieldValue.TryGetValue(name, out oValue))_dictFieldValue[name] = value;else_dictFieldValue.Add(name, value);}/// <summary>/// 屬性質(zhì)檢/// </summary>/// <param name="dictFieldValue">屬性名與屬性值集合</param>public CheckFieldValue(Dictionary<string, object> dictFieldValue){CheckInstance();_dictFieldValue = dictFieldValue;}/// <summary>/// /// </summary>private static void CheckInstance(){if (null == _dictFieldValue)_dictFieldValue = new Dictionary<string, object>() { };_dictFieldValue.Clear();if (null == _listResult)_listResult = new List<string>() { };}/// <summary>/// 正則表達(dá)式匹配檢查/// </summary>/// <param name="sInput">檢查參數(shù)</param>/// <param name="sPattern">正則表達(dá)式</param>/// <returns>是否匹配</returns>public static bool IsMatch(string sInput, string sPattern){return IsMatch(sInput, sPattern, false, false);}/// <summary>/// 正則表達(dá)式匹配檢查/// </summary>/// <param name="sInput">檢查參數(shù)</param>/// <param name="sPattern">正則表達(dá)式</param>/// <param name="bIngnoreCase">忽略大小寫</param>/// <param name="bIngnoreWhiteSpace">忽略空白</param>/// <returns>是否匹配</returns>public static bool IsMatch(string sInput, string sPattern, bool bIngnoreCase, bool bIngnoreWhiteSpace){if (bIngnoreWhiteSpace && string.IsNullOrWhiteSpace(sInput))return false;return (bIngnoreCase ? new Regex(sPattern, RegexOptions.IgnoreCase) : new Regex(sPattern)).IsMatch(sInput);}/// <summary>/// 是否為純數(shù)字的字符串/// </summary>/// <param name="sInput">檢查參數(shù)</param>/// <param name="nMinLength">最小長(zhǎng)度</param>/// <param name="nMaxLength">最大長(zhǎng)度</param>/// <returns>是否匹配</returns>public static bool IsNumberString(string sInput, int nMinLength, int nMaxLength){return IsMatch(sInput, @"^([0-9]{" + nMinLength + "," + nMaxLength + "})$");}/// <summary>/// 是否為指定長(zhǎng)度的字符串(包含數(shù)字、英文字符)/// </summary>/// <param name="sInput">檢查參數(shù)</param>/// <param name="nMinLength">最小長(zhǎng)度</param>/// <param name="nMaxLength">最大長(zhǎng)度</param>/// <returns>是否匹配</returns>public static bool IsNumberStringOrEnglishCharactor(string sInput, int nMinLength, int nMaxLength){return IsMatch(sInput, @"^([0-9a-zA-Z]{" + nMinLength + "," + nMaxLength + "})$");}/// <summary>/// 非空檢查(不允許為空)/// </summary>public void RuleNotNullable(){foreach (var _item in _dictFieldValue){if (ValueConvert.IsNull(_item.Value))_listResult.Add(string.Format("必填字段 {0} 為空", _item.Key));}}/// <summary>/// 固定長(zhǎng)度檢查(為空或?yàn)楣潭ㄩL(zhǎng)度的字符串,可為數(shù)字或英文字符)/// </summary>/// <param name="nLength">固定長(zhǎng)度</param>public void RuleNullOrFixedLength(int nLength){foreach (var _item in _dictFieldValue){if (!ValueConvert.IsNull(_item.Value) && !IsNumberStringOrEnglishCharactor(Convert.ToString(_item.Value), nLength, nLength))_listResult.Add(string.Format("字段 {0} 長(zhǎng)度不為 {1} 位", _item.Key, nLength));}}/// <summary>/// 固定長(zhǎng)度檢查(為空或?yàn)楣潭ㄩL(zhǎng)度的數(shù)字字符串)/// </summary>/// <param name="nLength"></param>public void RuleNullOrFixedLengthDigit(int nLength){foreach (var _item in _dictFieldValue){if (!ValueConvert.IsNull(_item.Value) && !IsNumberString(Convert.ToString(_item.Value), nLength, nLength))_listResult.Add(string.Format("字段 {0} 長(zhǎng)度不為 {1} 位", _item.Key, nLength));}}/// <summary>/// 清空檢查結(jié)果/// </summary>public void ClearResult(){if (null != _listResult && 0 < _listResult.Count)_listResult.Clear();}/// <summary>/// 獲取質(zhì)檢結(jié)果/// </summary>/// <param name="bAutoClear">是否自動(dòng)清空</param>/// <returns>質(zhì)檢結(jié)果</returns>public List<string> GetResult(bool bAutoClear = true){List<string> ls = new List<string>(_listResult);if (bAutoClear)_listResult.Clear();return ls;}}/// <summary>/// 宗地屬性檢查/// </summary>public class ParcelCheckFieldValue{/// <summary>/// 檢查宗地特征碼/// </summary>/// <param name="field">字段名</param>/// <param name="value">字段值</param>/// <returns>質(zhì)檢結(jié)果</returns>public static string CheckParcelFeatureCode(string field, object value, bool allowNull = false){bool bNull = ValueConvert.IsNull(value);if (!allowNull && bNull)return string.Format("字段{0}不允許為空", field);else if (allowNull && bNull)return null;return CheckFieldValue.IsMatch(System.Convert.ToString(value), @"^((G[BDEFSXY])|(J[ABCDEFSXY])|(ZW))$") ? null : string.Format("字段 {0} 不符合規(guī)范", field);}/// <summary>/// 檢查宗地的定著物特征碼/// </summary>/// <param name="field">字段名</param>/// <param name="value">字段值</param>/// <returns>質(zhì)檢結(jié)果</returns>public static string CheckFixedThingFeatureCode(string field ,object value){return (!ValueConvert.IsNull(value) && 0 == string.Compare(Convert.ToString(value), "W", true)) ? null : string.Format("字段 {0} 不符合規(guī)范", field);}} }其中,接口傳入?yún)?shù)與質(zhì)檢結(jié)果相關(guān)返回參數(shù)設(shè)計(jì)如下:
using GeoJSON.Net.Feature; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Web;namespace GISWebService.HttpRequestContent {/// <summary>/// 屬性質(zhì)檢的傳入?yún)?shù)/// </summary>public class CheckFieldsRequestBody{/// <summary>/// 圖層/// </summary>[JsonProperty("layer")]public string Layer { get; set; }/// <summary>/// 要素集合/// </summary>[JsonProperty("feature")]public List<Feature> Feature { get; set; }}/// <summary>/// 要素屬性質(zhì)檢結(jié)果/// </summary>public class CheckPropertyResult{/// <summary>/// OBJECTID/// </summary>[JsonProperty("objectid")]public int ObjectID { get; set; }/// <summary>/// 字段檢查結(jié)果/// </summary>[JsonProperty("fields")]public List<string> FieldInfo { get; set; }}/// <summary>/// 屬性質(zhì)檢結(jié)果/// </summary>public class CheckFieldsResponseBody{/// <summary>/// 圖層/// </summary>[JsonProperty("layer")]public string Layer { get; set; }/// <summary>/// 質(zhì)檢結(jié)果/// </summary>[JsonProperty("info")]public List<CheckPropertyResult> Information { get; set; }} }調(diào)用時(shí),以宗地質(zhì)檢為例:
{foreach (var aFeature in item.Feature){object oOid = null;if (!aFeature.Properties.TryGetValue("OBJECTID", out oOid))throw new Exception(string.Format("圖層 {0} 存在OBJECTID有誤的要素", item.Layer));int nOid = System.Convert.ToInt32(oOid);CheckPropertyResult aCheckPropResult = new CheckPropertyResult() { ObjectID = nOid, FieldInfo = new List<string>() { } };{List<string> lsNotNullFields = new List<string>() { "QXDM", "ZDTZM", "ZL", "DZWTZM", "QLR", "MJDW" };Dictionary<string, object> dict = new Dictionary<string, object>() { };foreach (var field in lsNotNullFields){object oValue = null;if (!aFeature.Properties.TryGetValue(field, out oValue))throw new Exception(string.Format("未能獲取圖層 {0} 的OBJECTID為 {1} 的要素的 {2} 字段值", item.Layer, nOid, field));dict.Add(field, oValue);}CheckFieldValue aCheck = new CheckFieldValue(dict);aCheck.RuleNotNullable();aCheckPropResult.FieldInfo.AddRange(aCheck.GetResult());}{for (int n = 0; n < 3; n++){string sFieldName = null;if (0 == n)sFieldName = "YSDM";else if (1 == n)sFieldName = "ZDDM";elsesFieldName = "BDCDYH";object oValue = null;if (!aFeature.Properties.TryGetValue(sFieldName, out oValue))throw new Exception(string.Format("未能獲取圖層 {0} 的OBJECTID為 {1} 的要素的 {2} 字段值", item.Layer, nOid, sFieldName));CheckFieldValue aCheck = new CheckFieldValue(sFieldName, oValue);if (0 == n)aCheck.RuleNullOrFixedLengthDigit(10);else if (1 == n)aCheck.RuleNullOrFixedLength(19);elseaCheck.RuleNullOrFixedLength(28);aCheckPropResult.FieldInfo.AddRange(aCheck.GetResult());}}{for (int n = 0; n < 2; n++){string sFeatureCode = (0 == n) ? "ZDTZM" : "DZWTZM";object oValue = null;if (!aFeature.Properties.TryGetValue(sFeatureCode, out oValue))throw new Exception(string.Format("未能獲取圖層 {0} 的OBJECTID為 {1} 的要素的 {2} 字段值", item.Layer, nOid, sFeatureCode));string sResult = 0 == n ? ParcelCheckFieldValue.CheckParcelFeatureCode(sFeatureCode, oValue) : ParcelCheckFieldValue.CheckFixedThingFeatureCode(sFeatureCode, oValue);if (!string.IsNullOrEmpty(sResult))aCheckPropResult.FieldInfo.Add(sResult);}}aResponseBody.Information.Add(aCheckPropResult);}}若傳入的參數(shù)為如下結(jié)構(gòu)的List<CheckFieldsRequestBody>類型的param對(duì)象,內(nèi)容為:
[{"layer": "ZRZ","feature": [{"type": "Feature","geometry": {"type": "Polygon","coordinates": [[[38527161.51,2564408.7410000004],[38527162.14,2564389.3790000007],[38527096.8336,2564387.3809999991],[38527096.8223,2564387.7569999993],[38527088.323,2564394.569],[38527087.9087,2564394.6539999992],[38527087.5629,2564406.4140000008],[38527161.51,2564408.7410000004]]]},"properties": {"OBJECTID": 1343,"BSM": null,"YSDM": null,"BDCDYH": "441322001001GB08213F0005000","ZDDM": "441322001001GB082134","ZRZH": "441322001001GB08213F005","XMMC": null,"JZWMC": null,"JGRQ": null,"JZWGD": null,"ZZDMJ": 1387.1000000000001,"ZYDMJ": null,"YCJZMJ": null,"SCJZMJ": null,"ZCS": 3,"DSCS": 3,"DXCS": null,"GHYT": null,"FWJG": null,"ZTS": null,"JZWJBYT": null,"DAH": null,"BZ": null,"ZT": null,"GID": "E5078ADBDD8A49A0958762CE5106C9AF","RKSJ": null,"SJZT": null,"ISLOCK": null,"ZDZHTZM": "GAB","ZBH": null,"IMPORTFLAG": null,"BMFBUILDID": null,"BMFBUILDCODE": null,"RKRQ": null,"RKR": null,"RKRID": null,"RKID": null,"ZTHYY": null,"RKFS": null,"DZWTZM": null,"ZL": "BL縣LY鎮(zhèn)水西村委會(huì)望牛墩(土名)地段遠(yuǎn)望數(shù)碼城8棟","ZDT": "ZDImage/E5078ADBDD8A49A0958762CE5106C9AF.jpg","DXSD": null,"QXDM": null,"YBDCDYH": null,"HQZTBS": null,"DOCUNID": null,"QJSHBZ": null}},{"type": "Feature","geometry": {"type": "Polygon","coordinates": [[[38527157.83,2564265.0409999993],[38527158.08,2564257.2640000004],[38527118.2,2564245.0390000008],[38527118.269999996,2564242.3949999996],[38527090.652,2564241.6089999992],[38527090.0357,2564262.9230000004],[38527157.83,2564265.0409999993]]]},"properties": {"OBJECTID": 813,"BSM": null,"YSDM": null,"BDCDYH": "441322001001GB08213F00150000","ZDDM": "441322001001GB08213","ZRZH": "441322001001GB08213F0015","XMMC": null,"JZWMC": null,"JGRQ": null,"JZWGD": null,"ZZDMJ": 1123.8,"ZYDMJ": null,"YCJZMJ": null,"SCJZMJ": null,"ZCS": null,"DSCS": null,"DXCS": null,"GHYT": null,"FWJG": null,"ZTS": null,"JZWJBYT": null,"DAH": null,"BZ": null,"ZT": null,"GID": "07B5F49C731B4F9CACDF77DAEEE502BB","RKSJ": null,"SJZT": null,"ISLOCK": null,"ZDZHTZM": "GB","ZBH": null,"IMPORTFLAG": null,"BMFBUILDID": null,"BMFBUILDCODE": null,"RKRQ": null,"RKR": null,"RKRID": null,"RKID": null,"ZTHYY": null,"RKFS": null,"DZWTZM": null,"ZL": "BL縣LY鎮(zhèn)水西村委會(huì)望牛墩(土名)地段遠(yuǎn)望數(shù)碼城15棟","ZDT": "ZDImage/07B5F49C731B4F9CACDF77DAEEE502BB.jpg","DXSD": null,"QXDM": null,"YBDCDYH": null,"HQZTBS": null,"DOCUNID": null,"QJSHBZ": null}}]},{"layer": "ZD_SHYQ","feature": [{"type": "Feature","geometry": {"type": "Polygon","coordinates": [[[38526926.715,2564197.0757999998],[38526920.7464,2564198.8359999992],[38526919.6978,2564204.0397999994],[38526910.2842,2564503.0131],[38526998.747,2564504.4110000003],[38526998.7721,2564521.7214],[38527175.1219,2564521.6728000008],[38527175.582,2564507.2051999997],[38527175.8705,2564495.5077],[38527180.167899996,2564363.0360000003],[38527183.1127,2564270.4807999991],[38527178.6205,2564255.3690000009],[38527165.8622,2564245.9126999993],[38526952.1922,2564176.4903999995],[38526941.2566,2564175.5524000004],[38526934.5509,2564178.1996999998],[38526930.5365,2564179.7846000008],[38526925.1559,2564185.8017999996],[38526922.8309,2564188.4188],[38526920.355399996,2564197.5955],[38526926.715,2564197.0757999998]]]},"properties": {"OBJECTID": 780,"BSM": 2564,"YSDM": "60201030110","ZDDM": null,"BDCDYH": "441322001001444GB08213W00000000","ZDTZM": "ZpW","ZL": "BL縣LY鎮(zhèn)水西村望牛墩地段-遠(yuǎn)望數(shù)碼城","ZDMJ": 81035,"MJDW": "1","YT": "054","DJ": null,"JG": null,"QLLX": "3","QLXZ": "102","QLSDFS": "2","RJL": null,"JZMD": null,"JZXG": null,"ZDSZD": "空地","ZDSZN": "空地","ZDSZX": "空地","ZDSZB": "空地","ZDT": "ZDImage/2CE6B4BA40584E7DAC9E2C14A84F2924.jpg","TFH": null,"DJH": null,"DAH": null,"ZT": null,"ZLDWDM": null,"ZLDWMC": null,"GID": "2CE6B4BA40584E7DAC9E2C14A84F2924","RKSJ": null,"SJZT": 0,"ISLOCK": null,"RKFS": "0","DZWTZM": "A","JZDH": null,"TDSYQSSJ": "2013-12-12T00:00:00","TDSYJSSJ": "2053-12-12T00:00:00","BZ": "本宗地土地證為:B府國用(2014)第010031號(hào),B府國用(2013)第010198號(hào),土地用途為商業(yè)用地,使用期限至2053年12月12日止,土地用途為商服用地,使用期限至2051年11月8日止","QLR": null,"ZYYT": "054","QXDM": "441322","YBDCDYH": null,"ZDH": null,"HQZTBS": null,"DOCUNID": null,"QJSHBZ": null}}]} ]則質(zhì)檢返回結(jié)果為:
{"status": 0,"result": [{"layer": "ZRZ","info": [{"objectid": 1343,"fields": ["字段 ZDDM 長(zhǎng)度不為 19 位","字段 BDCDYH 長(zhǎng)度不為 28 位","字段 ZRZH 長(zhǎng)度不為 24 位","字段 ZDZHTZM 不符合規(guī)范"]},{"objectid": 813,"fields": []}]},{"layer": "ZD_SHYQ","info": [{"objectid": 780,"fields": ["必填字段 QLR 為空","字段 YSDM 長(zhǎng)度不為 10 位","字段 BDCDYH 長(zhǎng)度不為 28 位","字段 ZDTZM 不符合規(guī)范","字段 DZWTZM 不符合規(guī)范"]}]}] }總結(jié)
以上是生活随笔為你收集整理的地籍数据属性质检功能设计与实现的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2021年江苏高考各科成绩查询,江苏20
- 下一篇: 数学在计算机科学上的应用文献,浅谈数学在