/// <summary> /// Support method for Geocode locate. May be removed at a later date. /// </summary> /// <param name="x"></param> /// <param name="y"></param> internal static void geoLocate(double x, double y) { gtGeoEditService.TargetMapWindow = gtApp.ActiveMapWindow; gtGeoEditService.RemoveAllGeometries(); gtApp.ActiveMapWindow.DisplayScale = 250; IGTPoint locationPoint = gCoordinateConvert(x, y, 0); IGTWorldRange gtWorldRange = gtApp.ActiveMapWindow.GetRange(); double xOffset = (gtWorldRange.TopRight.X - gtWorldRange.BottomLeft.X) / 2; double yOffset = (gtWorldRange.TopRight.Y - gtWorldRange.BottomLeft.Y) / 2; IGTPoint tempPt = GTClassFactory.Create <IGTPoint>(); tempPt.X = 0; tempPt.Y = 0; tempPt.X = locationPoint.X + xOffset; tempPt.Y = locationPoint.Y + yOffset; gtWorldRange.TopRight = tempPt; tempPt.X = 0; tempPt.Y = 0; tempPt.X = locationPoint.X - xOffset; tempPt.Y = locationPoint.Y - yOffset; gtWorldRange.BottomLeft = tempPt; gtGeoEditService.TargetMapWindow = gtApp.ActiveMapWindow; IGTPointGeometry newSymbol = GTClassFactory.Create <IGTPointGeometry>(); newSymbol.Origin = locationPoint; gtGeoEditService.AddGeometry(newSymbol, Convert.ToInt16(GTStyleIDConstants.gtstyleHandleSquareX)); gtApp.ActiveMapWindow.DisplayScale = 250; gtApp.ActiveMapWindow.ZoomArea(gtWorldRange); gtApp.RefreshWindows(); }
private void ExtendFollowingAutoFitRules(IGTMapWindow window, IGTWorldRange range) { try { double extentX = range.TopRight.X - range.BottomLeft.X; double extentY = range.TopRight.Y - range.BottomLeft.Y; double extendBY; if (extentY < 0 || extentX < 0) { return; } if (extentY < 1 && extentX < 1) { extendBY = AverageSymbolSize * 4; } else { extendBY = Math.Max(extentX, extentY) * (window.SelectBehaviorZoomFactor - 1); } IGTPoint tr = GTClassFactory.Create <IGTPoint>(range.TopRight.X + extendBY, range.TopRight.Y + extendBY, 0); IGTPoint bl = GTClassFactory.Create <IGTPoint>(range.BottomLeft.X - extendBY, range.BottomLeft.Y - extendBY, 0); range.BottomLeft = bl; range.TopRight = tr; } catch (Exception ex) { throw ex; } }
private void SetupLocationCriteria() { try { if (this.oMap == null) { throw new Exception("Map object is null."); } IGTWorldRange oMapExtents = this.oMap.GetRange(); IGTPolygonGeometry m_oPoly = GTClassFactory.Create <IGTPolygonGeometry>(); IGTPoint m_ulPoint = GTClassFactory.Create <IGTPoint>(); m_ulPoint.X = oMapExtents.BottomLeft.X; m_ulPoint.Y = oMapExtents.TopRight.Y; IGTPoint m_urPoint = GTClassFactory.Create <IGTPoint>(); m_urPoint.X = oMapExtents.TopRight.X; m_urPoint.Y = oMapExtents.TopRight.Y; IGTPoint m_lrPoint = GTClassFactory.Create <IGTPoint>(); m_lrPoint.X = oMapExtents.TopRight.X; m_lrPoint.Y = oMapExtents.BottomLeft.Y; IGTPoint m_llPoint = GTClassFactory.Create <IGTPoint>(); m_llPoint.X = oMapExtents.BottomLeft.X; m_llPoint.Y = oMapExtents.BottomLeft.Y; m_oPoly.Points.Add(m_ulPoint); m_oPoly.Points.Add(m_urPoint); m_oPoly.Points.Add(m_lrPoint); m_oPoly.Points.Add(m_llPoint); this.oLocationCriteria = (IGTGeometry)m_oPoly; if (this.oLocationCriteria == null) { throw new Exception("Map extents are null."); } } catch (Exception ex) { CommandUtilities.LogException(oDiag, "GTStreetLight.SetupLocationCriteria", ex); throw ex; } }
/// <summary> /// Method to zoom the plot window to a given extend value. /// </summary> /// <param name="p_frame">Plot Frame</param> /// <param name="p_worldRange">World Range of the placed feature</param> /// <param name="p_buffer">Extend value to which the map to be zoomed</param> private void ZoomToExtents(IGTPlotFrame p_frame, IGTWorldRange p_worldRange, double p_buffer) { IGTWorldRange rangeBuffered = GTClassFactory.Create <IGTWorldRange>(); IGTPoint ptTemp; ptTemp = GTClassFactory.Create <IGTPoint>(); ptTemp.X = p_worldRange.TopRight.X + p_buffer; ptTemp.Y = p_worldRange.TopRight.Y + p_buffer; rangeBuffered.TopRight = ptTemp; ptTemp = (IGTPoint)GTClassFactory.Create <IGTPoint>(); ptTemp.X = p_worldRange.BottomLeft.X - p_buffer; ptTemp.Y = p_worldRange.BottomLeft.Y - p_buffer; rangeBuffered.BottomLeft = ptTemp; p_frame.PlotMap.ZoomArea(rangeBuffered); }
/// <summary> /// //Add Detected Polygons to Detail Map Window Display Control and highlight feature with override symbology /// </summary> /// <param name="lbmAnalysis"></param> /// <param name="gtSymbologyOverrides"></param> private void AddFeaturesToDetailMapwindow(LBMAnalysisResults lbmAnalysis, IGTSymbology gtSymbologyOverrides) { IGTDisplayService displayService; Recordset rs = null; string query = null; bool validGeometry = false; //check selected polygon has valid geometry try { if (lbmAnalysis.DetectPolygons != null && lbmAnalysis.DetectPolygons.Count > 0) { var gtDDCKeyObjs = application.DataContext.GetDDCKeyObjects((short)lbmAnalysis.G3eFno, lbmAnalysis.G3eFid, GTComponentGeometryConstants.gtddcgPrimaryDetail); if (gtDDCKeyObjs != null && gtDDCKeyObjs.Count > 0) { var gtKeyObj = gtDDCKeyObjs[0]; if (gtKeyObj.Geometry != null) { validGeometry = true; } } foreach (KeyValuePair <int, int> feat in lbmAnalysis.DetectPolygons) { gtDDCKeyObjs = application.DataContext.GetDDCKeyObjects((short)feat.Value, feat.Key, GTComponentGeometryConstants.gtddcgPrimaryDetail); if (gtDDCKeyObjs != null && gtDDCKeyObjs.Count > 0) { var gtKeyObj = gtDDCKeyObjs[0]; if (gtKeyObj.Geometry != null) { if (query != null) { query += " union all "; } query += "select " + gtKeyObj.FNO + " G3E_FNO, " + gtKeyObj.FID + " G3E_FID, " + gtKeyObj.Recordset.Fields["G3E_CNO"].Value.ToString() + " G3E_CNO, " + gtKeyObj.Recordset.Fields["G3E_CID"].Value.ToString() + " G3E_CID from dual"; } } } } if (!string.IsNullOrEmpty(query)) { rs = application.DataContext.OpenRecordset(query, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, 1, new object[] { }); if (rs != null && rs.RecordCount > 0 && gtSymbologyOverrides != null) { foreach (IGTMapWindow window in application.GetMapWindows(GTMapWindowTypeConstants.gtapmtDetail)) { // detail windows can have different nominal scale and fitting is done against the active window.Without activating the targetted window we might end up with invalid range displayService = window.DisplayService; if (validGeometry) { displayService.AppendQuery(displayControlRootNode, "Feature_" + lbmAnalysis.G3eFid, rs, gtSymbologyOverrides, true, true, true, true, GTDisplayScaleModeConstants.gtdsdsOff); } if (lbmAnalysis.DetectPolygons != null && lbmAnalysis.DetectPolygons.Count > 0) { foreach (KeyValuePair <int, int> polygon in lbmAnalysis.DetectPolygons) { if (query.Contains(polygon.Key.ToString())) { displayService.AppendQuery(displayControlRootNode, "Feature_" + polygon.Key, rs, gtSymbologyOverrides, true, true, true, true, GTDisplayScaleModeConstants.gtdsdsOff); } } } if (validGeometry) { IGTWorldRange range = displayService.GetRange(displayControlRootNode, "Feature_" + lbmAnalysis.G3eFid); ExtendFollowingAutoFitRules(window, range); window.ZoomArea(range); } } } } } catch (Exception) { throw; } finally { displayService = null; if (rs != null) { rs.ActiveConnection = null; rs.Close(); rs = null; } } }