예제 #1
0
        /// <summary>
        /// http://www.blogjava.net/oathleo/archive/2011/09/14/358603.html
        /// </summary>
        /// <param name="originData"></param>
        /// <param name="accuracyE"></param>
        /// <returns></returns>
        public static List <Point> SDTCompress(List <Point> originData, double accuracyE)//后两个参数为其异步编程使用
        {
            List <Point> dataCompressed = new List <Point>();
            //上门和下门,初始时是关着的
            double upGate = -double.MaxValue;  //定义上门
            double downGate = double.MaxValue; //定义下门
            double nowUp, nowDown;             //当前数据的上下斜率

            if (originData.Count <= 0)
            {
                return(null);
            }

            PointContent status = new PointContent();

            status.LastReadData   = originData[0];       //当前数据的前一个数据
            status.LastStoredData = status.LastReadData; //最近保存的点
            dataCompressed.Add(status.LastReadData);
            int i = 0;

            foreach (var currentPoint in originData)
            {
                status.CurrentReadData = currentPoint;//当前读取到的数据
                nowUp = (currentPoint.value - status.LastStoredData.value - accuracyE) / (currentPoint.timestampClient - status.LastStoredData.timestampClient);
                //判断最大的上斜率,最小的下斜率
                if (nowUp > upGate)
                {
                    upGate = nowUp;
                }
                nowDown = (currentPoint.value - status.LastStoredData.value + accuracyE) / (currentPoint.timestampClient - status.LastStoredData.timestampClient);
                if (nowDown < downGate)
                {
                    downGate = nowDown;
                }
                //不在平行四边内,即内角和大于等于180度
                if (upGate >= downGate)
                {
                    status.LastStoredData = status.LastReadData; //修改最近保存的点
                    dataCompressed.Add(status.LastReadData);     //保存前一个点
                    upGate   = (currentPoint.value - status.LastStoredData.value - accuracyE) / (currentPoint.timestampClient - status.LastStoredData.timestampClient);
                    downGate = (currentPoint.value - status.LastStoredData.value + accuracyE) / (currentPoint.timestampClient - status.LastStoredData.timestampClient);
                }
                status.LastReadData = currentPoint;
                i++;
            }

            //if (dataCompressed.Count == 1)
            //{
            //    dataCompressed.Add(originData[originData.Count - 1]);
            //}
            return(dataCompressed);
        }
        public PointContentEditorWindow(PointContent toLoad)
        {
            InitializeComponent();
            StatusContext = new StatusControlContext();

            StatusContext.RunFireAndForgetBlockingTaskWithUiMessageReturn(async() =>
            {
                PointContent = await PointContentEditorContext.CreateInstance(StatusContext, toLoad);

                PointContent.RequestContentEditorWindowClose += (_, _) => { Dispatcher?.Invoke(Close); };
                AccidentalCloserHelper = new WindowAccidentalClosureHelper(this, StatusContext, PointContent);

                await ThreadSwitcher.ResumeForegroundAsync();
                DataContext = this;
            });
        }
예제 #3
0
        /// <summary>
        /// http://www.blogjava.net/oathleo/archive/2011/09/14/358603.html
        /// </summary>
        /// <param name="originData"></param>
        /// <returns></returns>
        public static List <Point> CompressString(List <Point> originData)//后两个参数为其异步编程使用
        {
            var dataCompressed = new List <Point>();

            if (originData.Count <= 0)
            {
                return(null);
            }

            PointContent status = new PointContent();

            status.LastReadData   = originData[0];       //当前数据的前一个数据
            status.LastStoredData = status.LastReadData; //最近保存的点
            dataCompressed.Add(status.LastStoredData);
            for (int i = 0; i < originData.Count(); i++)
            {
                status.CurrentReadData = originData[i];//当前读取到的数据
                if ((status.CurrentReadData.timestampClient - status.LastReadData.timestampClient) > status.CurrentReadData.interval * 5)
                {
                    status.LastStoredData = status.LastReadData;
                    dataCompressed.Add(status.LastStoredData);
                    dataCompressed.Add(new Point
                    {
                        pointid         = status.LastStoredData.pointid,
                        tenantid        = status.LastStoredData.tenantid,
                        value           = status.LastStoredData.value,
                        quality         = 24,
                        interval        = status.LastStoredData.interval,
                        timestampClient = status.LastStoredData.timestampClient + status.LastStoredData.interval / 2,
                        timestampServer = status.LastStoredData.timestampServer + status.LastStoredData.interval / 2
                    });
                    status.LastStoredData = status.CurrentReadData;
                    dataCompressed.Add(status.LastStoredData);
                    status.LastReadData = status.CurrentReadData;
                }
                else if (status.CurrentReadData.value.Equals(status.LastReadData.value))
                {
                    status.LastStoredData = status.CurrentReadData;
                    dataCompressed.Add(status.LastStoredData);
                    status.LastReadData = status.CurrentReadData;
                }
            }

            return(dataCompressed);
        }
예제 #4
0
 public static string Create(PointContent content)
 {
     return($@"{{{{{BracketCodeToken} {content.ContentId}; {content.Title}}}}}");
 }
 public static Point PointContentToPoint(PointContent content)
 {
     return(SpatialHelpers.Wgs84GeometryFactory()
            .CreatePoint(new CoordinateZ(content.Longitude, content.Latitude, content.Elevation ?? 0)));
 }
예제 #6
0
        /// <summary>
        /// http://www.blogjava.net/oathleo/archive/2011/09/14/358603.html
        /// </summary>
        /// <param name="originData"></param>
        /// <param name="accuracyE"></param>
        /// <returns></returns>
        public static List <Point> CompressMonitorSDT(List <Point> originData, double accuracyE)//后两个参数为其异步编程使用
        {
            List <Point> dataCompressed = new List <Point>();
            //上门和下门,初始时是关着的
            double upGate = -double.MaxValue;  //定义上门
            double downGate = double.MaxValue; //定义下门
            double nowUp, nowDown;             //当前数据的上下斜率

            if (originData.Count <= 1)
            {
                return(dataCompressed);
            }

            PointContent contentStatus = new PointContent();

            contentStatus.LastReadData   = originData[0];              //当前数据的前一个数据
            contentStatus.LastStoredData = contentStatus.LastReadData; //最近保存的点
            dataCompressed.Add(contentStatus.LastReadData);
            foreach (var currentPoint in originData)
            {
                contentStatus.CurrentReadData = currentPoint;//当前读取到的数据
                if ((contentStatus.CurrentReadData.timestampClient - contentStatus.LastReadData.timestampClient) > contentStatus.CurrentReadData.interval * 5)
                {
                    contentStatus.LastStoredData = contentStatus.LastReadData;
                    dataCompressed.Add(contentStatus.LastStoredData);
                    dataCompressed.Add(new Point
                    {
                        pointid         = contentStatus.LastStoredData.pointid,
                        tenantid        = contentStatus.LastStoredData.tenantid,
                        value           = contentStatus.LastStoredData.value,
                        quality         = 24,
                        interval        = contentStatus.LastStoredData.interval,
                        timestampClient = contentStatus.LastStoredData.timestampClient + contentStatus.LastStoredData.interval / 2,
                        timestampServer = contentStatus.LastStoredData.timestampServer + contentStatus.LastStoredData.interval / 2
                    });
                    contentStatus.LastStoredData = contentStatus.CurrentReadData;
                    dataCompressed.Add(contentStatus.LastStoredData);
                    contentStatus.LastReadData = contentStatus.CurrentReadData;
                }
                else
                {
                    nowUp = (currentPoint.value - contentStatus.LastStoredData.value - accuracyE) / (currentPoint.timestampClient - contentStatus.LastStoredData.timestampClient);
                    //判断最大的上斜率,最小的下斜率
                    if (nowUp > upGate)
                    {
                        upGate = nowUp;
                    }
                    nowDown = (currentPoint.value - contentStatus.LastStoredData.value + accuracyE) / (currentPoint.timestampClient - contentStatus.LastStoredData.timestampClient);
                    if (nowDown < downGate)
                    {
                        downGate = nowDown;
                    }
                    //不在平行四边内,即内角和大于等于180度
                    if (upGate >= downGate)
                    {
                        contentStatus.LastStoredData = contentStatus.LastReadData; //修改最近保存的点
                        dataCompressed.Add(contentStatus.LastReadData);            //保存前一个点
                        upGate   = (currentPoint.value - contentStatus.LastStoredData.value - accuracyE) / (currentPoint.timestampClient - contentStatus.LastStoredData.timestampClient);
                        downGate = (currentPoint.value - contentStatus.LastStoredData.value + accuracyE) / (currentPoint.timestampClient - contentStatus.LastStoredData.timestampClient);
                    }
                    contentStatus.LastReadData = currentPoint;
                }
            }
            //if (dataCompressed.Count == 1)
            //{
            //    dataCompressed.Add(originData[originData.Count - 1]);
            //}
            return(dataCompressed);
        }
예제 #7
0
        public static async Task WriteLocalDbJson(PointContent dbEntry)
        {
            var settings = UserSettingsSingleton.CurrentSettings();
            var db       = await Db.Context();

            var jsonDbEntry = JsonSerializer.Serialize(dbEntry);

            var jsonFile = new FileInfo(Path.Combine(settings.LocalSitePointContentDirectory(dbEntry).FullName,
                                                     $"{Names.PointContentPrefix}{dbEntry.ContentId}.json"));

            if (jsonFile.Exists)
            {
                jsonFile.Delete();
            }
            jsonFile.Refresh();

            await FileManagement.WriteAllTextToFileAndLogAsync(jsonFile.FullName, jsonDbEntry);

            var latestHistoricEntries = db.HistoricPointContents.Where(x => x.ContentId == dbEntry.ContentId)
                                        .OrderByDescending(x => x.LastUpdatedOn).Take(10);

            var jsonHistoricFile = new FileInfo(Path.Combine(settings.LocalSitePointContentDirectory(dbEntry).FullName,
                                                             $"{Names.HistoricPointContentPrefix}{dbEntry.ContentId}.json"));

            if (jsonHistoricFile.Exists)
            {
                jsonHistoricFile.Delete();
            }
            jsonHistoricFile.Refresh();

            if (latestHistoricEntries.Any())
            {
                var jsonHistoricDbEntry = JsonSerializer.Serialize(latestHistoricEntries);
                await FileManagement.WriteAllTextToFileAndLogAsync(jsonHistoricFile.FullName, jsonHistoricDbEntry);
            }

            var pointDetailsFile = new FileInfo(Path.Combine(settings.LocalSitePointContentDirectory(dbEntry).FullName,
                                                             $"{Names.PointDetailsContentPrefix}{dbEntry.ContentId}.json"));

            if (pointDetailsFile.Exists)
            {
                pointDetailsFile.Delete();
            }
            pointDetailsFile.Refresh();

            var pointDetails = await Db.PointDetailsForPoint(dbEntry.ContentId, db);

            if (pointDetails.Any())
            {
                var jsonPointDetails = JsonSerializer.Serialize(pointDetails);
                await FileManagement.WriteAllTextToFileAndLogAsync(pointDetailsFile.FullName, jsonPointDetails);
            }

            var historicPointDetailsFile = new FileInfo(Path.Combine(
                                                            settings.LocalSitePointContentDirectory(dbEntry).FullName,
                                                            $"{Names.HistoricPointDetailsContentPrefix}{dbEntry.ContentId}.json"));

            if (historicPointDetailsFile.Exists)
            {
                historicPointDetailsFile.Delete();
            }
            historicPointDetailsFile.Refresh();

            var historicPointDetails = await Db.HistoricPointDetailsForPoint(dbEntry.ContentId, db, 40);

            if (historicPointDetails.Any())
            {
                var jsonPointDetails = JsonSerializer.Serialize(historicPointDetails);
                await FileManagement.WriteAllTextToFileAndLogAsync(historicPointDetailsFile.FullName, jsonPointDetails);
            }
        }
예제 #8
0
    private void UpdateDict(string prefix, Dictionary <string, Vector3> pointDict)
    {
        textBox.text += "starting person\n";

        foreach (KeyValuePair <string, Vector3> kvp in pointDict)
        {
            textBox.text += "testing " + kvp.Key + " on position " + kvp.Value + "\n";

            //get known values (name of point and its screen position)
            string  name      = prefix + "_" + kvp.Key;
            Vector3 screenPos = kvp.Value;

            textBox.text += "after init\n";

            //attempt to get its anchor point if it is defined (ie. hand to elbow)
            pointConnections.TryGetValue(kvp.Key, out string anchor);
            anchor = prefix + "_" + anchor;

            textBox.text += "after get connection\n";

            //attempt to find its world position and confidence
            Vector3 worldPosition = new Vector3(0, 0, 0);
            float   confidence    = 0f;

            raycastManager.Raycast(screenPos, hitResults, TrackableType.All);

            textBox.text += "after raycast \n";

            if (hitResults.Count != 0)
            {
                worldPosition = hitResults[0].pose.position;

                //if we hit a keypoint, find its pointcloud
                //then find the closest point in that pointcloud (because that's totally smart, thanks unity)
                //and get its confidence
                if (hitResults[0].hitType == TrackableType.FeaturePoint)
                {
                    /*
                     * var conf = pointCloudManager.trackables[hitResults[0].trackableId].confidenceValues;
                     * var poss = pointCloudManager.trackables[hitResults[0].trackableId].positions;
                     *
                     * float dist = float.MaxValue;
                     * int possPos = 0;
                     *
                     * for (int i = 0; i < poss.Length; ++i)
                     * {
                     *  float newDist = Vector3.Distance(worldPosition, poss[i]);
                     *
                     *  if (newDist < dist)
                     *  {
                     *      dist = newDist;
                     *      possPos = i;
                     *  }
                     * }
                     */

                    confidence = 0f; //conf[possPos];
                }
            }

            PointContent pc = new PointContent(name, worldPosition, confidence, anchor);

            points.Add(pc);
        }
    }