void AfterAnalysis(ProjectBoreholeResult result)
        {
            if (result == null)
                return;

            IView profileView = OutputCB.SelectedItem as IView;
            profileView.eMap.profileLine = _projLine;

            // test code:
            //profileView.addLayer(testGraphicsLayer());

            // Assign name to each graphic objects,
            // so that the graphics layer can sync them with corresponding object.
            foreach(int bhID in result.bhGraphics.Keys)
            {
                Borehole bh = _allBhs[bhID] as Borehole;
                IGraphicCollection gc = result.bhGraphics[bhID];
                foreach (IGraphic g in gc)
                    g.Attributes["Name"] = bh.name;
            }
            foreach(int stID in result.stGraphics.Keys)
            {
                Stratum st = _allSts[stID] as Stratum;
                IGraphicCollection gc = result.stGraphics[stID];
                foreach (IGraphic g in gc)
                    g.Attributes["Name"] = st.name;
            }

            // add graphic to the view
            // boreholes displayed on top of strata
            HashSet<IGraphicsLayer> bhGraphicLayers = new HashSet<IGraphicsLayer>();
            HashSet<IGraphicsLayer> stGraphicLayers = new HashSet<IGraphicsLayer>();
            foreach (int id in result.stGraphics.Keys)
            {
                IGraphicCollection gc = result.stGraphics[id];
                DGObject obj = _allSts[id];
                string layerID = obj.parent.definition.GISLayerName;
                IGraphicsLayer gLayerSt = getStratumLayer(profileView, layerID);
                gLayerSt.addGraphics(gc);
                stGraphicLayers.Add(gLayerSt);
            }
            foreach (int id in result.bhGraphics.Keys)
            {
                IGraphicCollection gc = result.bhGraphics[id];
                DGObject obj = _allBhs[id];
                string layerID = obj.parent.definition.GISLayerName;
                IGraphicsLayer gLayerBh = getBoreholeLayer(profileView, layerID);
                gLayerBh.addGraphics(gc);
                bhGraphicLayers.Add(gLayerBh);
            }

            // sync objects with graphics
            List<DGObject> bhs = _allBhs.merge();
            List<DGObject> sts = _allSts.merge();
            foreach (IGraphicsLayer gLayer in bhGraphicLayers)
                gLayer.syncObjects(bhs);
            foreach (IGraphicsLayer gLayer in stGraphicLayers)
                gLayer.syncObjects(sts);

            _mainFrame.activeView = profileView;
            profileView.zoomTo(result.Extent);
        }
Exemplo n.º 2
0
        public static ProjectBoreholeResult ProjectBoreholes(List<Tuple<Borehole, IMapPoint>> input,
            IPolyline projLine, GeoProjSettings geoProjSettings)
        {
            if (input == null || projLine == null)
                return null;

            // remove the boreholes that do not have geology infos,
            // so called 'empty' boreholes
            //
            input.RemoveAll(x =>
                x.Item1.Geologies == null || x.Item1.Geologies.Count == 0
                || x.Item1.Top == x.Item1.Base);

            // sort the boreholes according to their projected position on the projection line
            //
            List<ProjectedBorehole> sortedList = new List<ProjectedBorehole>();
            foreach (var tuple in input)
            {
                Borehole bh = tuple.Item1;
                IMapPoint p = tuple.Item2;

                double distance = 0;
                IMapPoint prjPnt = null;
                bool canProject = GeomUtil.ProjectPointToPolyline(p,
                    projLine.GetPoints(), ref distance, ref prjPnt);
                if (geoProjSettings.clipInProjectionLine == true && canProject == false)
                    continue;

                distance /= geoProjSettings.scale;
                distance += geoProjSettings.xOffset;
                ProjectedBorehole prjBorehole = new ProjectedBorehole();
                prjBorehole.Borehole = bh;
                prjBorehole.Distance = distance;
                prjBorehole.Pos = p;
                sortedList.Add(prjBorehole);
            }
            if (sortedList.Count == 0)
                return null;

            sortedList.Sort((x, y) => x.Distance.CompareTo(y.Distance));

            // extend borholes to same depth
            //
            if (geoProjSettings.extendBorehole)
            {
                ExtendBoreholes(input);
            }

            // perform the projection
            //
            ProjectBoreholeResult result = new ProjectBoreholeResult();

            List<STGraphic> stResults = new List<STGraphic>();
            ProjectedBorehole previousBh = null;
            foreach (ProjectedBorehole projectedBorehole in sortedList)
            {
                Borehole bh = projectedBorehole.Borehole;

                // draw strata
                if (geoProjSettings.drawStratum)
                {
                    if (previousBh == null)
                    {
                        previousBh = projectedBorehole;
                    }
                    else
                    {
                        List<STGraphic> stGraphics = LinkBorehole(
                            previousBh.Borehole, projectedBorehole.Borehole,
                            previousBh.Distance, projectedBorehole.Distance,
                            geoProjSettings.zScale);
                        previousBh = projectedBorehole;
                        stResults.AddRange(stGraphics);
                    }
                }

                // draw borehole
                if (geoProjSettings.drawBorehole)
                {
                    IGraphicCollection gc = ProjectBorehole(bh,
                        projectedBorehole.Distance, geoProjSettings.zScale);
                    result.bhGraphics[bh.id] = gc;
                }
            }

            // transfrom strata results
            foreach (STGraphic stGraphic in stResults)
            {
                int id = stGraphic.StratumID;
                if (result.stGraphics.ContainsKey(id))
                {
                    IGraphicCollection gc = result.stGraphics[id];
                    gc.Add(stGraphic.Graphic);
                }
                else
                {
                    IGraphicCollection gc = NewGraphicCollection();
                    gc.Add(stGraphic.Graphic);
                    result.stGraphics[id] = gc;
                }
            }

            // calculate extent
            IEnvelope ext = null;
            foreach (IGraphicCollection gc in result.bhGraphics.Values)
            {
                IEnvelope itemExt = GraphicsUtil.GetGraphicsEnvelope(gc);
                if (ext == null)
                    ext = itemExt;
                else
                    ext = ext.Union(itemExt);
            }
            result.Extent = ext;

            return result;
        }