1: using System;
2: using System.Collections;
3: using System.Collections.Generic;
4: using System.Linq;
5: using System.Web;
6: using System.ComponentModel.DataAnnotations;
7: using System.ComponentModel.DataAnnotations.Schema;
8: using System.Data;
9:
10: namespace Ia.TentPlay.Cl.Model.Business.Trek
11: {
12: ////////////////////////////////////////////////////////////////////////////
13:
14: /// <summary publish="true">
15: /// FeatureClass Support class for TentPlay Trek business model
16: /// </summary>
17: ///
18: /// <remarks>
19: /// Copyright © 2012-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
20: ///
21: /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
22: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
23: ///
24: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
25: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
26: ///
27: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
28: ///
29: /// Copyright notice: This notice may not be removed or altered from any source distribution.
30: /// </remarks>
31: public partial class FeatureClass
32: {
33: /*
34: public enum FeatureClassName
35: {
36: Administrative, Populated, Vegetation, Locality, Undersea, Street, Hypsographic, Hydrographic, Spot
37: }
38: */
39:
40: /// <summary/>
41: public FeatureClass() { }
42: /*
43: /// <summary/>
44: public FeatureClass(string id)
45: {
46: this.Id = id;
47: }
48: */
49: /// <summary/>
50: public FeatureClass(string id, string name, string caption)
51: {
52: this.Id = id;
53: this.Name = name;
54: this.Caption = caption;
55: }
56: /*
57: /// <summary/>
58: public FeatureClass(string id, string name, string caption, int count)
59: {
60: this.Id = id;
61: this.Name = name;
62: this.Caption = caption;
63: this.Count = count;
64: }
65: */
66: ///<summary/>
67: public string Id { get; set; }
68: ///<summary/>
69: public string Name { get; set; }
70: ///<summary ///<summary/>
71: public string Caption { get; set; }
72:
73: public string Description { get; set; }
74: ///<summary/>
75: public int Count { get; set; }
76:
77: ///<summary/>
78: public ICollection<Ia.TentPlay.Cl.Model.Business.Trek.FeatureDesignation> FeatureDesignations
79: {
80: get
81: {
82: return null;
83: }
84: }
85:
86: ////////////////////////////////////////////////////////////////////////////
87:
88: /// <summary>
89: ///
90: /// </summary>
91: public static string ConvertBinaryToBooleanAndOrStringOfClassFeatures(string b)
92: {
93: int i;
94: string s;
95:
96: s = string.Empty;
97:
98: i = Convert.ToInt32(b, 2);
99:
100: if ((i & 256) == 256) s += @"ncw.Class == ""A"" || ";
101: if ((i & 128) == 128) s += @"ncw.Class == ""P"" || ";
102: if ((i & 64) == 64) s += @"ncw.Class == ""V"" || ";
103: if ((i & 32) == 32) s += @"ncw.Class == ""L"" || ";
104: if ((i & 16) == 16) s += @"ncw.Class == ""U"" || ";
105: if ((i & 8) == 8) s += @"ncw.Class == ""R"" || ";
106: if ((i & 4) == 4) s += @"ncw.Class == ""T"" || ";
107: if ((i & 2) == 2) s += @"ncw.Class == ""H"" || ";
108: if ((i & 1) == 1) s += @"ncw.Class == ""S"" || ";
109:
110: if (!string.IsNullOrEmpty(s))
111: {
112: s = s.Remove(s.Length - 4, 4);
113: }
114: else s = @"ncw.Class == ""Z""";
115:
116: return s;
117: }
118:
119: ////////////////////////////////////////////////////////////////////////////
120:
121: /// <summary>
122: ///
123: /// </summary>
124: public static string ConvertIntegerToBooleanAndOrStringOfClassFeatures(int i)
125: {
126: return ConvertBinaryToBooleanAndOrStringOfClassFeatures(ConvertIntegerToBinary(i));
127: }
128:
129: ////////////////////////////////////////////////////////////////////////////
130:
131: /// <summary>
132: ///
133: /// </summary>
134: public static string ConvertIntegerToBinary(int i)
135: {
136: string s;
137:
138: s = Ia.Cl.Model.Default.IntegerToBinaryString(i);
139:
140: return s;
141: }
142:
143: ////////////////////////////////////////////////////////////////////////////
144:
145: /// <summary>
146: ///
147: /// </summary>
148: public static int ConvertBinaryToInteger(bool administrative, bool populated, bool vegetation, bool locality, bool undersea, bool street, bool hypsographic, bool hydrographic, bool spot)
149: {
150: int i;
151: string s;
152:
153: s = string.Empty;
154:
155: s += administrative ? "1" : "0";
156: s += populated ? "1" : "0";
157: s += vegetation ? "1" : "0";
158: s += locality ? "1" : "0";
159: s += undersea ? "1" : "0";
160: s += street ? "1" : "0";
161: s += hypsographic ? "1" : "0";
162: s += hydrographic ? "1" : "0";
163: s += spot ? "1" : "0";
164:
165: i = Convert.ToInt32(s, 2);
166:
167: return i;
168: }
169:
170: ////////////////////////////////////////////////////////////////////////////
171: ////////////////////////////////////////////////////////////////////////////
172: }
173:
174: ////////////////////////////////////////////////////////////////////////////
175: ////////////////////////////////////////////////////////////////////////////
176: }