Map

*Промежуточный коммит* Добавлены классы новой Data модели Начало

3/16/2019 9:14:16 PM

Details

.gitignore 5(+4 -1)

diff --git a/.gitignore b/.gitignore
index 3c4efe2..a4ff839 100644
--- a/.gitignore
+++ b/.gitignore
@@ -258,4 +258,7 @@ paket-files/
 
 # Python Tools for Visual Studio (PTVS)
 __pycache__/
-*.pyc
\ No newline at end of file
+*.pyc
+
+# Doxygen documentation
+**/Content/html/*
\ No newline at end of file
diff --git a/ModelData/BusinessModel/BaseAndInterface/BaseOntologyEntity.cs b/ModelData/BusinessModel/BaseAndInterface/BaseOntologyEntity.cs
new file mode 100644
index 0000000..97cbaf0
--- /dev/null
+++ b/ModelData/BusinessModel/BaseAndInterface/BaseOntologyEntity.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ModelData.BusinessModel.BaseAndInterface
+{
+    public abstract class BaseOntologyEntity : I_URLcs
+    {
+        const string BaseURL = "http://127.0.0.1/Jena/";
+
+
+
+        public string URL { set; get; }
+
+        public string Title
+        {
+            get
+            {
+                return URL.Split('\\')[0];
+            }
+        }
+
+    }
+}
diff --git a/ModelData/BusinessModel/BaseAndInterface/I_URLcs.cs b/ModelData/BusinessModel/BaseAndInterface/I_URLcs.cs
new file mode 100644
index 0000000..d152010
--- /dev/null
+++ b/ModelData/BusinessModel/BaseAndInterface/I_URLcs.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ModelData.BusinessModel.BaseAndInterface
+{
+    interface I_URLcs
+    {
+        string Title { get; }
+
+        string URL { set;  get; }
+    }
+}
diff --git a/ModelData/BusinessModel/BusinessDataManager.cs b/ModelData/BusinessModel/BusinessDataManager.cs
index 6e4f6c4..6eda5ea 100644
--- a/ModelData/BusinessModel/BusinessDataManager.cs
+++ b/ModelData/BusinessModel/BusinessDataManager.cs
@@ -51,33 +51,6 @@ namespace ModelData.BusinessModel
             var lst_query = RDFQuery.GetData(RDFQuery.QueryType.AllSettlements , new string[] { YearMin, YearMax });
             Settlement settlement;
 
-            /*
-            0-9 : 151
-            10-49 : 206
-            50-99 : 136
-            100-299 : 283
-            300-999 : 409
-            1000-4999 : 129
-            5000-9999 : 18
-            10000-29999 : 9
-            30000-99999 : 7
-            100000-999999 : 3
-             */
-
-            //Dictionary<string, int> stat = new Dictionary<string, int>
-            //{
-            //    ["0-9"] = 0,
-            //    ["10-49"] = 0,
-            //    ["50-99"] = 0,
-            //    ["100-299"] = 0,
-            //    ["300-999"] = 0,
-            //    ["1000-4999"] = 0,
-            //    ["5000-9999"] = 0,
-            //    ["10000-29999"] = 0,
-            //    ["30000-99999"] = 0,
-            //    ["100000-999999"] = 0
-            //};
-            //System.IO.StreamWriter wr = new System.IO.StreamWriter("D:\\out.txt");
             foreach (var elem in lst_query)
             {
                 int pop = int.Parse(elem["population"].ToString().Split('^')[0]);
@@ -86,32 +59,7 @@ namespace ModelData.BusinessModel
                     Population = elem["population"] != null ? elem["population"].ToString() : "0"
                 };
                 lst_settlements.Add(settlement);
-
-                //if (pop > -1 && pop < 10)
-                //    stat["0-9"]++;
-                //else if (pop > 9 && pop < 50)
-                //    stat["10-49"]++;
-                //else if (pop > 49 && pop < 100)
-                //    stat["50-99"]++;
-                //else if (pop > 99 && pop < 300)
-                //    stat["100-299"]++;
-                //else if (pop > 299 && pop < 1000)
-                //    stat["300-999"]++;
-                //else if (pop > 999 && pop < 5000)
-                //    stat["1000-4999"]++;
-                //else if (pop > 4999 && pop < 10000)
-                //    stat["5000-9999"]++;
-                //else if (pop > 9999 && pop < 30000)
-                //    stat["10000-29999"]++;
-                //else if (pop > 29999 && pop < 100000)
-                //    stat["30000-99999"]++;
-                //else if (pop > 99999 && pop < 1000000)
-                //    stat["100000-999999"]++;
             }
-
-            //foreach (var item in stat)
-            //    wr.WriteLine(item.Key + " : " + item.Value);
-            //wr.Close();
         }
 
         static int u = 0;
@@ -163,15 +111,8 @@ namespace ModelData.BusinessModel
 
         public Settlement GetInfoAboutSettlement(string URL)
         {
-            Settlement settlement = lst_settlements[FindByURL(URL)];
-            
-            //  Условия, которые проверят наличие данных о поселении
-            //  Если данных нет (кроме имени и координат), нужно выполнить их загрузку
-            if (settlement.Type == null)
-            {
-                LoadInfoAboutSettlement(URL);
-            }
-            return settlement;
+            LoadInfoAboutSettlement(URL);
+            return lst_settlements[FindByURL(URL)];
         }
 
         public string[] GetSettlementsNames(string subName)
diff --git a/ModelData/BusinessModel/ExtraEntities/DataSourseEntity.cs b/ModelData/BusinessModel/ExtraEntities/DataSourseEntity.cs
new file mode 100644
index 0000000..7df3b06
--- /dev/null
+++ b/ModelData/BusinessModel/ExtraEntities/DataSourseEntity.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ModelData.BusinessModel.ExtraEntities
+{
+    /// <summary>
+    /// Отображает внешний источник данных параметров
+    /// </summary>
+    public class DataSourseEntity
+    {
+
+        public string URL { set; get; }
+
+        public Dictionary <string, string> Data { set; get; }
+
+
+
+    }
+}
diff --git a/ModelData/BusinessModel/ExtraEntities/Region.cs b/ModelData/BusinessModel/ExtraEntities/Region.cs
new file mode 100644
index 0000000..20955c2
--- /dev/null
+++ b/ModelData/BusinessModel/ExtraEntities/Region.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using ModelData.BusinessModel.BaseAndInterface;
+
+namespace ModelData.BusinessModel.MainEntities
+{
+    /// \class  Region
+    ///
+    /// \brief  A region.
+    ///
+    /// \author Deniska
+    /// \date   14.03.2019
+
+    public class Region : BaseOntologyEntity
+    {
+        public Region partOfRegion { set; get; }
+    }
+}
diff --git a/ModelData/BusinessModel/MainEntities/EditedSettlement.cs b/ModelData/BusinessModel/MainEntities/EditedSettlement.cs
new file mode 100644
index 0000000..6893dd0
--- /dev/null
+++ b/ModelData/BusinessModel/MainEntities/EditedSettlement.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using ModelData.BusinessModel.Tools;
+using ModelData.BusinessModel.BaseAndInterface;
+using ModelData.BusinessModel.ExtraEntities;
+
+namespace ModelData.BusinessModel.MainEntities
+{
+    public class EditedSettlement : BaseOntologyEntity
+    {
+
+        public enum Enum_SettlementType
+        {
+            Не_определен,
+            Город,
+            Пригород
+        }
+
+
+
+        public Settlement before { set; get; }
+        public Period hasBeginning { set; get; }
+
+        public string src_settlementType { set; get; }
+        public Enum_SettlementType settlementType
+        {
+            get
+            {
+                Enum_SettlementType res = Enum_SettlementType.Не_определен;
+
+                Enum.TryParse<Enum_SettlementType>(src_settlementType, out res);                    
+                                
+                return res;                
+            }
+        }
+
+
+        public DataSourseEntity data { set; get; }
+
+    }
+}
diff --git a/ModelData/BusinessModel/MainEntities/Settlement.cs b/ModelData/BusinessModel/MainEntities/Settlement.cs
new file mode 100644
index 0000000..b019c03
--- /dev/null
+++ b/ModelData/BusinessModel/MainEntities/Settlement.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using ModelData.BusinessModel.Tools;
+using ModelData.BusinessModel.BaseAndInterface;
+
+namespace ModelData.BusinessModel.MainEntities
+{
+    public class Settlement : BaseOntologyEntity
+    {
+        public Coordinate Coordinate { set; get; }
+
+        public Period hasBeginning { set; get; }
+
+        public Dictionary<string, string> Properties { set; get; }
+
+        public List<EditedSettlement> EditedSettlements { set; get; }
+    }
+}
diff --git a/ModelData/BusinessModel/Tools/Coordinate.cs b/ModelData/BusinessModel/Tools/Coordinate.cs
new file mode 100644
index 0000000..f46676e
--- /dev/null
+++ b/ModelData/BusinessModel/Tools/Coordinate.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using System.ComponentModel;
+
+namespace ModelData.BusinessModel.Tools
+{
+    public class Coordinate
+    {
+        [DisplayName("Ширина")]
+        public double Lat { set; get; }
+
+        [DisplayName("Долгота")]
+        public double Long { set; get; }
+
+
+        public Coordinate()
+        {
+            Lat = 0;
+            Long = 0;
+        }
+        public Coordinate(VDS.RDF.INode long_, VDS.RDF.INode lat_)
+        {
+            this.Lat = double.Parse(long_.ToString().Split('^')[0].Replace('.', ','));
+            this.Long = double.Parse(lat_.ToString().Split('^')[0].Replace('.', ','));
+        }
+        public Coordinate(double x, double y)
+        {
+            this.Lat = x;
+            this.Long = y;
+        }
+        public Coordinate(Position origin)
+        {
+            Lat = origin.X;
+            Long = origin.Y;
+        }
+
+
+        public static bool TryParse(string src, out Coordinate val)
+        {
+            val = new Coordinate();
+            return true;
+        }
+        public override string ToString()
+        {
+            return Lat + " " + Long;
+        }
+
+
+    }
+}
\ No newline at end of file
diff --git a/ModelData/BusinessModel/Tools/Period.cs b/ModelData/BusinessModel/Tools/Period.cs
new file mode 100644
index 0000000..9214e63
--- /dev/null
+++ b/ModelData/BusinessModel/Tools/Period.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ModelData.BusinessModel.Tools
+{
+    public class Period
+    {
+        public string src_BeginDateString { set; get; }
+        public string src_EndDateString { set; get; }
+
+
+        public DateTime Begin_DateTime
+        {
+            get
+            {
+                return DateTime.Now;
+            }
+        }
+
+
+        //if (a > b) 1920 = 1900.20f
+        public float Begin_Float
+        {
+            get
+            {
+                return 0f;
+            }
+        }
+
+
+    }
+}
diff --git a/ModelData/BusinessModel/UnitOfWork/Context.cs b/ModelData/BusinessModel/UnitOfWork/Context.cs
new file mode 100644
index 0000000..1b23754
--- /dev/null
+++ b/ModelData/BusinessModel/UnitOfWork/Context.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using ModelData.BusinessModel.RDF;
+using ModelData.BusinessModel.MainEntities;
+using ModelData.BusinessModel.ExtraEntities;
+
+namespace ModelData.BusinessModel.UnitOfWork
+{
+    public class Context
+    {
+
+        public IEnumerable<Settlement> settlements { set; get; }
+        //public IEnumerable<EditedSettlement> editedSettlements { set; get; }
+
+
+        private void LoadAllSettlements(string YearMin, string YearMax)
+        {
+            var lst_query = RDFQuery.GetData(RDFQuery.QueryType.AllSettlements, new string[] { YearMin, YearMax });
+            Settlement settlement;
+
+            foreach (var elem in lst_query)
+            {
+                int pop = int.Parse(elem["population"].ToString().Split('^')[0]);
+                settlement = new Settlement(elem["settlement"].ToString(), elem["name"].ToString(), new Position(elem["long"], elem["lat"]))
+                {
+                    Population = elem["population"] != null ? elem["population"].ToString() : "0"
+                };
+                lst_settlements.Add(settlement);
+            }
+        }
+
+        static int u = 0;
+        private void LoadInfoAboutSettlement(string URL)
+        {
+            System.IO.StreamWriter wr = new System.IO.StreamWriter("D:\\out.txt", true);
+            wr.WriteLine(URL);
+
+            var lst_query = RDFQuery.GetData(RDFQuery.QueryType.SettlementInfo, new string[] { URL });
+            foreach (var elem in lst_query)
+            {
+                //name nameOfRegion nameOfType hasBeginning lat long population populationOfMan populationOfWoman year source
+                Settlement settlement = lst_settlements[FindByURL(URL)];
+                settlement.Type = elem["nameOfType"] != null ? elem["nameOfType"].ToString() : null;
+                settlement.Year = elem["year"] != null ? elem["year"].ToString() : null;
+                settlement.Region = elem["nameOfRegion"] != null ? elem["nameOfRegion"].ToString() : null;
+                settlement.Population = elem["population"] != null ? elem["population"].ToString() : "0";
+                settlement.PopulationOfMan = elem["populationOfMan"] != null ? elem["populationOfMan"].ToString() : null;
+                settlement.PopulationOfWoman = elem["populationOfWoman"] != null ? elem["populationOfWoman"].ToString() : null;
+                settlement.Description = u.ToString();
+                settlement.Source = elem["source"] != null ? elem["source"].ToString() : null;
+
+                u++;
+                wr.Close();
+                //lst_settlements.Add(new_settlement);
+            }
+        }
+
+        #region Tools
+
+        private void Clear()
+        {
+            lst_settlements = new List<Settlement>();
+        }
+
+        private int FindByName(string name)
+        {
+            for (int i = 0; i < lst_settlements.Count; i++)
+            {
+                if (lst_settlements[i].Name == name)
+                    return i;
+            }
+            return -1;
+        }
+
+        private int FindByURL(string URL)
+        {
+            for (int i = 0; i < lst_settlements.Count; i++)
+            {
+                if (lst_settlements[i].URL == URL)
+                    return i;
+            }
+            return -1;
+        }
+
+        #endregion
+
+    }
+}
diff --git a/ModelData/ModelData.csproj b/ModelData/ModelData.csproj
index 366b8b5..2d4ba28 100644
--- a/ModelData/ModelData.csproj
+++ b/ModelData/ModelData.csproj
@@ -55,11 +55,20 @@
     </Reference>
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="BusinessModel\BaseAndInterface\BaseOntologyEntity.cs" />
+    <Compile Include="BusinessModel\BaseAndInterface\I_URLcs.cs" />
     <Compile Include="BusinessModel\BusinessDataManager.cs" />
+    <Compile Include="BusinessModel\ExtraEntities\DataSourseEntity.cs" />
+    <Compile Include="BusinessModel\ExtraEntities\Region.cs" />
+    <Compile Include="BusinessModel\MainEntities\EditedSettlement.cs" />
+    <Compile Include="BusinessModel\MainEntities\Settlement.cs" />
     <Compile Include="BusinessModel\Position.cs" />
     <Compile Include="BusinessModel\RDF\Queries.cs" />
     <Compile Include="BusinessModel\Settlement.cs" />
     <Compile Include="BusinessModel\RDF\RDFQuery.cs" />
+    <Compile Include="BusinessModel\Tools\Coordinate.cs" />
+    <Compile Include="BusinessModel\Tools\Period.cs" />
+    <Compile Include="BusinessModel\UnitOfWork\Context.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="WebModel\MapPoint.cs" />
     <Compile Include="WebModel\WebDataManager.cs" />
diff --git a/web-map/Controllers/HomeController.cs b/web-map/Controllers/HomeController.cs
index 6137484..3fa2312 100644
--- a/web-map/Controllers/HomeController.cs
+++ b/web-map/Controllers/HomeController.cs
@@ -19,5 +19,14 @@ namespace web_map.Controllers
 
             return View();
         }
+
+        public ActionResult GetDoc(string fileName)
+        {
+            string path = Server.MapPath("~/App_Data") + "/html/index.html";
+            System.IO.FileInfo file = new System.IO.FileInfo(path);
+            if (file.Exists)
+                return File(file.FullName, "text/plain", file.Name);
+            return Content("");
+        }
     }
 }
\ No newline at end of file
diff --git a/web-map/Controllers/MapAPIController.cs b/web-map/Controllers/MapAPIController.cs
index 7a919c5..64147dd 100644
--- a/web-map/Controllers/MapAPIController.cs
+++ b/web-map/Controllers/MapAPIController.cs
@@ -50,7 +50,7 @@ namespace web_map.Controllers
             WebDataManager webData = WebDataManager.Get();
 
             return Json(webData.GetSettlementsNames(subName), JsonRequestBehavior.AllowGet);
-        }
+        }        
 
     }
 }
\ No newline at end of file
diff --git a/web-map/Scripts/SiteScripts/AjaxQuery.js b/web-map/Scripts/SiteScripts/AjaxQuery.js
index e98b426..efcad4f 100644
--- a/web-map/Scripts/SiteScripts/AjaxQuery.js
+++ b/web-map/Scripts/SiteScripts/AjaxQuery.js
@@ -101,4 +101,31 @@ function GetDate() {
             alert('Ошибка. Не удалось получить данные от сервера');
         }
     });
-}
\ No newline at end of file
+}
+
+
+
+//function apiConnect(apiKey) {
+
+//    function get(route) {
+//        return fetch(`${route}?key=${apiKey}`);
+//    }
+
+//    function post(route, params) {
+//        return
+//        fetch(route,
+//            {
+//                method: 'POST',
+//                body: JSON.stringify(params),
+//                headers: {
+//                    'Authorization': `Bearer ${apiKey}`
+//                }
+//            })
+//    }
+
+//    return { get, post }
+//}
+//const api = apiConnect('my-secret-key');
+//// Использовать ключ доступа к API больше уже не нужно
+//api.get('http://www.example.com/get-endpoint');
+//api.post('http://www.example.com/post-endpoint', { name: 'Joe' });
\ No newline at end of file
diff --git a/web-map/Views/Home/FAQ.cshtml b/web-map/Views/Home/FAQ.cshtml
index cc8dca4..8f39475 100644
--- a/web-map/Views/Home/FAQ.cshtml
+++ b/web-map/Views/Home/FAQ.cshtml
@@ -4,6 +4,10 @@
 
 <h1>Инструкции</h1>
 <h2>На этой странице будут инструкции по работе с картой</h2>
+<a href="~/Content/html/index.html">Doc</a>
+
+@Html.ActionLink("Инструкция", "Index", "Doc")
+
 
 <!--
 <address>
diff --git a/web-map/Views/Map/Map.cshtml b/web-map/Views/Map/Map.cshtml
index ef4f831..df3a0d6 100644
--- a/web-map/Views/Map/Map.cshtml
+++ b/web-map/Views/Map/Map.cshtml
@@ -19,7 +19,7 @@
 
 <div class="row" style="margin-top: 20px">
     <div class="col-xs-1">
-            <input id="NameCount" type="text" class="form-control" value="10">
+        <input id="NameCount" type="text" class="form-control" value="10">
     </div>
 
     <div class="col-xs-11">
@@ -32,11 +32,11 @@
     </div>
 
     @*<div class="col-xs-10">
-        <div class="input-group">
-            <span class="input-group-addon" id="basic-addon1"><i class="glyphicon glyphicon-search"></i></span>
-            <input id="inputName" type="text" class="form-control" placeholder="Введите название">
-        </div>
-    </div>*@
+            <div class="input-group">
+                <span class="input-group-addon" id="basic-addon1"><i class="glyphicon glyphicon-search"></i></span>
+                <input id="inputName" type="text" class="form-control" placeholder="Введите название">
+            </div>
+        </div>*@
 </div>
 <div class="row" style="margin-top: 20px; margin-bottom: 10px">
     <div class="col-xs-8 col-sm-8" style="line-height: 43px;">