Ejemplo n.º 1
0
        public AddCommand(
            ICloudObjectsContainer <SlamPoint> pointsContainer,
            ICloudObjectsContainer <SlamLine> linesContainer,
            ICloudObjectsContainer <SlamObservation> observationsContainer,
            SlamPackage slamEvent)
        {
            m_pointsContainer       = pointsContainer;
            m_linesContainer        = linesContainer;
            m_observationsContainer = observationsContainer;

            if (slamEvent.Points != null)
            {
                m_addedPoints = slamEvent.Points.Where(p => p.isNew).ToArray();
            }
            if (slamEvent.Lines != null)
            {
                m_addedLines = slamEvent.Lines.Where(l => !m_linesContainer.Exists(l)).ToArray();
                for (int i = 0; i < m_addedLines.Length; ++i)
                {
                    m_addedLines[i].isRemoved = true;
                    m_addedLines[i].vert1     = m_pointsContainer[m_addedLines[i].pointId1].position;
                    m_addedLines[i].vert2     = m_pointsContainer[m_addedLines[i].pointId2].position;
                }
            }
            if (slamEvent.Observations != null)
            {
                m_addedObservations = slamEvent.Observations.Where(o => o.Point.isNew && o.Point.id != -1).ToArray();
            }
        }
        public static void TestNonExistent(
            this SlamPackage package,
            Func <SlamPoint, bool> filter,
            ICloudObjectsContainer <SlamPoint> pointsContainer,
            ICloudObjectsContainer <SlamObservation> graph)
        {
#if DEBUG
            if (package.Points != null)
            {
                var existentPoints = SlamObjectQuery(package.Points.Where(p => filter(p)), id => !pointsContainer.Exists(id));
                ElektronikLogger.WrapDebug(() => Test(package, existentPoints, "Point id {0} doesn't exists. New: '{1}'. Removed: '{2}'"));
            }
            if (package.Observations != null)
            {
                var existentObs = SlamObjectQuery(package.Observations.Select(o => (SlamPoint)o).Where(o => filter(o)), id => !graph.Exists(id));
                ElektronikLogger.WrapDebug(() => Test(package, existentObs, "Observation id {0} doesn't exists. New: '{1}'. Removed: '{2}'"));
            }
#endif
        }
 public static void TestExistent(
     this SlamPackage package,
     Func <SlamPoint, bool> filter,
     ICloudObjectsContainer <SlamPoint> pointsContainer,
     ICloudObjectsContainer <SlamObservation> graph)
 {
     if (package.Points != null)
     {
         var existentPoints = SlamObjectQuery(package.Points.Where(p => filter(p)), id => pointsContainer.Exists(id));
         Test(package, existentPoints, "Point id {0} already exists. New: '{1}'. Removed: '{2}'");
     }
     if (package.Observations != null)
     {
         var existentObs = SlamObjectQuery(package.Observations.Select(o => (SlamPoint)o).Where(o => filter(o)), id => graph.Exists(id));
         Test(package, existentObs, "Observation id {0} already exists. New: '{1}'. Removed: '{2}'");
     }
 }