private void DrawRhumbLine(IPoint fromPoint, IPoint toPoint) { if (fromPoint == null || toPoint == null) return; try { IColor rgbColor = new RgbColorClass(); rgbColor.RGB = 255; IPolyline polyline = CreateGeoPolyline(fromPoint, toPoint); ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Color = rgbColor; simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = 2; ILineElement lineElement = new LineElementClass(); lineElement.Symbol = simpleLineSymbol; IElement element = (IElement)lineElement; // Explicit Cast element.Geometry = polyline; m_globeGraphicsLayer.AddElement(element, 1); } catch (Exception ex) { logger.Error("Draw Rhumb Line encountered and error. {0}", ex.Message); } }
private IPolyline CreateGeoPolyline(IPoint startPoint, IPoint endPoint) { try { // Set the measurement tool and the GeoPolyline. The measurement tool // will be used to calculate the distance and azimuth of the GeoPolyline // based on the start and end point coordinates of the line GeoPolyline geoPolyline = new ESRI.ArcGIS.DefenseSolutions.GeoPolyline(); IMeasurementTool measurementTool = new ESRI.ArcGIS.DefenseSolutions.MeasurementTool(); // Get the GeoPolyline type from the Type dropdown list and set it as // the type for both the measurement tool and the GeoPolyline. The options // are Geodesic, Great Circle, and Rhumb Line. measurementTool.SpecialGeolineType = ESRI.ArcGIS.DefenseSolutions.cjmtkSGType.cjmtkSGTRhumbLine; geoPolyline.SpecialGeolineType = ESRI.ArcGIS.DefenseSolutions.cjmtkSGType.cjmtkSGTRhumbLine; // Define the spatial reference of the rhumb line. // Define the spatial reference to be used for geopolylines, // geoellipses, and geopolygons. ESRI.ArcGIS.Geometry.ISpatialReferenceFactory2 pSpatRefFact = (ISpatialReferenceFactory2) new ESRI.ArcGIS.Geometry.SpatialReferenceEnvironment(); ISpatialReference2 spatialReference2 = (ISpatialReference2) pSpatRefFact.CreateSpatialReference((int) ESRI.ArcGIS.Geometry.esriSRGeoCSType.esriSRGeoCS_WGS1984); // Initialize the MeasurementTool and define the properties of the line. // These properties include the line type, which is a rhumb line in this case, and the // spatial reference of the line. measurementTool.SpecialGeolineType = cjmtkSGType.cjmtkSGTRhumbLine; measurementTool.SpecialSpatialReference = spatialReference2; // Determine the distance and azimuth of the rhumb line based on the start and end point coordinates. measurementTool.ConstructByPoints(startPoint, endPoint); geoPolyline.MaxPercent = 0.01; geoPolyline.UsePercent = true; IPolyline polyline = measurementTool.get_Polyline(1000); return measurementTool.get_Polyline(1000); } catch (Exception error) { logger.Error("There was a problem creating the rhumb line. {0}", error.Message); } return null; }
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.