本文整理汇总了C#中PointClass.Project方法的典型用法代码示例。如果您正苦于以下问题:C# PointClass.Project方法的具体用法?C# PointClass.Project怎么用?C# PointClass.Project使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointClass
的用法示例。
在下文中一共展示了PointClass.Project方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getGeoPoint
/// <summary>
/// 坐标系转换-----投影坐标系转WGS84
/// </summary>
/// <param name="x">x坐标</param>
/// <param name="y">y坐标</param>
/// <returns>转换后的IPoint</returns>
public static IPoint getGeoPoint(double x, double y)
{
IPoint pProjPoint = new PointClass();
pProjPoint.PutCoords(x, y);
ISpatialReferenceFactory pSRF = new SpatialReferenceEnvironmentClass();
pProjPoint.SpatialReference = pSRF.CreateProjectedCoordinateSystem((int)(esriSRProjCSType.esriSRProjCS_WGS1984UTM_31N));
pProjPoint.Project(pSRF.CreateGeographicCoordinateSystem((int)(esriSRGeoCSType.esriSRGeoCS_WGS1984)));
return pProjPoint; //此时为经纬度点
}
示例2: DrawPoly
/// <summary>
/// Draw the polygon contained within the properties.
/// </summary>
/// <param name="polyToBeDrawn">
/// The polygon to be drawn.
/// </param>
/// <param name="graphicContainer">
/// The graphic container.
/// </param>
private void DrawPoly(Properties polyToBeDrawn, IGraphicsContainer graphicContainer)
{
var poly = new PolygonClass();
poly.Project(ArcMap.Document.ActiveView.Extent.SpatialReference);
foreach (var pnt in polyToBeDrawn.Points)
{
var tempPoint = new PointClass();
tempPoint.PutCoords(pnt.X, pnt.Y);
tempPoint.SpatialReference = Jarvis.ProjectedCoordinateSystem;
tempPoint.Project(ArcMap.Document.ActiveView.Extent.SpatialReference);
poly.AddPoint(tempPoint);
}
IElement elm = new PolygonElementClass();
elm.Geometry = poly;
graphicContainer.AddElement(elm, 0);
}
示例3: CreateStop
// Creates Stop by Stop Point, Index and Description and adds it to Stops collection
private void CreateStop(SMRouter objRouter, string strAddress, string strCity, string strState, string strCode, SMStopsCollection objStopsCol, int nID)
{
// geocode point
IPoint objPoint = new PointClass();
objPoint = GeocodeAddress(strAddress, strCity, strState, strCode);
if (objPoint.IsEmpty)
throw new Exception("Cannot geocode address.");
// project point
objPoint.Project(m_objSpatialReference);
// create and initialize router point
SMRouterPoint objRouterPoint = null;
objRouterPoint = new SMRouterPointClass();
objRouterPoint.X = objPoint.X;
objRouterPoint.Y = objPoint.Y;
// create flag
ISMFlagCreator2 objFlagCreator2 = null;
objFlagCreator2 = objRouter.FlagCreator as ISMFlagCreator2;
if (objFlagCreator2 != null)
objFlagCreator2.SearchTolerance = 5;
SMFlag objFlag = null;
objFlag = objRouter.FlagCreator.CreateFlag(objRouterPoint);
// create and initialize stop
SMStop objStop = null;
objStop = new SMStop();
objStop.StopID = nID;
objStop.Duration = 0;
objStop.Flag = objFlag;
objStop.Description = GetAddressString(strAddress, strCity, strState, strCode);
objStopsCol.Add(objStop);
}
示例4: get_ErrorPoint
protected IPoint get_ErrorPoint(IGeometry shape)
{
IPoint theErrorPoint;
if (shape is IArea)
{
try
{
theErrorPoint = ((IArea)shape).LabelPoint;
}
catch (Exception)
{
theErrorPoint = ((IArea)shape).Centroid;
}
}
else if (shape is ICurve)
{
ICurve theCurve = (ICurve)shape;
theErrorPoint = new PointClass();
theErrorPoint.Project(shape.SpatialReference);
theCurve.QueryPoint(esriSegmentExtension.esriNoExtension, 0.5, true, theErrorPoint);
}
else if (shape is IPointCollection)
theErrorPoint = ((IPointCollection)shape).get_Point(0);
else if (shape is IPoint)
theErrorPoint = (IPoint)shape;
else
{
theErrorPoint = new PointClass();
theErrorPoint.PutCoords(0, 0);
}
theErrorPoint.Project(SpatialReferenceHelper.GeographicReference);
return theErrorPoint;
}
示例5: ConstructLine
private ILine ConstructLine(double x1, double y1, double x2, double y2)
{
IPoint p1 = new PointClass();
p1.PutCoords(x1, y1);
p1.Project(SpatialReferenceHelper.BCAlbersSpatialReference);
IPoint p2 = new PointClass();
p2.PutCoords(x2, y2);
p2.Project(SpatialReferenceHelper.BCAlbersSpatialReference);
ILine theReturn = new LineClass();
theReturn.PutCoords(p1, p2);
theReturn.Project(SpatialReferenceHelper.BCAlbersSpatialReference);
return theReturn;
}
示例6: XY2JWD
public static IPoint XY2JWD(double x, double y, int gcsType, int pcsType)
{
try
{
IPoint point = new PointClass();
point.PutCoords(x, y);
ISpatialReferenceFactory factory = new SpatialReferenceEnvironmentClass();
point.SpatialReference = factory.CreateProjectedCoordinateSystem(pcsType);
point.Project(factory.CreateGeographicCoordinateSystem(gcsType));
return point;
}
catch
{
return null;
}
}
示例7: CreateWellsiteFeature
// build the actual point feature and store it
private void CreateWellsiteFeature()
{
IFeatureCursor pFeatureCursor = null;
try
{
IFeatureClass pFeatureClass;
IFields pFields;
pFeatureClass = m_pFeatureLayerWellsOSDB.FeatureClass;
// first deal with point creation
IPoint pPoint = new PointClass();
ISpatialReferenceFactory2 pSRF = new SpatialReferenceEnvironmentClass();
double xcoord, ycoord;
ISpatialReference pSR = null;
if (txtUTMnorthing.ReadOnly == false) //we'll use the UTM coordinates to validate the BCGS
{
// create the correct UTM projected coordinate system (based on zone) - NAD 83 datum
pSR = pSRF.CreateSpatialReference(26900 + Convert.ToInt32(txtUTMzone.Text));
xcoord = Convert.ToDouble(txtUTMeasting.Text);
ycoord = Convert.ToDouble(txtUTMnorthing.Text);
}
else // we'll use the lat/lon coordinates to validate the BCGS
{
pSR = pSRF.CreateSpatialReference(4269); //esriSRGeoCS_NAD1983
xcoord = Convert.ToDouble(txtLongitude.Text);
ycoord = Convert.ToDouble(txtLatitude.Text);
// make sure our xcoord is negative even if the user entered positive (for western hem)
if (xcoord > 0)
xcoord *= -1;
// make sure our ycoord is positive for northern hemisphere
if (ycoord < 0)
ycoord *= -1;
}
// assign coordinate info and SR
pPoint.SpatialReference = pSR;
pPoint.X = xcoord;
pPoint.Y = ycoord;
Debug.WriteLine("before project -> x,y = " + pPoint.X.ToString() + "," + pPoint.Y.ToString());
// get SR of destination featureclass
IGeoDataset pGeodataset = (IGeoDataset)pFeatureClass;
// project point
pPoint.Project(pGeodataset.SpatialReference);
if (pPoint.IsEmpty == true)
{
MessageBox.Show("The point coordinate failed to project.\n" +
"Check that your coordinates are correct.", "SUITT Error");
return;
}
else
{
Debug.WriteLine("after project -> x,y = " + pPoint.X.ToString() + "," + pPoint.Y.ToString());
}
string correctMapSheet;
if (BCGSCheck(txtBCGSMap.Text, pPoint, out correctMapSheet) == false)
{
if (correctMapSheet.Length == 0)
{
// no result.. either a major error or the point does not fall inside
// any mapsheet polygon
MessageBox.Show("The point coordinate does not fall inside any BCGS map sheet", "SUITT");
return;
}
else
{
// point was not in the specified mapsheet polygon
MessageBox.Show("The point coordinate does not exist\n" +
"within the specified BCGS map sheet.\n" +
"The point cannot be added.\n\n" +
"The correct sheet should be: " + correctMapSheet, "SUITT");
return;
}
}
// now do the insertion
pFeatureCursor = pFeatureClass.Insert(false);
IFeatureBuffer pFeatureBuffer = pFeatureClass.CreateFeatureBuffer();
pFields = pFeatureCursor.Fields;
pFeatureBuffer.set_Value(pFields.FindField("WELLSITE_SID"), Convert.ToDouble(txtWellsiteSID.Text));
// write point
pFeatureBuffer.Shape = pPoint;
//.........这里部分代码省略.........
示例8: CreatePoint
private void CreatePoint(double x, double y)
{
IPoint pPoint = new PointClass();
IMap pMap = axMapControl.Map;
IActiveView pActiveView = pMap as IActiveView;
IGraphicsContainer pGraphicsContainer;
IElement pElement = new MarkerElementClass();
pGraphicsContainer = (IGraphicsContainer)pActiveView;
IFormattedTextSymbol pTextSymbol = new TextSymbolClass();
IBalloonCallout pBalloonCallout = CreateBalloonCallout(x, y);
IRgbColor pColor = new RgbColorClass();
pColor.Red = 150;
pColor.Green = 0;
pColor.Blue = 0;
pTextSymbol.Color = pColor;
ITextBackground pTextBackground;
pTextBackground = (ITextBackground)pBalloonCallout;
//pTextSymbol.Background = pTextBackground;
//((ITextElement)pElement).Symbol = pTextSymbol;
//((ITextElement)pElement).Text = "测试";
pPoint.X = x + 42;
pPoint.Y = y + 42;
pPoint.PutCoords(x, y);
ISpatialReferenceFactory pSRF = new SpatialReferenceEnvironmentClass();
pPoint.SpatialReference = pSRF.CreateProjectedCoordinateSystem(2414);
pPoint.Project(pSRF.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_Beijing1954));
pElement.Geometry = pPoint;
pGraphicsContainer.AddElement(pElement, 1);
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
示例9: button5_Click
private void button5_Click(object sender, EventArgs e)
{
IPoint pPoint = new PointClass();
pPoint.X = 40;
pPoint.Y = -101;
ISpatialReferenceFactory pSRF = new SpatialReferenceEnvironmentClass();
pPoint.SpatialReference = pSRF.CreateProjectedCoordinateSystem(4152);
pPoint.Project(pSRF.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_NAD1983HARN));
GeoToGra(pPoint);
esriUnits eu = new esriUnits();
axMapControl.MapUnits = esriUnits.esriMeters;
}
示例10: Execute
public override int Execute(string logfileName)
{
this.InitLogging(logfileName);
this.LogMessage(this.Name + " QA test execution started.");
int currentOid = -1;
try
{
this.LogMessage(this.Name + " Parameters:");
for (int i = 0; i < this.ParameterCount; i++)
this.LogMessage(this.get_ParameterText(i) + ": " + this.get_ParameterValue(i));
this.ClearErrors();
// Check the search radius
int idx = this.FindParameter("search-radius");
DoubleParameterInfo theInfo = (DoubleParameterInfo)this._params[idx];
double theSearchRadius = (double)theInfo.ParamValue;
if (theSearchRadius <= 0)
{
this.LogMessage("Zero or negative value passed as search radius for " + this.Name + ". Stopping.");
return -1;
}
// Check the cluster tolerance
idx = this.FindParameter("cluster-tolerance");
theInfo = (DoubleParameterInfo)this._params[idx];
double theCluster = (double)theInfo.ParamValue;
if (theCluster >= theSearchRadius)
{
this.LogMessage("Cluster tolerance equal to or larger than search radius for " + this.Name + ". Stopping.");
return -1;
}
// Convert them to metres
idx = this.FindParameter("search-units");
UnitsParameterInfo theUnitsParam = (UnitsParameterInfo)this._params[idx];
esriUnits theUnits = theUnitsParam.ParamValueInUnits;
IUnitConverter theConverter = new UnitConverterClass();
theSearchRadius = theConverter.ConvertUnits(theSearchRadius, theUnits, esriUnits.esriMeters);
theCluster = theConverter.ConvertUnits(theCluster, theUnits, esriUnits.esriMeters);
// Get the canDefer/canExcept params
idx = this.FindParameter(ParameterInfo.PARAM_CANDEFER);
bool canDefer = (bool)((ParameterInfo)this._params[idx]).ParamValue;
idx = this.FindParameter(ParameterInfo.PARAM_CANEXCEPT);
bool canExcept = (bool)((ParameterInfo)this._params[idx]).ParamValue;
// Loop through the layers
for (int i = 0; i < this.LayerCount - 1; i++)
{
IFeatureLayer theLayer1 = this.get_Layer(i);
if (this.SupportsGeometryType(theLayer1.FeatureClass.ShapeType) == false)
continue;
// Index the points in theLayer1
IDataset theDataset1 = (IDataset)theLayer1.FeatureClass;
IGeoDataset theGeoDS = (IGeoDataset)theDataset1;
IEnvelope theAOI = theGeoDS.Extent;
if (theAOI == null || theAOI.IsEmpty)
continue;
theAOI.Project(SpatialReferenceHelper.BCAlbersSpatialReference);
double theCellsize = theAOI.Width / 100;
this.LogMessage("Indexing features in " + theDataset1.Name + ". Cellsize (m): " + theCellsize);
PointCollectionIndex theIndex = new PointCollectionIndex(theCellsize);
IFeatureCursor theFCursor1 = null;
if (this.ConstrainToSelection)
{
ICursor theCursor = null;
IFeatureSelection theFSel = (IFeatureSelection)theLayer1;
theFSel.SelectionSet.Search(null, true, out theCursor);
theFCursor1 = (IFeatureCursor)theCursor;
}
else
{
theFCursor1 = theLayer1.Search(null, true);
}
IFeature theFeature1 = theFCursor1.NextFeature();
while (theFeature1 != null)
{
if (theFeature1.Shape != null && theFeature1.Shape.IsEmpty == false)
{
IPointCollection thePtColl = (IPointCollection)theFeature1.Shape;
for (int k = 0; k < thePtColl.PointCount; k++)
{
theIndex.AddPoint(new IndexPoint(theFeature1.OID, k, thePtColl.get_Point(k)));
}
}
theFeature1 = theFCursor1.NextFeature();
}
// Release the cursor
Marshal.ReleaseComObject(theFCursor1);
//.........这里部分代码省略.........
示例11: panButton_Click
private void panButton_Click(object sender, System.EventArgs e)
{
try
{
Conflict conflict = getSelected();
if(ext != null && conflict != null && conflict.Shape != null)
{
IEnvelope shEnv = new EnvelopeClass();
conflict.Shape.QueryEnvelope(shEnv);
IPoint pt = new PointClass();
pt.PutCoords( ((shEnv.XMax-shEnv.XMin)/2)+shEnv.XMin, ((shEnv.YMax-shEnv.YMin)/2)+shEnv.YMin);
pt.SpatialReference = conflict.Shape.SpatialReference;
IEnvelope current = ((IActiveView)this.ext.FocusMap).Extent;
pt.Project(current.SpatialReference);
current.CenterAt(pt);
//this.ext.FocusMap.AreaOfInterest = current;
((IActiveView)this.ext.FocusMap).Extent = current;
((IActiveView)this.ext.FocusMap).Refresh();
}
}
catch(Exception ee)
{
Logger.Warn(ee);
MessageBox.Show("An Unexpected Error Occured: "+ee.Message+"\n\tPlease Review the Log.",
"EXCEPTION", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
示例12: btnZoomSelected_Click
// zooms to features in the map that correspond to selected features in the list view
private void btnZoomSelected_Click(object sender, System.EventArgs e)
{
try
{
IQueryFilter pQueryFilter = new QueryFilterClass();
IFeatureClass pFeatureClass = m_pFeatureLayer.FeatureClass;
// build array of selected OIDs
string[] OID = new string[lvGPS.SelectedItems.Count];
for(int x = 0; x < lvGPS.SelectedItems.Count; x++)
{
OID[x] = lvGPS.SelectedItems[x].Text;
}
string OIDs = String.Join(",",OID);
// build the whereclause
string whereclause = pFeatureClass.OIDFieldName + " IN (" + OIDs + ")";
Debug.WriteLine(whereclause);
pQueryFilter.WhereClause = whereclause;
// bind query filter resultant geometry into a geometry bag
IEnumGeometryBind pEnumBind = new EnumFeatureGeometryClass();
IGeometryFactory pGeomFactory = new GeometryEnvironmentClass();
pEnumBind.BindGeometrySource(pQueryFilter,pFeatureClass);
IGeometryBag pGeometryBag = (IGeometryBag)pGeomFactory.CreateGeometryFromEnumerator((IEnumGeometry)pEnumBind);
IGeometryCollection pGeomCollection = (IGeometryCollection)pGeometryBag;
// TODO:
//IMxDocument pMxDoc = (IMxDocument)m_pApp.Document;
IActiveView pActiveView = (IActiveView)m_pISDUTExt.FocusMap; //pMxDoc.FocusMap;
//util.Utils.Release(pMxDoc);
IEnvelope pEnv = pGeometryBag.Envelope;
if(pGeomCollection.GeometryCount == 1)
{
// if only one point the do a pan instead of a zoom
IPoint pPoint = new PointClass();
pPoint.PutCoords(pEnv.XMin,pEnv.YMin);
// get SR of featureclass
IGeoDataset pGeodataset = (IGeoDataset)m_pFeatureLayer.FeatureClass;
pPoint.SpatialReference = pGeodataset.SpatialReference;
// project point to match focus map SR
// TODO:
//pMxDoc = (IMxDocument)m_pApp.Document;
pPoint.Project(m_pISDUTExt.FocusMap.SpatialReference);// pMxDoc.FocusMap.SpatialReference);
//util.Utils.Release(pMxDoc);
IEnvelope pPanEnv = pActiveView.Extent;
pPanEnv.CenterAt(pPoint);
pActiveView.Extent = pPanEnv;
}
else
{
pEnv.Expand(1.1,1.1,true);
pActiveView.Extent = pEnv;
}
pActiveView.Refresh();
}
catch(Exception ex)
{
util.Logger.Write(" Descrip : Zooms to features on the map the correspond with items selected in the list view." +
"\n Message : " + ex.Message +
"\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug);
MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
Debug.WriteLine(ex.Message + "\n" + ex.StackTrace);
}
//lvGPS.Focus();
}
示例13: MakeTxtFileOfJSONElevationResponses
//.........这里部分代码省略.........
//return;
Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
System.Object obj = Activator.CreateInstance(factoryType);
ISpatialReferenceFactory spatialReferenceFactory = obj as ISpatialReferenceFactory;
ISpatialReference spatRef = spatialReferenceFactory.CreateGeographicCoordinateSystem(4326);
//ISpatialReference existingSpatRef = geomCol.get_Geometry(0).SpatialReference;
ISpatialReference existingSpatRef = startWaypoint.ShapeCopy.SpatialReference;
/*IFeature trailFe = feCur.NextFeature();
ISpatialReference existingSpatRef = null;
while (trailFe != null)
{
geomCol.AddGeometry(trailFe.ShapeCopy);
if(existingSpatRef == null)
{
existingSpatRef = trailFe.ShapeCopy.SpatialReference;
}
trailFe = feCur.NextFeature();
}*/
IPointCollection newPolyline = new PolylineClass();
((IGeometry)newPolyline).SpatialReference = startWaypoint.ShapeCopy.SpatialReference;
HashSet<string> points = new HashSet<string>();
for(int i = 0 ; i < geomCol.GeometryCount; i++)
{
IPointCollection geomPntCol = geomCol.get_Geometry(i) as IPointCollection;
for (int j = 0; j < geomPntCol.PointCount; j++ )
{
IPoint pnt = geomPntCol.get_Point(j);
string pntString = pnt.X + "," + pnt.Y;
if(points.Contains(pntString) == false)
{
points.Add(pntString);
pnt.SpatialReference = startWaypoint.ShapeCopy.SpatialReference;
newPolyline.AddPoint(pnt);
}
}
}
IPolyline fullTrail = newPolyline as IPolyline;
fullTrail.SpatialReference = startWaypoint.ShapeCopy.SpatialReference;
//ITopologicalOperator unionedPolyline = new PolylineClass();
//unionedPolyline.ConstructUnion(geomCol as IEnumGeometry);
//IPolyline fullTrail = unionedPolyline as IPolyline;
Marshal.FinalReleaseComObject(feCur);
IFeature fromPoint = waypointFC.GetFeature(Convert.ToInt16( startWaypointOID));
IProximityOperator proxOp = fromPoint.ShapeCopy as IProximityOperator;
double fromPointDist = proxOp.ReturnDistance(fullTrail.FromPoint);
if (proxOp.ReturnDistance(fullTrail.ToPoint) == 0)
{
fullTrail.ReverseOrientation();
}
int dividePointIndex = 1;
List<IPoint> pointsOnTrail = new List<IPoint>();
double totalDistance = 0;
while(dividePointIndex * distanceBetweenPoints < fullTrail.Length)
{
IPoint outPoint = new PointClass();
fullTrail.QueryPoint(esriSegmentExtension.esriNoExtension, dividePointIndex * distanceBetweenPoints, false, outPoint);
outPoint.SpatialReference = existingSpatRef;
outPoint.Project(spatRef);
pointsOnTrail.Add(outPoint);
dividePointIndex++;
}
StringBuilder sb = new StringBuilder();
List<string> locationStrings = new List<string>();
int locationPointsInStringBuilder = 0;
for (int i = 0; i < pointsOnTrail.Count; i++)
{
if(sb.Length > 0)
{
sb.Append("|");
}
sb.Append(pointsOnTrail[i].Y);
sb.Append(",");
sb.Append(pointsOnTrail[i].X);
locationPointsInStringBuilder++;
if (locationPointsInStringBuilder > 33)
{
locationStrings.Add(sb.ToString());
sb = new StringBuilder();
locationPointsInStringBuilder = 0;
}
}
locationStrings.Add(sb.ToString());
//FileStream fsw = File.OpenWrite(@"c:\temp\SectionAElevations.txt");
int counter = 0;
foreach(string locString in locationStrings)
{
counter++;
//FileStream fsw = File.OpenWrite(@"c:\temp\SectionAElevations.txt");
string address = "https://maps.googleapis.com/maps/api/elevation/json?locations=" + locString + "&key=AIzaSyBJlaYSBeJkYl_G2tInjNJBYmjJhaSulLA";
System.Threading.Thread.Sleep(1000);
string reply = client.DownloadString(address);
File.AppendAllText(@"c:\temp\Section" + sectionName + "Elevations.txt", reply + Environment.NewLine);
}
// https://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536,-104.9847034|36.455556,-116.866667&key=AIzaSyC2WxuR5N1TKk5rfFrFQSd_IwMlg3TvVnM
//string address = @"https://maps.googleapis.com/maps/api/elevation/json?path=" + path + "&samples=" + samples + "&key=AIzaSyC2WxuR5N1TKk5rfFrFQSd_IwMlg3TvVnM";
}
示例14: OnClick
protected override void OnClick()
{
int beginingDistance = 1485480;//distanc for the first point in this section
MakeTxtFileOfJSONElevationResponses();
//return;
string trailName = "GDT";
string section = "G";
IFeatureClass trailFC = null;
IFeatureClass elevationFC = null;
IFeatureClass waypointFC = null;
GetFeatureClasses(ref trailFC, ref elevationFC, ref waypointFC);
IWorkspaceEdit wse = (IWorkspaceEdit)(elevationFC as IDataset).Workspace;
wse.StartEditing(false);
wse.StartEditOperation();
Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
System.Object obj = Activator.CreateInstance(factoryType);
ISpatialReferenceFactory spatialReferenceFactory = obj as ISpatialReferenceFactory;
ISpatialReference spatRef = spatialReferenceFactory.CreateGeographicCoordinateSystem(4326);
ISpatialReference spatRefWGS = spatialReferenceFactory.CreateProjectedCoordinateSystem(3857);
string fullText = File.ReadAllText(@"c:\temp\section'" + section + "'elevations.txt");
string[] split = new string[1];
split[0] = Environment.NewLine;
string[] results = fullText.Split(split, StringSplitOptions.None);
double dat = 0;
foreach (string json in results)
{
RootObject root = JsonConvert.DeserializeObject<RootObject>(json);
if (root != null)
{
foreach (Result result in root.results)
{
double elevation = result.elevation;
double lat = result.location.lat;
double lng = result.location.lng;
double resolotuion = result.resolution;
IPoint pnt = new PointClass();
pnt.SpatialReference = spatRef;
pnt.PutCoords(lng, lat);
pnt.Project(spatRefWGS);
IFeature newFeature = elevationFC.CreateFeature();
newFeature.Shape = pnt;
newFeature.set_Value(newFeature.Fields.FindField("ELEVATION"), elevation);
newFeature.set_Value(newFeature.Fields.FindField("LAT"), lat);
newFeature.set_Value(newFeature.Fields.FindField("LNG"), lng);
newFeature.set_Value(newFeature.Fields.FindField("RESOLUTION"), resolotuion);
newFeature.set_Value(newFeature.Fields.FindField("TRAILNAME"), trailName);
newFeature.set_Value(newFeature.Fields.FindField("SECTION"), section);
double dat2 = beginingDistance + dat;
newFeature.set_Value(newFeature.Fields.FindField("DISTANCEALONGTRAIL"), dat2);
newFeature.Store();
dat = dat + 10;
}
}
}
wse.StopEditOperation();
wse.StopEditing(true);
}
示例15: DisplayAgentLocation
private void DisplayAgentLocation(AGENT_IN_FIELD agent)
{
//Create a point and get the IPoint interface
IPoint point = new PointClass();
//Set the points x and y coordinates
point.PutCoords(agent.Longitude, agent.Latitude);
//Set the points spatial reference - WHERE the point is coming FROM
point.SpatialReference = m_GeographicCoordinateSystem;
//Project the point onto the displays current spatial reference - WHERE the point is going TO
point.Project(m_ProjectedCoordinateSystem);
//Create a marker element and get the IElement interface
IElement element = new MarkerElementClass();
//Set the elements geometry
element.Geometry = point;
//QI for the IMarkerElement interface from the IElement interface
IMarkerElement markerElement = (IMarkerElement) element;
//Set the marker symbol
markerElement.Symbol = GetMarkerSymbol(agent.Located);
//QI for the IElementProperties interface from the IMarkerElement interface
IElementProperties elementProperties = (IElementProperties) markerElement;
elementProperties.Name = agent.Located.ToString();
//Add the element to the graphics container
m_GraphicsContainer.AddElement(element, 0);
}