예제 #1
0
    public void UpdateTransectChartAndOutput(LineInfo lineInfo, bool currLine)
    {
        if (lineInfo == null || lineInfo.mapLayer == null)
        {
            return;
        }

        if (currLine)
        {
            // Add visible grids to the budget layer
            foreach (var layer in gridLayerController.mapLayers)
            {
                AddGridData(layer.Grid);
            }
            lineInspector.LineInspectorGrids.Clear();

            lineInfo.mapLayer.Show(true);
            // Update data values
            lineInfo.mapLayer.Refresh(lineInfo.coords);
            UpdateTransectLineInfoAndAllGridDatas(lineInfo);
        }
        else
        {
            // Hide at the beginning
            lineInfo.mapLayer.Show(false);

            // Move visible grids from budget layer to list
            if (lineInfo.mapLayer.grids.Count > 0)
            {
                lineInspector.LineInspectorGrids.AddRange(lineInfo.mapLayer.grids);
                lineInfo.mapLayer.Clear();
            }
        }
        UpdateOutput();
    }
예제 #2
0
    public void OnRemoveLineInspection(LineInfo lineInfo)
    {
        --lineInspector.LineInspectionCount;

        // if (lineInspector.LineInspectionCount == 1)
        //     inspectorOutput.SetDropDownInteractive(InspectorTool.InspectorType.Line, false);

        if (lineInspector.LineInspectionCount == 0)
        {
            inspectorTool.SetAction(InspectorTool.Action.None);
            lineInspector.CurrLineInspection        = -1;
            removeLineInspectionToggle.interactable = false;

            inspectorOutput.ResetAndClearOutput(InspectorTool.InspectorType.Line);

            // Update transect chart and output
            UpdateTransectLineInfoAndAllGridDatas(null);
            inspectorOutput.LineOutput.UpdateLineInspectorOutput(null, dataLayers);
        }
        else
        {
            // Do necessary swapping of elements in lineInfos array upon deletion of inspection line
            var inspectionLine = lineInfo.lineInspectionDelete.transform.parent;
            int index          = inspectionLine.GetSiblingIndex();
            int count          = lineInspector.LineInspectionCount;
            if (index < count)
            {
                for (int i = index; i < count; ++i)
                {
                    var temp = lineInfos[i];
                    lineInfos[i] = lineInfos[i + 1];
                    var tmpinspectionLine = lineInfos[i + 1].lineInspectionDelete.transform.parent;

                    var tempIndex = tmpinspectionLine.GetSiblingIndex();
                    inspectionLine.SetSiblingIndex(tempIndex);
                    foreach (var controlPt in lineInfos[i].controlPts)
                    {
                        controlPt.InspectionIndex = i;
                    }

                    lineInfos[i + 1] = temp;
                }
            }

            // Update currLineInspection value
            if (lineInspector.CurrLineInspection == index)
            {
                lineInspector.CurrLineInspection = Mathf.Clamp(index - 1, 0, 2);
            }
            else
            {
                Mathf.Clamp(--lineInspector.CurrLineInspection, 0, 2);
            }
        }
        lineInspector.RemoveLineInspectorInfoProperties(lineInfo);
        SetCurrInspection(lineInspector.CurrLineInspection);

        createLineInspectionToggle.interactable = true;
    }
예제 #3
0
 public void UpdateTransectLineInfoAndAllGridDatas(LineInfo lineInfo)
 {
     // Update data values
     transectController.SetLineInfo(lineInfo);
     foreach (var layer in gridLayerController.mapLayers)
     {
         transectController.UpdateGridData(layer.Grid);
     }
 }
예제 #4
0
    public void ChangeKnobsAndLine(LineInfo lineInfo, bool solidThin)
    {
        var startPt = (lineInfo.controlPts[StartPtIndex] as EndPt);
        var endPt   = (lineInfo.controlPts[EndPtIndex] as EndPt);
        var line    = lineInfo.line;

        if (solidThin)
        {
            // Change endpt knobs to solid and thinner line width
            startPt.KnobSolid();
            endPt.KnobSolid();
            line.widthMultiplier = HalfLineWidth;
        }
        else
        {
            // Change endpt knobs to small and normal line width
            startPt.KnobSmall();
            endPt.KnobSmall();
            line.widthMultiplier = LineWidth;
        }
    }
    public void ComputeAndUpdateTotalLength(LineInfo[] lineInfos, int index)
    {
        currLineInspectionIndex = index;
        LineInfo lineInfo = lineInfos[index];

        // Computations
        double lon1 = lineInfo.coords[0].Longitude, lat1 = lineInfo.coords[0].Latitude,
               lon2 = lineInfo.coords[1].Longitude, lat2 = lineInfo.coords[1].Latitude,
               totalLength = GeoCalculator.GetDistanceInMeters(lon1, lat1, lon2, lat2) / 1000.0;

        linePS[currLineInspectionIndex].totalLength = totalLength;

        // Update total length shown
        if (linePSUIRef.summaryDropdown.value == LinePS.SelectedLine)
        {
            linePSUIRef.SelectedTotalLength(linePS[currLineInspectionIndex]);
        }
        else if (linePSUIRef.summaryDropdown.value == LinePS.AllLinesCombined)
        {
            lineDO.AllCombinedTotalLength(linePS, linePSUIRef);
        }
    }
예제 #6
0
    //
    // Private Methods
    //

    private void InitLineInspectorInfo()
    {
        // Initialize line inspections
        lineInfos = new LineInfo[maxInspectionCount];
        for (int i = 0; i < maxInspectionCount; ++i)
        {
            var lineInfo = new LineInfo
            {
                lineInspectionDelete = null,
                lineInspection       = null,
                controlPtsTB         = new List <ToggleButton>(),
                controlPts           = new List <ControlPt>(),
                coords             = new List <Coordinate>(),
                line               = null,
                inspectionLine     = null,
                mapLayer           = null,
                mapViewAreaChanged = false,
                scaleFactor        = 1.0f
            };
            lineInfos[i] = lineInfo;
        }
    }
예제 #7
0
    public void ComputeAndUpdateTotalLength(LineInfo[] lineInfos, int index)
    {
        currLineInspectionIndex = index;
        LineInfo lineInfo = lineInfos[index];

        // Computations
        double lon1 = lineInfo.coords[0].Longitude, lat1 = lineInfo.coords[0].Latitude,
               lon2 = lineInfo.coords[1].Longitude, lat2 = lineInfo.coords[1].Latitude,
               totalLength = GeoCalculator.GetDistanceInMeters(lon1, lat1, lon2, lat2) / 1000.0;

        propertiesAndSummaries[currLineInspectionIndex].totalLength = totalLength;

        // Update total length shown
        if (summaryDropdown.value == SelectedLine)
        {
            SelectedLineTotalLength();
        }
        else if (summaryDropdown.value == AllLinesCombined)
        {
            AllLinesCombinedTotalLength();
        }
    }
 public void SetLineInfo(LineInfo lineInfo)
 {
     this.lineInfo = lineInfo;
 }
    public void UpdateLineInspectorOutput(LineInfo lineInfo, DataLayers dataLayers)
    {
        if (!linePSUIRef.summaryDropdown.value.Equals(LinePS.SelectedLine))
        {
            return;
        }

        Dictionary <string, List <float> > idToValueList    = new Dictionary <string, List <float> >();
        Dictionary <string, int>           idToNoDataList   = new Dictionary <string, int>();
        Dictionary <string, string>        idToUnitsList    = new Dictionary <string, string>();
        Dictionary <string, Color>         idToDotColorList = new Dictionary <string, Color>();

        if (lineInfo != null)
        {
            var lineGrids          = lineInfo.mapLayer.grids;
            var lineInspectedGrids = lineInfo.mapLayer.inspectedGridsData;

            int lineGridsLength = lineGrids.Count;
            for (int i = 0; i < lineGridsLength; ++i)
            {
                var layerName = dataLayers.activeLayerPanels[i].name;
                var dotColor  = dataLayers.activeLayerPanels[i].dot.color;

                int lineInspectedGridsLength = lineInspectedGrids[lineGrids[i]].Count;
                for (int j = 0; j < lineInspectedGridsLength; ++j)
                {
                    // Add all cells to list
                    if (!idToValueList.ContainsKey(layerName))
                    {
                        List <float> data        = new List <float>();
                        int          noDataCount = 0;
                        float        value       = lineInspectedGrids[lineGrids[i]][j];
                        if (value > 0.0f)
                        {
                            data.Add(value);
                        }
                        else
                        {
                            ++noDataCount;
                        }
                        idToValueList.Add(layerName, data);
                        idToNoDataList.Add(layerName, noDataCount);
                    }
                    else
                    {
                        var   list  = idToValueList[layerName];
                        float value = lineInspectedGrids[lineGrids[i]][j];
                        if (value > 0.0f)
                        {
                            list.Add(value);
                        }
                        else
                        {
                            ++idToNoDataList[layerName];
                        }
                    }
                }

                if (!idToUnitsList.ContainsKey(layerName))
                {
                    idToUnitsList.Add(layerName, lineGrids[i].units);
                }

                if (!idToDotColorList.ContainsKey(layerName))
                {
                    idToDotColorList.Add(layerName, dotColor);
                }
            }
            ComputeAndUpdateNoDataLength(idToValueList, idToNoDataList);
            lineDO.SetData(idToValueList, idToUnitsList, idToDotColorList, idToNoDataList, PlotLineData);
        }
    }
예제 #10
0
    private void UpdateLineInspetorChart(LineInfo lineInfo)
    {
        if (lineInfo != null)
        {
            GridData lineGrid = lineInfo.mapLayer.Grid;

            // Initizlize values
            int length = lineInfo.mapLayer.numOfSamples;
            if (dataToSend == null || dataToSend.Length != length)
            {
                dataToSend = new float[length];
            }

            // Set all values to 0
            for (int i = 0; i < length; ++i)
            {
                dataToSend[i] = 0;
            }

            // Calculate values
            double thisDegreesPerCellX = (lineGrid.east - lineGrid.west) / lineGrid.countX;
            double thisDegreesPerCellY = (lineGrid.south - lineGrid.north) / lineGrid.countY;
            double thisCellsPerDegreeX = 1.0 / thisDegreesPerCellX;
            double thisCellsPerDegreeY = 1.0 / thisDegreesPerCellY;

            var patchCellsPerDegreeX = grid.countX / (grid.east - grid.west);
            var patchCellsPerDegreeY = grid.countY / (grid.south - grid.north);

            double scaleX = patchCellsPerDegreeX * thisDegreesPerCellX;
            double scaleY = patchCellsPerDegreeY * thisDegreesPerCellY;

            double offsetX = (lineGrid.west - grid.west) * patchCellsPerDegreeX + 0.5 * scaleX;
            double offsetY = (lineGrid.north - grid.north) * patchCellsPerDegreeY + 0.5 * scaleY;

            Coordinate coorStart = lineInfo.coords[0];
            Coordinate coorEnd   = lineInfo.coords[1];

            // The smaller range of longitude and latitude
            double startLon = (coorStart.Longitude > grid.west) ? coorStart.Longitude : grid.west;
            double startLat = (coorStart.Latitude < grid.north) ? coorStart.Latitude : grid.north;
            double endLon   = (coorEnd.Longitude < grid.east) ? coorEnd.Longitude : grid.east;
            double endLat   = (coorEnd.Latitude > grid.south) ? coorEnd.Latitude : grid.south;

            // Precompute values to be used in loop
            double diffX          = endLon - startLon;
            double diffY          = endLat - startLat;
            double diffXperSample = diffX / length;
            double diffYperSample = diffY / length;

            double srcX = (startLon - lineGrid.west) * thisCellsPerDegreeX + 0.5;
            double srcY = (startLat - lineGrid.north) * thisCellsPerDegreeY + 0.5;

            double pX = offsetX + srcX * scaleX;
            double pY = offsetY + srcY * scaleY;

            double srcXStep = diffXperSample * thisCellsPerDegreeX;
            double srcYStep = diffYperSample * thisCellsPerDegreeY;

            double srcXStepScaleX = srcXStep * scaleX;
            double srcYStepScaleY = srcYStep * scaleY;

            if (grid.IsCategorized)
            {
                if (grid.values != null)
                {
                    for (int j = 0; j < lineInfo.mapLayer.numOfSamples; ++j)
                    {
                        if (grid.IsInside(startLon, startLat))
                        {
                            int patchIndex = (int)pY * grid.countX + (int)pX;
                            if (patchIndex >= 0 && patchIndex < grid.values.Length)
                            {
                                int   value    = (int)grid.values[patchIndex];
                                byte  mask     = grid.valuesMask == null ? (byte)1 : grid.valuesMask[patchIndex];
                                float valToAdd = mask == 1 ? grid.categoryFilter.IsSetAsInt(value) : 0;
                                dataToSend[j] = valToAdd;
                            }
                        }

                        startLon += diffXperSample;
                        startLat += diffYperSample;

                        srcX += srcXStep;
                        srcY += srcYStep;

                        pX += srcXStepScaleX;
                        pY += srcYStepScaleY;
                    }
                }
            }
            else
            {
                float gridMin  = grid.minValue;
                float invRange = 1f / (grid.maxValue - grid.minValue);
                if (lineInfo.mapLayer.useFilters)
                {
                    if (grid.values != null)
                    {
                        for (int j = 0; j < length; ++j)
                        {
                            if (grid.IsInside(startLon, startLat))
                            {
                                int patchIndex = (int)pY * grid.countX + (int)pX;
                                if (patchIndex >= 0 && patchIndex < grid.values.Length)
                                {
                                    int  value = (int)grid.values[patchIndex];
                                    byte mask  = grid.valuesMask == null ? (byte)1 : grid.valuesMask[patchIndex];
                                    if (mask == 1 && value >= grid.minFilter && value <= grid.maxFilter)
                                    {
                                        float valToAdd = (value - gridMin) * invRange;
                                        dataToSend[j] = valToAdd;
                                    }
                                }
                            }

                            startLon += diffXperSample;
                            startLat += diffYperSample;

                            srcX += srcXStep;
                            srcY += srcYStep;

                            pX += srcXStepScaleX;
                            pY += srcYStepScaleY;
                        }
                    }
                }
                else
                {
                    if (grid.values != null)
                    {
                        for (int j = 0; j < lineInfo.mapLayer.numOfSamples; ++j)
                        {
                            if (grid.IsInside(startLon, startLat))
                            {
                                int patchIndex = (int)pY * grid.countX + (int)pX;
                                if (patchIndex >= 0 && patchIndex < grid.values.Length)
                                {
                                    byte mask = grid.valuesMask == null ? (byte)1 : grid.valuesMask[patchIndex];
                                    if (mask == 1)
                                    {
                                        float valToAdd = (grid.values[patchIndex] - gridMin);
                                        dataToSend[j] = valToAdd;
                                    }
                                }
                            }

                            startLon += diffXperSample;
                            startLat += diffYperSample;

                            srcX += srcXStep;
                            srcY += srcYStep;

                            pX += srcXStepScaleX;
                            pY += srcYStepScaleY;
                        }
                    }
                }
            }
        }
        else
        {
            // Set all values to 0
            for (int i = 0; i < dataToSend.Length; ++i)
            {
                dataToSend[i] = 0;
            }
        }

        if (dataToSend.Length > 0)
        {
            SetData(dataToSend);
        }
    }
예제 #11
0
 public void SetLineInfo(LineInfo lineInfo)
 {
     UpdateLineInspetorChart(lineInfo);
 }
예제 #12
0
 public void UpdateLineEndPtAndMidPtFromWorldPos(LineInfo lineInfo, int controlPtIndex, Vector3 worldPos)
 {
     lineInspector.UpdateLineEndPtFromWorldPos(lineInfo, controlPtIndex, worldPos);
     lineInspector.UpdateLineMidPt(lineInfo, midPtOffset);
 }